From 9615b103ac8fd760e00f242f168546fff073cc0c Mon Sep 17 00:00:00 2001 From: Alex Popa Date: Thu, 9 Jan 2025 21:30:25 +0200 Subject: [PATCH] View mode 3 4 --- .../EditDetailedEvaluationResult.php | 1 + .../ViewDetailedEvaluation.php | 25 ++------ .../Widgets/CounselingSheetWidget.php | 63 ++++++++++--------- lang/ro/intervention_plan.php | 1 + 4 files changed, 39 insertions(+), 51 deletions(-) diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/DetailedEvaluation/EditDetailedEvaluationResult.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/DetailedEvaluation/EditDetailedEvaluationResult.php index c9e84015..9f9a1c38 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/DetailedEvaluation/EditDetailedEvaluationResult.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/DetailedEvaluation/EditDetailedEvaluationResult.php @@ -55,6 +55,7 @@ public static function getSchema(): array ->schema([ Section::make(__('beneficiary.section.detailed_evaluation.heading.recommendation_services')) ->schema(self::getRecommendationServicesSchema()), + self::getInterventionPlanSchema(), ]), diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/DetailedEvaluation/ViewDetailedEvaluation.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/DetailedEvaluation/ViewDetailedEvaluation.php index 05f846a1..51ab02f7 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/DetailedEvaluation/ViewDetailedEvaluation.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/DetailedEvaluation/ViewDetailedEvaluation.php @@ -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; @@ -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') diff --git a/app/Filament/Organizations/Resources/InterventionServiceResource/Widgets/CounselingSheetWidget.php b/app/Filament/Organizations/Resources/InterventionServiceResource/Widgets/CounselingSheetWidget.php index 89d5d511..b944a3fe 100644 --- a/app/Filament/Organizations/Resources/InterventionServiceResource/Widgets/CounselingSheetWidget.php +++ b/app/Filament/Organizations/Resources/InterventionServiceResource/Widgets/CounselingSheetWidget.php @@ -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')), diff --git a/lang/ro/intervention_plan.php b/lang/ro/intervention_plan.php index 762122ed..894fc465 100644 --- a/lang/ro/intervention_plan.php +++ b/lang/ro/intervention_plan.php @@ -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' => [