From 3e95da2dbb444b395d3cf5f0cb1c5a5cbc443927 Mon Sep 17 00:00:00 2001 From: Alex Popa Date: Fri, 20 Dec 2024 03:35:12 +0200 Subject: [PATCH] Back action --- app/Actions/BackAction.php | 24 ++++++++ app/Concerns/HasBackAction.php | 18 ++++++ app/Concerns/RedirectToCloseFile.php | 2 + app/Concerns/RedirectToDetailedEvaluation.php | 2 + app/Concerns/RedirectToIdentity.php | 2 + app/Concerns/RedirectToInitialEvaluation.php | 2 + app/Concerns/RedirectToMonitoring.php | 2 + .../RedirectToPersonalInformation.php | 2 + .../Pages/EditBeneficiaryIntervention.php | 4 ++ .../Pages/ViewBeneficiaryIntervention.php | 15 +++++ .../Pages/ViewMeetings.php | 15 +++++ .../Pages/ViewUnfoldedMeetings.php | 15 +++++ .../Pages/CloseFile/CreateCloseFile.php | 9 +++ .../Pages/CloseFile/ViewCloseFile.php | 4 ++ .../CreateDetailedEvaluation.php | 12 +++- .../ViewDetailedEvaluation.php | 9 +++ .../Pages/EditBeneficiaryIdentity.php | 7 --- .../EditBeneficiaryPersonalInformation.php | 7 --- .../CreateInitialEvaluation.php | 9 +++ .../ViewInitialEvaluation.php | 9 +++ .../Pages/ListSpecialists.php | 11 +++- .../Pages/ViewBeneficiary.php | 6 +- .../Pages/ViewBeneficiaryIdentity.php | 9 +++ .../ViewBeneficiaryPersonalInformation.php | 9 +++ .../DocumentResource/Pages/ListDocuments.php | 5 ++ .../DocumentResource/Pages/ViewDocument.php | 5 ++ .../Pages/ViewInterventionPlan.php | 5 ++ .../Pages/EditCounselingSheet.php | 14 ++++- .../Pages/EditInterventionService.php | 4 ++ .../Pages/ViewInterventionService.php | 15 +++++ .../Widgets/CounselingSheetWidget.php | 6 +- .../Pages/CreateMonitoring.php | 9 ++- .../Pages/ListMonitoring.php | 5 ++ .../Pages/ViewMonitoring.php | 5 ++ lang/ro/beneficiary.php | 2 +- .../components/header/index.blade.php | 60 +++++++++++++++++++ 36 files changed, 313 insertions(+), 26 deletions(-) create mode 100644 app/Actions/BackAction.php create mode 100644 app/Concerns/HasBackAction.php create mode 100644 resources/views/vendor/filament-panels/components/header/index.blade.php diff --git a/app/Actions/BackAction.php b/app/Actions/BackAction.php new file mode 100644 index 00000000..44ffcd7a --- /dev/null +++ b/app/Actions/BackAction.php @@ -0,0 +1,24 @@ +icon('heroicon-o-chevron-left'); + $this->hiddenLabel(); + $this->link(); + } + + public function getName(): ?string + { + return 'back_action'; + } +} diff --git a/app/Concerns/HasBackAction.php b/app/Concerns/HasBackAction.php new file mode 100644 index 00000000..3c45903d --- /dev/null +++ b/app/Concerns/HasBackAction.php @@ -0,0 +1,18 @@ +url($this->getRedirectUrl()), + ]; + } +} diff --git a/app/Concerns/RedirectToCloseFile.php b/app/Concerns/RedirectToCloseFile.php index 23449faf..a1a3f9ef 100644 --- a/app/Concerns/RedirectToCloseFile.php +++ b/app/Concerns/RedirectToCloseFile.php @@ -6,6 +6,8 @@ trait RedirectToCloseFile { + use HasBackAction; + protected function getRedirectUrl(): string { return self::$resource::getUrl('view_close_file', [ diff --git a/app/Concerns/RedirectToDetailedEvaluation.php b/app/Concerns/RedirectToDetailedEvaluation.php index e9168bd9..242be4fb 100644 --- a/app/Concerns/RedirectToDetailedEvaluation.php +++ b/app/Concerns/RedirectToDetailedEvaluation.php @@ -6,6 +6,8 @@ trait RedirectToDetailedEvaluation { + use HasBackAction; + protected function getRedirectUrl(): string { return self::$resource::getUrl('view_detailed_evaluation', [ diff --git a/app/Concerns/RedirectToIdentity.php b/app/Concerns/RedirectToIdentity.php index 2660916e..7217e29a 100644 --- a/app/Concerns/RedirectToIdentity.php +++ b/app/Concerns/RedirectToIdentity.php @@ -6,6 +6,8 @@ trait RedirectToIdentity { + use HasBackAction; + protected function getRedirectUrl(): string { return static::getResource()::getUrl('view_identity', [ diff --git a/app/Concerns/RedirectToInitialEvaluation.php b/app/Concerns/RedirectToInitialEvaluation.php index 39da1321..5e2bb9ca 100644 --- a/app/Concerns/RedirectToInitialEvaluation.php +++ b/app/Concerns/RedirectToInitialEvaluation.php @@ -6,6 +6,8 @@ trait RedirectToInitialEvaluation { + use HasBackAction; + protected function getRedirectUrl(): string { return self::$resource::getUrl('view_initial_evaluation', [ diff --git a/app/Concerns/RedirectToMonitoring.php b/app/Concerns/RedirectToMonitoring.php index fd98fa28..911679ed 100644 --- a/app/Concerns/RedirectToMonitoring.php +++ b/app/Concerns/RedirectToMonitoring.php @@ -6,6 +6,8 @@ trait RedirectToMonitoring { + use HasBackAction; + protected function getRedirectUrl(): ?string { return self::getParentResource()::getUrl('monitorings.view', [ diff --git a/app/Concerns/RedirectToPersonalInformation.php b/app/Concerns/RedirectToPersonalInformation.php index c03f3676..de35445a 100644 --- a/app/Concerns/RedirectToPersonalInformation.php +++ b/app/Concerns/RedirectToPersonalInformation.php @@ -6,6 +6,8 @@ trait RedirectToPersonalInformation { + use HasBackAction; + protected function getRedirectUrl(): string { return static::getResource()::getUrl('view_personal_information', [ diff --git a/app/Filament/Organizations/Resources/BeneficiaryInterventionResource/Pages/EditBeneficiaryIntervention.php b/app/Filament/Organizations/Resources/BeneficiaryInterventionResource/Pages/EditBeneficiaryIntervention.php index 028b6fd6..d7834cd5 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryInterventionResource/Pages/EditBeneficiaryIntervention.php +++ b/app/Filament/Organizations/Resources/BeneficiaryInterventionResource/Pages/EditBeneficiaryIntervention.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\BeneficiaryInterventionResource\Pages; +use App\Actions\BackAction; use App\Concerns\HasParentResource; use App\Filament\Organizations\Resources\BeneficiaryInterventionResource; use App\Filament\Organizations\Resources\InterventionPlanResource; @@ -41,6 +42,9 @@ public function getTitle(): string|Htmlable protected function getHeaderActions(): array { return [ + BackAction::make() + ->url($this->getRedirectUrl()), + Actions\DeleteAction::make() ->label(__('intervention_plan.actions.delete_beneficiary_intervention')) ->outlined() diff --git a/app/Filament/Organizations/Resources/BeneficiaryInterventionResource/Pages/ViewBeneficiaryIntervention.php b/app/Filament/Organizations/Resources/BeneficiaryInterventionResource/Pages/ViewBeneficiaryIntervention.php index bec2cb33..20fdcec6 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryInterventionResource/Pages/ViewBeneficiaryIntervention.php +++ b/app/Filament/Organizations/Resources/BeneficiaryInterventionResource/Pages/ViewBeneficiaryIntervention.php @@ -4,9 +4,11 @@ namespace App\Filament\Organizations\Resources\BeneficiaryInterventionResource\Pages; +use App\Actions\BackAction; use App\Concerns\HasGroupPages; use App\Concerns\HasParentResource; use App\Filament\Organizations\Resources\BeneficiaryInterventionResource; +use App\Filament\Organizations\Resources\InterventionPlanResource; use App\Filament\Organizations\Resources\InterventionServiceResource; use App\Services\Breadcrumb\InterventionPlanBreadcrumb; use Filament\Infolists\Components\Actions\Action; @@ -37,6 +39,19 @@ public function getTitle(): string|Htmlable return $this->getRecord()->organizationServiceIntervention->serviceInterventionWithoutStatusCondition->name; } + protected function getHeaderActions(): array + { + return [ + BackAction::make() + ->url( + InterventionPlanResource::getUrl('view_intervention_service', [ + 'parent' => $this->parent->interventionPlan, + 'record' => $this->parent, + ]) + ), + ]; + } + public function infolist(Infolist $infolist): Infolist { return $infolist diff --git a/app/Filament/Organizations/Resources/BeneficiaryInterventionResource/Pages/ViewMeetings.php b/app/Filament/Organizations/Resources/BeneficiaryInterventionResource/Pages/ViewMeetings.php index d9dac8cb..e46f193b 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryInterventionResource/Pages/ViewMeetings.php +++ b/app/Filament/Organizations/Resources/BeneficiaryInterventionResource/Pages/ViewMeetings.php @@ -4,10 +4,12 @@ namespace App\Filament\Organizations\Resources\BeneficiaryInterventionResource\Pages; +use App\Actions\BackAction; use App\Concerns\HasGroupPages; use App\Concerns\HasParentResource; use App\Enums\MeetingStatus; use App\Filament\Organizations\Resources\BeneficiaryInterventionResource; +use App\Filament\Organizations\Resources\InterventionPlanResource; use App\Filament\Organizations\Resources\InterventionServiceResource; use App\Forms\Components\DatePicker; use App\Forms\Components\Select; @@ -50,6 +52,19 @@ public function getTitle(): string|Htmlable return $this->getRecord()->organizationServiceIntervention->serviceInterventionWithoutStatusCondition->name; } + protected function getHeaderActions(): array + { + return [ + BackAction::make() + ->url( + InterventionPlanResource::getUrl('view_intervention_service', [ + 'parent' => $this->parent->interventionPlan, + 'record' => $this->parent, + ]) + ), + ]; + } + protected function getFormSchema(): array { return [ diff --git a/app/Filament/Organizations/Resources/BeneficiaryInterventionResource/Pages/ViewUnfoldedMeetings.php b/app/Filament/Organizations/Resources/BeneficiaryInterventionResource/Pages/ViewUnfoldedMeetings.php index 8d9dd00a..cf6c29f7 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryInterventionResource/Pages/ViewUnfoldedMeetings.php +++ b/app/Filament/Organizations/Resources/BeneficiaryInterventionResource/Pages/ViewUnfoldedMeetings.php @@ -4,10 +4,12 @@ namespace App\Filament\Organizations\Resources\BeneficiaryInterventionResource\Pages; +use App\Actions\BackAction; use App\Concerns\HasGroupPages; use App\Concerns\HasParentResource; use App\Filament\Organizations\Resources\BeneficiaryInterventionResource; use App\Filament\Organizations\Resources\BeneficiaryInterventionResource\Widgets\UnfoldedWidget; +use App\Filament\Organizations\Resources\InterventionPlanResource; use App\Services\Breadcrumb\InterventionPlanBreadcrumb; use Filament\Resources\Pages\ViewRecord; use Illuminate\Contracts\Support\Htmlable; @@ -32,6 +34,19 @@ public function getTitle(): string|Htmlable return $this->getRecord()->organizationServiceIntervention->serviceInterventionWithoutStatusCondition->name; } + protected function getHeaderActions(): array + { + return [ + BackAction::make() + ->url( + InterventionPlanResource::getUrl('view_intervention_service', [ + 'parent' => $this->parent->interventionPlan, + 'record' => $this->parent, + ]) + ), + ]; + } + protected function getFooterWidgets(): array { return [ diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/CloseFile/CreateCloseFile.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/CloseFile/CreateCloseFile.php index 035a35ed..d235eaba 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/CloseFile/CreateCloseFile.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/CloseFile/CreateCloseFile.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\BeneficiaryResource\Pages\CloseFile; +use App\Actions\BackAction; use App\Concerns\PreventMultipleSubmit; use App\Concerns\PreventSubmitFormOnEnter; use App\Filament\Organizations\Resources\BeneficiaryResource; @@ -46,6 +47,14 @@ protected function getRedirectUrl(): ?string return self::getResource()::getUrl('view_close_file', ['record' => $this->getRecord()]); } + protected function getHeaderActions(): array + { + return [ + BackAction::make() + ->url(BeneficiaryResource::getUrl('view', ['record' => $this->getRecord()])), + ]; + } + public function beforeFill(): void { $this->prefillFormData = [ diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/CloseFile/ViewCloseFile.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/CloseFile/ViewCloseFile.php index b4a63d30..997c2a4d 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/CloseFile/ViewCloseFile.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/CloseFile/ViewCloseFile.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\BeneficiaryResource\Pages\CloseFile; +use App\Actions\BackAction; use App\Enums\CloseMethod; use App\Filament\Organizations\Resources\BeneficiaryResource; use App\Filament\Organizations\Resources\BeneficiaryResource\Pages\ViewBeneficiaryIdentity; @@ -36,6 +37,9 @@ public function getBreadcrumbs(): array protected function getHeaderActions(): array { return [ + BackAction::make() + ->url(BeneficiaryResource::getUrl('view', ['record' => $this->getRecord()])), + DeleteAction::make() ->label(__('beneficiary.section.close_file.actions.delete')) ->outlined() diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/DetailedEvaluation/CreateDetailedEvaluation.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/DetailedEvaluation/CreateDetailedEvaluation.php index 05756211..503dc59e 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/DetailedEvaluation/CreateDetailedEvaluation.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/DetailedEvaluation/CreateDetailedEvaluation.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\BeneficiaryResource\Pages\DetailedEvaluation; +use App\Actions\BackAction; use App\Concerns\PreventMultipleSubmit; use App\Concerns\PreventSubmitFormOnEnter; use App\Filament\Organizations\Resources\BeneficiaryResource; @@ -38,14 +39,19 @@ public function getBreadcrumbs(): array ->getBreadcrumbs('create_detailed_evaluation'); } - /** - * @return string|Htmlable - */ public function getTitle(): string|Htmlable { return __('beneficiary.page.create_detailed_evaluation.title'); } + protected function getHeaderActions(): array + { + return [ + BackAction::make() + ->url(BeneficiaryResource::getUrl('view', ['record' => $this->getRecord()])), + ]; + } + public function getSteps(): array { return [ diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/DetailedEvaluation/ViewDetailedEvaluation.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/DetailedEvaluation/ViewDetailedEvaluation.php index cf44e10d..0e70977e 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/DetailedEvaluation/ViewDetailedEvaluation.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/DetailedEvaluation/ViewDetailedEvaluation.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\BeneficiaryResource\Pages\DetailedEvaluation; +use App\Actions\BackAction; use App\Enums\AddressType; use App\Enums\RecommendationService; use App\Enums\Ternary; @@ -36,6 +37,14 @@ public function getBreadcrumbs(): array ->getBreadcrumbs('view_detailed_evaluation'); } + protected function getHeaderActions(): array + { + return [ + BackAction::make() + ->url(BeneficiaryResource::getUrl('view', ['record' => $this->getRecord()])), + ]; + } + public function infolist(Infolist $infolist): Infolist { return $infolist diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/EditBeneficiaryIdentity.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/EditBeneficiaryIdentity.php index dd97178b..7611ec7e 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/EditBeneficiaryIdentity.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/EditBeneficiaryIdentity.php @@ -41,13 +41,6 @@ class EditBeneficiaryIdentity extends EditRecord protected static string $resource = BeneficiaryResource::class; - protected function getHeaderActions(): array - { - return [ - // - ]; - } - public function getTitle(): string|Htmlable { return __('beneficiary.page.edit_identity.title'); diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/EditBeneficiaryPersonalInformation.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/EditBeneficiaryPersonalInformation.php index 98282954..5633d8ca 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/EditBeneficiaryPersonalInformation.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/EditBeneficiaryPersonalInformation.php @@ -33,13 +33,6 @@ class EditBeneficiaryPersonalInformation extends EditRecord protected static string $resource = BeneficiaryResource::class; - protected function getHeaderActions(): array - { - return [ - // - ]; - } - public function getTitle(): string|Htmlable { return __('beneficiary.page.edit_personal_information.title', [ diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/InitialEvaluation/CreateInitialEvaluation.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/InitialEvaluation/CreateInitialEvaluation.php index 155b6265..6a92c506 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/InitialEvaluation/CreateInitialEvaluation.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/InitialEvaluation/CreateInitialEvaluation.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\BeneficiaryResource\Pages\InitialEvaluation; +use App\Actions\BackAction; use App\Concerns\PreventMultipleSubmit; use App\Concerns\PreventSubmitFormOnEnter; use App\Filament\Organizations\Resources\BeneficiaryResource; @@ -37,6 +38,14 @@ public function getBreadcrumbs(): array ->getBreadcrumbs('create_initial_evaluation'); } + protected function getHeaderActions(): array + { + return [ + BackAction::make() + ->url(BeneficiaryResource::getUrl('view', ['record' => $this->getRecord()])), + ]; + } + public function getSteps(): array { return [ diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/InitialEvaluation/ViewInitialEvaluation.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/InitialEvaluation/ViewInitialEvaluation.php index 971cc6a1..7cc8c78f 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/InitialEvaluation/ViewInitialEvaluation.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/InitialEvaluation/ViewInitialEvaluation.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\BeneficiaryResource\Pages\InitialEvaluation; +use App\Actions\BackAction; use App\Enums\RecommendationService; use App\Enums\Ternary; use App\Filament\Organizations\Resources\BeneficiaryResource; @@ -35,6 +36,14 @@ public function getBreadcrumbs(): array ->getBreadcrumbs('view_initial_evaluation'); } + protected function getHeaderActions(): array + { + return [ + BackAction::make() + ->url(BeneficiaryResource::getUrl('view', ['record' => $this->getRecord()])), + ]; + } + public function infolist(Infolist $infolist): Infolist { return $infolist->schema([ diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ListSpecialists.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ListSpecialists.php index 06cf209e..0bca56f5 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ListSpecialists.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ListSpecialists.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\BeneficiaryResource\Pages; +use App\Actions\BackAction; use App\Filament\Organizations\Resources\BeneficiaryResource; use App\Services\Breadcrumb\BeneficiaryBreadcrumb; use Filament\Resources\Pages\ViewRecord; @@ -19,6 +20,14 @@ public function getBreadcrumbs(): array ->getBreadcrumbs('view_specialists'); } + protected function getHeaderActions(): array + { + return [ + BackAction::make() + ->url(BeneficiaryResource::getUrl('view', ['record' => $this->getRecord()])), + ]; + } + protected function getHeaderWidgets(): array { return [ @@ -31,7 +40,7 @@ public function getHeaderWidgetsColumns(): int|string|array return 1; } - public function getHeading(): string|Htmlable + public function getTitle(): string|Htmlable { return __('beneficiary.section.specialists.title'); } diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ViewBeneficiary.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ViewBeneficiary.php index c604fe0b..8af1d309 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ViewBeneficiary.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ViewBeneficiary.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\BeneficiaryResource\Pages; +use App\Actions\BackAction; use App\Enums\ActivityDescription; use App\Enums\AddressType; use App\Enums\CaseStatus; @@ -131,9 +132,6 @@ protected function getHeaderActions(): array ]; } - /** - * @return string|Htmlable - */ public function getTitle(): string|Htmlable { $statusBadge = Blade::render('{{$name}}', [ @@ -142,6 +140,8 @@ public function getTitle(): string|Htmlable ]); return new HtmlString(__('beneficiary.page.view.title', [ + 'action' => BackAction::make() + ->url(BeneficiaryResource::getUrl())->toHtml(), 'name' => $this->record->full_name, 'id' => $this->record->id, 'badge' => $statusBadge, diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ViewBeneficiaryIdentity.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ViewBeneficiaryIdentity.php index 7865991c..c950d629 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ViewBeneficiaryIdentity.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ViewBeneficiaryIdentity.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\BeneficiaryResource\Pages; +use App\Actions\BackAction; use App\Enums\AddressType; use App\Filament\Organizations\Resources\BeneficiaryResource; use App\Infolists\Components\Actions\Edit; @@ -38,6 +39,14 @@ public function getBreadcrumbs(): array ->getBreadcrumbs('view_identity'); } + protected function getHeaderActions(): array + { + return [ + BackAction::make() + ->url(BeneficiaryResource::getUrl('view', ['record' => $this->getRecord()])), + ]; + } + public function infolist(Infolist $infolist): Infolist { return $infolist diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ViewBeneficiaryPersonalInformation.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ViewBeneficiaryPersonalInformation.php index f6c127a6..bce2558e 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ViewBeneficiaryPersonalInformation.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ViewBeneficiaryPersonalInformation.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\BeneficiaryResource\Pages; +use App\Actions\BackAction; use App\Enums\Diseases; use App\Enums\Ternary; use App\Filament\Organizations\Resources\BeneficiaryResource; @@ -37,6 +38,14 @@ public function getBreadcrumbs(): array ->getBreadcrumbs('view_personal_information'); } + protected function getHeaderActions(): array + { + return [ + BackAction::make() + ->url(BeneficiaryResource::getUrl('view', ['record' => $this->getRecord()])), + ]; + } + public function infolist(Infolist $infolist): Infolist { return $infolist diff --git a/app/Filament/Organizations/Resources/DocumentResource/Pages/ListDocuments.php b/app/Filament/Organizations/Resources/DocumentResource/Pages/ListDocuments.php index be2724ef..41e0a23d 100644 --- a/app/Filament/Organizations/Resources/DocumentResource/Pages/ListDocuments.php +++ b/app/Filament/Organizations/Resources/DocumentResource/Pages/ListDocuments.php @@ -4,8 +4,10 @@ namespace App\Filament\Organizations\Resources\DocumentResource\Pages; +use App\Actions\BackAction; use App\Concerns\HasParentResource; use App\Enums\DocumentType; +use App\Filament\Organizations\Resources\BeneficiaryResource; use App\Filament\Organizations\Resources\DocumentResource; use App\Models\Document; use App\Services\Breadcrumb\BeneficiaryBreadcrumb; @@ -45,6 +47,9 @@ public function getTitle(): string|Htmlable protected function getHeaderActions(): array { return [ + BackAction::make() + ->url(BeneficiaryResource::getUrl('view', ['record' => $this->parent])), + Actions\CreateAction::make() ->modalHeading(__('beneficiary.section.documents.title.add_modal')) ->label(__('beneficiary.section.documents.actions.add')) diff --git a/app/Filament/Organizations/Resources/DocumentResource/Pages/ViewDocument.php b/app/Filament/Organizations/Resources/DocumentResource/Pages/ViewDocument.php index a3dfe405..e04bbef0 100644 --- a/app/Filament/Organizations/Resources/DocumentResource/Pages/ViewDocument.php +++ b/app/Filament/Organizations/Resources/DocumentResource/Pages/ViewDocument.php @@ -4,7 +4,9 @@ namespace App\Filament\Organizations\Resources\DocumentResource\Pages; +use App\Actions\BackAction; use App\Concerns\HasParentResource; +use App\Filament\Organizations\Resources\BeneficiaryResource; use App\Filament\Organizations\Resources\DocumentResource; use App\Infolists\Components\DocumentPreview; use App\Infolists\Components\EnumEntry; @@ -39,6 +41,9 @@ public function getBreadcrumbs(): array protected function getHeaderActions(): array { return [ + BackAction::make() + ->url(BeneficiaryResource::getUrl('documents.index', ['parent' => $this->parent])), + DeleteAction::make() ->label(__('beneficiary.section.documents.actions.delete')) ->outlined() diff --git a/app/Filament/Organizations/Resources/InterventionPlanResource/Pages/ViewInterventionPlan.php b/app/Filament/Organizations/Resources/InterventionPlanResource/Pages/ViewInterventionPlan.php index 1bd9004b..43809314 100644 --- a/app/Filament/Organizations/Resources/InterventionPlanResource/Pages/ViewInterventionPlan.php +++ b/app/Filament/Organizations/Resources/InterventionPlanResource/Pages/ViewInterventionPlan.php @@ -4,7 +4,9 @@ namespace App\Filament\Organizations\Resources\InterventionPlanResource\Pages; +use App\Actions\BackAction; use App\Concerns\HasParentResource; +use App\Filament\Organizations\Resources\BeneficiaryResource; use App\Filament\Organizations\Resources\InterventionPlanResource; use App\Forms\Components\DatePicker; use App\Models\Beneficiary; @@ -41,6 +43,9 @@ public function getTitle(): string|Htmlable protected function getHeaderActions(): array { return [ + BackAction::make() + ->url(BeneficiaryResource::getUrl('view', ['record' => $this->parent])), + Actions\EditAction::make() ->label(__('intervention_plan.actions.edit_intervention_plan')) ->icon('heroicon-o-pencil') diff --git a/app/Filament/Organizations/Resources/InterventionServiceResource/Pages/EditCounselingSheet.php b/app/Filament/Organizations/Resources/InterventionServiceResource/Pages/EditCounselingSheet.php index b91184ef..74ccd408 100644 --- a/app/Filament/Organizations/Resources/InterventionServiceResource/Pages/EditCounselingSheet.php +++ b/app/Filament/Organizations/Resources/InterventionServiceResource/Pages/EditCounselingSheet.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\InterventionServiceResource\Pages; +use App\Actions\BackAction; use App\Enums\CounselingSheet; use App\Enums\ExtendedFrequency; use App\Enums\FamilyRelationship; @@ -62,9 +63,20 @@ public function getBreadcrumbs(): array ->getServiceBreadcrumb($this->getRecord()); } + protected function getHeaderActions(): array + { + return [ + BackAction::make() + ->url($this->getRedirectUrl()), + ]; + } + public function form(Form $form): Form { - $counselingSheet = $this->record->organizationService->serviceWithoutStatusCondition->counseling_sheet; + $counselingSheet = $this->record + ->organizationServiceWithoutStatusCondition + ->serviceWithoutStatusCondition + ->counseling_sheet; $schema = []; if (CounselingSheet::isValue($counselingSheet, CounselingSheet::LEGAL_ASSISTANCE)) { diff --git a/app/Filament/Organizations/Resources/InterventionServiceResource/Pages/EditInterventionService.php b/app/Filament/Organizations/Resources/InterventionServiceResource/Pages/EditInterventionService.php index 3aee1eec..ca3da853 100644 --- a/app/Filament/Organizations/Resources/InterventionServiceResource/Pages/EditInterventionService.php +++ b/app/Filament/Organizations/Resources/InterventionServiceResource/Pages/EditInterventionService.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\InterventionServiceResource\Pages; +use App\Actions\BackAction; use App\Concerns\HasParentResource; use App\Filament\Organizations\Resources\BeneficiaryResource; use App\Filament\Organizations\Resources\InterventionPlanResource; @@ -46,6 +47,9 @@ protected function getRedirectUrl(): ?string protected function getHeaderActions(): array { return [ + BackAction::make() + ->url($this->getRedirectUrl()), + Actions\DeleteAction::make() ->label(__('intervention_plan.actions.delete_service')) ->icon('heroicon-o-trash') diff --git a/app/Filament/Organizations/Resources/InterventionServiceResource/Pages/ViewInterventionService.php b/app/Filament/Organizations/Resources/InterventionServiceResource/Pages/ViewInterventionService.php index 68443290..1b633078 100644 --- a/app/Filament/Organizations/Resources/InterventionServiceResource/Pages/ViewInterventionService.php +++ b/app/Filament/Organizations/Resources/InterventionServiceResource/Pages/ViewInterventionService.php @@ -4,7 +4,9 @@ namespace App\Filament\Organizations\Resources\InterventionServiceResource\Pages; +use App\Actions\BackAction; use App\Concerns\HasParentResource; +use App\Filament\Organizations\Resources\BeneficiaryResource; use App\Filament\Organizations\Resources\InterventionServiceResource; use App\Services\Breadcrumb\InterventionPlanBreadcrumb; use Filament\Resources\Pages\ViewRecord; @@ -27,6 +29,19 @@ public function getTitle(): string|Htmlable return $this->getRecord()->organizationServiceWithoutStatusCondition?->serviceWithoutStatusCondition->name ?: ''; } + protected function getHeaderActions(): array + { + return [ + BackAction::make() + ->url( + BeneficiaryResource::getUrl('view_intervention_plan', [ + 'parent' => $this->parent->beneficiary, + 'record' => $this->parent, + ]) + ), + ]; + } + protected function getFooterWidgets(): array { return [ diff --git a/app/Filament/Organizations/Resources/InterventionServiceResource/Widgets/CounselingSheetWidget.php b/app/Filament/Organizations/Resources/InterventionServiceResource/Widgets/CounselingSheetWidget.php index 1a936ff2..3875bcdf 100644 --- a/app/Filament/Organizations/Resources/InterventionServiceResource/Widgets/CounselingSheetWidget.php +++ b/app/Filament/Organizations/Resources/InterventionServiceResource/Widgets/CounselingSheetWidget.php @@ -47,7 +47,11 @@ public static function canView(): bool protected function getInfoListSchema(): array { - $counselingSheet = $this->record->organizationService->serviceWithoutStatusCondition->counseling_sheet; + $counselingSheet = $this->record + ->organizationServiceWithoutStatusCondition + ->serviceWithoutStatusCondition + ->counseling_sheet; + if (blank($counselingSheet)) { return []; } diff --git a/app/Filament/Organizations/Resources/MonitoringResource/Pages/CreateMonitoring.php b/app/Filament/Organizations/Resources/MonitoringResource/Pages/CreateMonitoring.php index 08846b76..e2b9844b 100644 --- a/app/Filament/Organizations/Resources/MonitoringResource/Pages/CreateMonitoring.php +++ b/app/Filament/Organizations/Resources/MonitoringResource/Pages/CreateMonitoring.php @@ -4,9 +4,11 @@ namespace App\Filament\Organizations\Resources\MonitoringResource\Pages; +use App\Actions\BackAction; use App\Concerns\HasParentResource; use App\Concerns\PreventMultipleSubmit; use App\Concerns\PreventSubmitFormOnEnter; +use App\Filament\Organizations\Resources\BeneficiaryResource; use App\Filament\Organizations\Resources\MonitoringResource; use App\Models\Monitoring; use App\Models\Specialist; @@ -59,9 +61,12 @@ protected function getRedirectUrl(): string ]); } - protected function configureAction(Action $action): void + protected function getHeaderActions(): array { - $action->hidden(); + return [ + BackAction::make() + ->url(BeneficiaryResource::getUrl('monitorings.index', ['parent' => $this->parent])), + ]; } protected function afterFill(): void diff --git a/app/Filament/Organizations/Resources/MonitoringResource/Pages/ListMonitoring.php b/app/Filament/Organizations/Resources/MonitoringResource/Pages/ListMonitoring.php index 8ecdef77..6d6cef72 100644 --- a/app/Filament/Organizations/Resources/MonitoringResource/Pages/ListMonitoring.php +++ b/app/Filament/Organizations/Resources/MonitoringResource/Pages/ListMonitoring.php @@ -4,7 +4,9 @@ namespace App\Filament\Organizations\Resources\MonitoringResource\Pages; +use App\Actions\BackAction; use App\Concerns\HasParentResource; +use App\Filament\Organizations\Resources\BeneficiaryResource; use App\Filament\Organizations\Resources\MonitoringResource; use App\Models\Monitoring; use App\Services\Breadcrumb\BeneficiaryBreadcrumb; @@ -37,6 +39,9 @@ public function getTitle(): string|Htmlable protected function getHeaderActions(): array { return [ + BackAction::make() + ->url(BeneficiaryResource::getUrl('view', ['record' => $this->parent])), + Actions\Action::make('open_modal') ->label(__('monitoring.actions.create')) ->visible(fn () => $this->parent->monitoring->count()) diff --git a/app/Filament/Organizations/Resources/MonitoringResource/Pages/ViewMonitoring.php b/app/Filament/Organizations/Resources/MonitoringResource/Pages/ViewMonitoring.php index dc6a3e63..5dfe7fc9 100644 --- a/app/Filament/Organizations/Resources/MonitoringResource/Pages/ViewMonitoring.php +++ b/app/Filament/Organizations/Resources/MonitoringResource/Pages/ViewMonitoring.php @@ -4,7 +4,9 @@ namespace App\Filament\Organizations\Resources\MonitoringResource\Pages; +use App\Actions\BackAction; use App\Concerns\HasParentResource; +use App\Filament\Organizations\Resources\BeneficiaryResource; use App\Filament\Organizations\Resources\BeneficiaryResource\Pages\ViewBeneficiaryIdentity; use App\Filament\Organizations\Resources\MonitoringResource; use App\Infolists\Components\Actions\Edit; @@ -41,6 +43,9 @@ public function getTitle(): string|Htmlable protected function getHeaderActions(): array { return [ + BackAction::make() + ->url(BeneficiaryResource::getUrl('monitorings.index', ['parent' => $this->parent])), + Actions\DeleteAction::make() ->label(__('monitoring.actions.delete')) ->outlined() diff --git a/lang/ro/beneficiary.php b/lang/ro/beneficiary.php index 3bf079a9..9acd6f58 100644 --- a/lang/ro/beneficiary.php +++ b/lang/ro/beneficiary.php @@ -23,7 +23,7 @@ 'title' => 'Înregistrează caz nou', ], 'view' => [ - 'title' => '

#:id :name :badge

', + 'title' => '

:action #:id :name :badge

', ], 'identity' => [ 'title' => 'Date identitate', diff --git a/resources/views/vendor/filament-panels/components/header/index.blade.php b/resources/views/vendor/filament-panels/components/header/index.blade.php new file mode 100644 index 00000000..c997faba --- /dev/null +++ b/resources/views/vendor/filament-panels/components/header/index.blade.php @@ -0,0 +1,60 @@ +@php use App\Actions\BackAction; @endphp +@props([ + 'actions' => [], + 'breadcrumbs' => [], + 'heading', + 'subheading' => null, +]) + +@php + $backAction = null; + foreach ($actions as $key => $action) + { + if ($action instanceof BackAction){ + $backAction = $action; + unset($actions[$key]); + } + } +@endphp +
class(['fi-header flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between']) }} +> +
+ @if ($breadcrumbs) +
+ +
$breadcrumbs, + ]) + > + {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\View\PanelsRenderHook::PAGE_HEADER_ACTIONS_BEFORE, scopes: $this->getRenderHookScopes()) }} + + @if ($actions) + + @endif + + {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\View\PanelsRenderHook::PAGE_HEADER_ACTIONS_AFTER, scopes: $this->getRenderHookScopes()) }} +
+