Skip to content

Commit

Permalink
Merge pull request #486 from code4romania/381-general-ui-enhancements…
Browse files Browse the repository at this point in the history
…-across-components

View mode 3 4
  • Loading branch information
gheorghelupu17 authored Jan 13, 2025
2 parents 0fed219 + 9615b10 commit f1214ab
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public static function getSchema(): array
->schema([
Section::make(__('beneficiary.section.detailed_evaluation.heading.recommendation_services'))
->schema(self::getRecommendationServicesSchema()),

self::getInterventionPlanSchema(),

]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

use App\Actions\BackAction;
use App\Enums\AddressType;
use App\Enums\RecommendationService;
use App\Enums\Ternary;
use App\Filament\Organizations\Resources\BeneficiaryResource;
use App\Filament\Organizations\Resources\BeneficiaryResource\Pages\ViewBeneficiaryIdentity;
use App\Infolists\Components\Actions\EditAction;
Expand Down Expand Up @@ -134,28 +132,15 @@ public function infolist(Infolist $infolist): Infolist

private function getResultSchema(): array
{
$fields = [];
$record = $this->getRecord();
foreach (RecommendationService::options() as $key => $value) {
$fields[] = TextEntry::make($key)
->label($value)
->state(
$record->detailedEvaluationResult
->recommendation_services
->contains(RecommendationService::tryFrom($key)) ?
Ternary::YES->getLabel() :
Ternary::NO->getLabel()
);
}

return [
...$fields,
TextEntry::make('recommendation_services.other_services')
->formatStateUsing(fn ($state) => $record ? __('enum.ternary.1') : __('enum.ternary.0'))
->label(__('beneficiary.section.detailed_evaluation.labels.other_services')),
TextEntry::make('recommendation_services')
->label(__('beneficiary.section.detailed_evaluation.heading.recommendation_services'))
->listWithLineBreaks(),

TextEntry::make('other_services_description')
->label(__('beneficiary.section.detailed_evaluation.labels.other_services'))
->placeholder(__('beneficiary.placeholder.other_services')),

Section::make(__('beneficiary.section.detailed_evaluation.labels.recommendations_for_intervention_plan'))
->schema([
TextEntry::make('recommendations_for_intervention_plan')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,37 +175,38 @@ private function getSchemaForPsychologicalAssistance(): array
TextEntry::make('data.violence_history_forms')
->label(__('intervention_plan.labels.violence_history_forms')),

EnumEntry::make('data.physics')
->label(__('intervention_plan.labels.physics'))
->enumClass(ExtendedFrequency::class),

EnumEntry::make('data.sexed')
->label(__('intervention_plan.labels.sexed'))
->enumClass(ExtendedFrequency::class),

EnumEntry::make('data.psychological')
->label(__('intervention_plan.labels.psychological'))
->enumClass(ExtendedFrequency::class),

EnumEntry::make('data.verbal')
->label(__('intervention_plan.labels.verbal'))
->enumClass(ExtendedFrequency::class),

EnumEntry::make('data.sociable')
->label(__('intervention_plan.labels.sociable'))
->enumClass(ExtendedFrequency::class),

EnumEntry::make('data.economic')
->label(__('intervention_plan.labels.economic'))
->enumClass(ExtendedFrequency::class),

EnumEntry::make('data.cybernetics')
->label(__('intervention_plan.labels.cybernetics'))
->enumClass(ExtendedFrequency::class),

EnumEntry::make('data.spiritual')
->label(__('intervention_plan.labels.spiritual'))
->enumClass(ExtendedFrequency::class),
TextEntry::make('violence_frequency')
->label(__('intervention_plan.labels.violence_frequency'))
->state(function ($record) {
$fields = [
'physics',
'sexed',
'psychological',
'verbal',
'sociable',
'economic',
'cybernetics',
'spiritual',
];

$result = [];
foreach ($fields as $field) {
$data = $record->counselingSheet->data;
if ($data[$field] &&
! ExtendedFrequency::isValue($data[$field], ExtendedFrequency::NO_ANSWER) &&
! ExtendedFrequency::isValue($data[$field], ExtendedFrequency::NONE)
) {
$result[] = \sprintf(
'%s - %s',
__('intervention_plan.labels.' . $field),
ExtendedFrequency::tryFrom($data[$field])->getLabel()
);
}
}

return $result;
})
->listWithLineBreaks(),

TextEntry::make('data.physical_violence_description')
->label(__('intervention_plan.labels.physical_violence_description')),
Expand Down
1 change: 1 addition & 0 deletions lang/ro/intervention_plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
'service_details' => 'Detalii acordare serviciu',
'award_methods' => 'Modalitatea de acordare',
'intervention_details' => 'Detalii acordare intervenții',
'violence_frequency' => 'Frecvența formelor de violență'
],

'headings' => [
Expand Down

0 comments on commit f1214ab

Please sign in to comment.