From 3e95da2dbb444b395d3cf5f0cb1c5a5cbc443927 Mon Sep 17 00:00:00 2001 From: Alex Popa Date: Fri, 20 Dec 2024 03:35:12 +0200 Subject: [PATCH 1/4] 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()) }} +
+
From 0fa91cc65b64b955c7200b036d717fc63e412153 Mon Sep 17 00:00:00 2001 From: Alex Popa Date: Fri, 20 Dec 2024 13:47:37 +0200 Subject: [PATCH 2/4] Monthly plan --- .../Pages/CreateMonthlyPlan.php | 15 ++++++++++++++- .../Pages/EditMonthlyPlanDetails.php | 9 +++++++++ .../EditMonthlyPlanServicesAndInterventions.php | 9 +++++++++ .../MonthlyPlanResource/Pages/ViewMonthlyPlan.php | 7 +++++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/app/Filament/Organizations/Resources/MonthlyPlanResource/Pages/CreateMonthlyPlan.php b/app/Filament/Organizations/Resources/MonthlyPlanResource/Pages/CreateMonthlyPlan.php index a751d5c2..42e5b4cd 100644 --- a/app/Filament/Organizations/Resources/MonthlyPlanResource/Pages/CreateMonthlyPlan.php +++ b/app/Filament/Organizations/Resources/MonthlyPlanResource/Pages/CreateMonthlyPlan.php @@ -4,9 +4,11 @@ namespace App\Filament\Organizations\Resources\MonthlyPlanResource\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\InterventionPlanResource; use App\Filament\Organizations\Resources\MonthlyPlanResource; use App\Services\Breadcrumb\InterventionPlanBreadcrumb; @@ -32,7 +34,7 @@ class CreateMonthlyPlan extends CreateRecord public function getBreadcrumbs(): array { return InterventionPlanBreadcrumb::make($this->parent) - ->getCreateMonthlyPlan($this->getRecord()); + ->getCreateMonthlyPlan(); } public function getTitle(): string|Htmlable @@ -48,6 +50,17 @@ protected function getRedirectUrl(): string ]); } + public function getHeaderActions(): array + { + return [ + BackAction::make() + ->url(BeneficiaryResource::getUrl('view_intervention_plan', [ + 'parent' => $this->parent->beneficiary, + 'record' => $this->parent, + ])), + ]; + } + protected function afterFill(): void { $copyLastPlan = (bool) request('copyLastPlan'); diff --git a/app/Filament/Organizations/Resources/MonthlyPlanResource/Pages/EditMonthlyPlanDetails.php b/app/Filament/Organizations/Resources/MonthlyPlanResource/Pages/EditMonthlyPlanDetails.php index 8e2196d5..08bb85fe 100644 --- a/app/Filament/Organizations/Resources/MonthlyPlanResource/Pages/EditMonthlyPlanDetails.php +++ b/app/Filament/Organizations/Resources/MonthlyPlanResource/Pages/EditMonthlyPlanDetails.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\MonthlyPlanResource\Pages; +use App\Actions\BackAction; use App\Concerns\HasParentResource; use App\Filament\Organizations\Resources\InterventionPlanResource; use App\Filament\Organizations\Resources\MonthlyPlanResource; @@ -48,6 +49,14 @@ protected function getTabSlug(): string return Str::slug(__('intervention_plan.headings.monthly_plan_details')); } + public function getHeaderActions(): array + { + return [ + BackAction::make() + ->url($this->getRedirectUrl()), + ]; + } + public function form(Form $form): Form { return $form->schema(self::getSchema($this->parent->beneficiary)); diff --git a/app/Filament/Organizations/Resources/MonthlyPlanResource/Pages/EditMonthlyPlanServicesAndInterventions.php b/app/Filament/Organizations/Resources/MonthlyPlanResource/Pages/EditMonthlyPlanServicesAndInterventions.php index 86008bbd..027152c4 100644 --- a/app/Filament/Organizations/Resources/MonthlyPlanResource/Pages/EditMonthlyPlanServicesAndInterventions.php +++ b/app/Filament/Organizations/Resources/MonthlyPlanResource/Pages/EditMonthlyPlanServicesAndInterventions.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\MonthlyPlanResource\Pages; +use App\Actions\BackAction; use App\Concerns\HasParentResource; use App\Filament\Organizations\Resources\InterventionPlanResource; use App\Filament\Organizations\Resources\MonthlyPlanResource; @@ -58,6 +59,14 @@ protected function getTabSlug(): string return Str::slug(__('intervention_plan.headings.services_and_interventions')); } + public function getHeaderActions(): array + { + return [ + BackAction::make() + ->url($this->getRedirectUrl()), + ]; + } + public function form(Form $form): Form { return $form->schema([ diff --git a/app/Filament/Organizations/Resources/MonthlyPlanResource/Pages/ViewMonthlyPlan.php b/app/Filament/Organizations/Resources/MonthlyPlanResource/Pages/ViewMonthlyPlan.php index 7f0759e0..b3eeb9bd 100644 --- a/app/Filament/Organizations/Resources/MonthlyPlanResource/Pages/ViewMonthlyPlan.php +++ b/app/Filament/Organizations/Resources/MonthlyPlanResource/Pages/ViewMonthlyPlan.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\MonthlyPlanResource\Pages; +use App\Actions\BackAction; use App\Concerns\HasParentResource; use App\Filament\Organizations\Resources\BeneficiaryResource; use App\Filament\Organizations\Resources\InterventionPlanResource; @@ -44,6 +45,12 @@ public function getTitle(): string|Htmlable public function getHeaderActions(): array { return [ + BackAction::make() + ->url(BeneficiaryResource::getUrl('view_intervention_plan', [ + 'parent' => $this->parent->beneficiary, + 'record' => $this->parent, + ])), + DeleteAction::make() ->label(__('intervention_plan.actions.delete_monthly_plan')) ->icon('heroicon-o-trash') From 35c3787398b84dc1b2462a6475d4241774e87fb1 Mon Sep 17 00:00:00 2001 From: Alex Popa Date: Fri, 20 Dec 2024 13:55:13 +0200 Subject: [PATCH 3/4] Staff and service --- .../Resources/ServiceResource/Pages/CreateService.php | 9 +++++++++ .../Resources/ServiceResource/Pages/EditService.php | 4 ++++ .../Resources/ServiceResource/Pages/ViewService.php | 4 ++++ .../Resources/UserResource/Pages/CreateUser.php | 9 +++++++++ .../Resources/UserResource/Pages/EditUser.php | 9 +++++++++ .../Resources/UserResource/Pages/ViewUser.php | 9 +++++---- 6 files changed, 40 insertions(+), 4 deletions(-) diff --git a/app/Filament/Organizations/Resources/ServiceResource/Pages/CreateService.php b/app/Filament/Organizations/Resources/ServiceResource/Pages/CreateService.php index 357e7d10..a2fa2df3 100644 --- a/app/Filament/Organizations/Resources/ServiceResource/Pages/CreateService.php +++ b/app/Filament/Organizations/Resources/ServiceResource/Pages/CreateService.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\ServiceResource\Pages; +use App\Actions\BackAction; use App\Concerns\PreventMultipleSubmit; use App\Concerns\PreventSubmitFormOnEnter; use App\Filament\Organizations\Resources\ServiceResource; @@ -32,6 +33,14 @@ public function getBreadcrumbs(): array ]; } + protected function getHeaderActions(): array + { + return [ + BackAction::make() + ->url(ServiceResource::getUrl()), + ]; + } + protected function mutateFormDataBeforeCreate(array $data): array { $this->data['interventions'] = self::$resource::processInterventionsBeforeSave($this->data['interventions']); diff --git a/app/Filament/Organizations/Resources/ServiceResource/Pages/EditService.php b/app/Filament/Organizations/Resources/ServiceResource/Pages/EditService.php index ec401864..4337d55d 100644 --- a/app/Filament/Organizations/Resources/ServiceResource/Pages/EditService.php +++ b/app/Filament/Organizations/Resources/ServiceResource/Pages/EditService.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\ServiceResource\Pages; +use App\Actions\BackAction; use App\Filament\Organizations\Resources\ServiceResource; use App\Filament\Organizations\Resources\ServiceResource\Actions\ChangeStatusAction; use Filament\Actions; @@ -35,6 +36,9 @@ public function getBreadcrumbs(): array protected function getHeaderActions(): array { return [ + BackAction::make() + ->url($this->getRedirectUrl()), + ChangeStatusAction::make() ->disabled(fn () => ! $this->getRecord()->service), diff --git a/app/Filament/Organizations/Resources/ServiceResource/Pages/ViewService.php b/app/Filament/Organizations/Resources/ServiceResource/Pages/ViewService.php index b712cb88..0977e0d1 100644 --- a/app/Filament/Organizations/Resources/ServiceResource/Pages/ViewService.php +++ b/app/Filament/Organizations/Resources/ServiceResource/Pages/ViewService.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\ServiceResource\Pages; +use App\Actions\BackAction; use App\Enums\CounselingSheet; use App\Filament\Organizations\Resources\InterventionServiceResource\Pages\EditCounselingSheet; use App\Filament\Organizations\Resources\ServiceResource; @@ -36,6 +37,9 @@ public function getBreadcrumbs(): array protected function getHeaderActions(): array { return [ + BackAction::make() + ->url(ServiceResource::getUrl()), + EditAction::make() ->label(__('service.actions.change_service')), ]; diff --git a/app/Filament/Organizations/Resources/UserResource/Pages/CreateUser.php b/app/Filament/Organizations/Resources/UserResource/Pages/CreateUser.php index 366ce957..d37979d7 100644 --- a/app/Filament/Organizations/Resources/UserResource/Pages/CreateUser.php +++ b/app/Filament/Organizations/Resources/UserResource/Pages/CreateUser.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\UserResource\Pages; +use App\Actions\BackAction; use App\Concerns\PreventMultipleSubmit; use App\Concerns\PreventSubmitFormOnEnter; use App\Filament\Organizations\Resources\UserResource; @@ -27,6 +28,14 @@ public function getTitle(): string|Htmlable return __('user.titles.create_specialist'); } + protected function getHeaderActions(): array + { + return [ + BackAction::make() + ->url(UserResource::getUrl()), + ]; + } + protected function afterSave(): void { /** @var User $user */ diff --git a/app/Filament/Organizations/Resources/UserResource/Pages/EditUser.php b/app/Filament/Organizations/Resources/UserResource/Pages/EditUser.php index fcf433ce..45b6ee92 100644 --- a/app/Filament/Organizations/Resources/UserResource/Pages/EditUser.php +++ b/app/Filament/Organizations/Resources/UserResource/Pages/EditUser.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\UserResource\Pages; +use App\Actions\BackAction; use App\Filament\Organizations\Resources\UserResource; use Filament\Resources\Pages\EditRecord; use Illuminate\Contracts\Support\Htmlable; @@ -29,4 +30,12 @@ protected function getRedirectUrl(): string { return self::$resource::getUrl('view', ['record' => $this->record->id]); } + + protected function getHeaderActions(): array + { + return [ + BackAction::make() + ->url($this->getRedirectUrl()), + ]; + } } diff --git a/app/Filament/Organizations/Resources/UserResource/Pages/ViewUser.php b/app/Filament/Organizations/Resources/UserResource/Pages/ViewUser.php index 9da19e89..84521faf 100644 --- a/app/Filament/Organizations/Resources/UserResource/Pages/ViewUser.php +++ b/app/Filament/Organizations/Resources/UserResource/Pages/ViewUser.php @@ -4,6 +4,7 @@ namespace App\Filament\Organizations\Resources\UserResource\Pages; +use App\Actions\BackAction; use App\Enums\AdminPermission; use App\Enums\CasePermission; use App\Enums\Ternary; @@ -20,7 +21,6 @@ use Filament\Infolists\Components\TextEntry; use Filament\Infolists\Infolist; use Filament\Resources\Pages\ViewRecord; -use Illuminate\Support\Str; class ViewUser extends ViewRecord { @@ -66,9 +66,7 @@ public function infolist(Infolist $infolist): Infolist TextEntry::make('can_be_case_manager') ->label(__('user.labels.can_be_case_manager')) - ->state(fn (User $record) => Ternary::tryFrom((int)$record->canBeCaseManager())), - - + ->state(fn (User $record) => Ternary::tryFrom((int) $record->canBeCaseManager())), Group::make() ->columnSpanFull() @@ -108,6 +106,9 @@ public function infolist(Infolist $infolist): Infolist protected function getHeaderActions(): array { return [ + BackAction::make() + ->url(UserResource::getUrl()), + DeactivateUserAction::make(), ResetPasswordAction::make(), From 64fe2258c2508c77b6b7d304c5031e67196b574b Mon Sep 17 00:00:00 2001 From: Alex Popa Date: Fri, 20 Dec 2024 15:25:36 +0200 Subject: [PATCH 4/4] SuperAdmin --- .../Resources/BenefitResource/Pages/CreateBenefit.php | 9 +++++++++ .../Resources/BenefitResource/Pages/EditBenefit.php | 4 ++++ .../Resources/BenefitResource/Pages/ViewBenefit.php | 6 +++++- .../InstitutionResource/Pages/EditInstitutionCenters.php | 9 +++++++++ .../InstitutionResource/Pages/EditInstitutionDetails.php | 9 +++++++++ .../InstitutionResource/Pages/ViewInstitution.php | 4 ++++ .../Resources/ResultResource/Pages/CreateResult.php | 9 +++++++++ .../Admin/Resources/ResultResource/Pages/EditResult.php | 4 ++++ .../Admin/Resources/RoleResource/Pages/CreateRole.php | 9 +++++++++ .../Admin/Resources/RoleResource/Pages/EditRole.php | 4 ++++ .../Admin/Resources/RoleResource/Pages/ViewRole.php | 6 +++++- .../Resources/ServiceResource/Pages/CreateService.php | 9 +++++++++ .../Resources/ServiceResource/Pages/EditService.php | 4 ++++ .../Resources/ServiceResource/Pages/ViewService.php | 4 ++++ .../Pages/EditUserInstitution.php | 9 +++++++++ .../Pages/ViewUserInstitution.php | 4 ++++ 16 files changed, 101 insertions(+), 2 deletions(-) diff --git a/app/Filament/Admin/Resources/BenefitResource/Pages/CreateBenefit.php b/app/Filament/Admin/Resources/BenefitResource/Pages/CreateBenefit.php index 3dd2014b..e28c6563 100644 --- a/app/Filament/Admin/Resources/BenefitResource/Pages/CreateBenefit.php +++ b/app/Filament/Admin/Resources/BenefitResource/Pages/CreateBenefit.php @@ -4,6 +4,7 @@ namespace App\Filament\Admin\Resources\BenefitResource\Pages; +use App\Actions\BackAction; use App\Concerns\PreventMultipleSubmit; use App\Concerns\PreventSubmitFormOnEnter; use App\Filament\Admin\Resources\BenefitResource; @@ -36,4 +37,12 @@ protected function getRedirectUrl(): string { return self::$resource::getUrl('view', ['record' => $this->getRecord()]); } + + protected function getHeaderActions(): array + { + return [ + BackAction::make() + ->url(BenefitResource::getUrl()), + ]; + } } diff --git a/app/Filament/Admin/Resources/BenefitResource/Pages/EditBenefit.php b/app/Filament/Admin/Resources/BenefitResource/Pages/EditBenefit.php index eaa608d4..93ac601d 100644 --- a/app/Filament/Admin/Resources/BenefitResource/Pages/EditBenefit.php +++ b/app/Filament/Admin/Resources/BenefitResource/Pages/EditBenefit.php @@ -4,6 +4,7 @@ namespace App\Filament\Admin\Resources\BenefitResource\Pages; +use App\Actions\BackAction; use App\Filament\Admin\Actions\ChangeNomenclatureStatusAction; use App\Filament\Admin\Resources\BenefitResource; use Filament\Actions; @@ -35,6 +36,9 @@ protected function getRedirectUrl(): string protected function getHeaderActions(): array { return [ + BackAction::make() + ->url($this->getRedirectUrl()), + ChangeNomenclatureStatusAction::make(), Actions\DeleteAction::make() diff --git a/app/Filament/Admin/Resources/BenefitResource/Pages/ViewBenefit.php b/app/Filament/Admin/Resources/BenefitResource/Pages/ViewBenefit.php index dc71fe0f..a4d4aa78 100644 --- a/app/Filament/Admin/Resources/BenefitResource/Pages/ViewBenefit.php +++ b/app/Filament/Admin/Resources/BenefitResource/Pages/ViewBenefit.php @@ -4,6 +4,7 @@ namespace App\Filament\Admin\Resources\BenefitResource\Pages; +use App\Actions\BackAction; use App\Filament\Admin\Resources\BenefitResource; use App\Filament\Admin\Resources\BenefitResource\Widgets\BenefitTypesWidget; use Filament\Actions\EditAction; @@ -20,9 +21,12 @@ public function getFooterWidgetsColumns(): int|string|array return 1; } - protected function getActions(): array + protected function getHeaderActions(): array { return [ + BackAction::make() + ->url(BenefitResource::getUrl()), + EditAction::make() ->label(__('nomenclature.actions.edit_benefit')), ]; diff --git a/app/Filament/Admin/Resources/InstitutionResource/Pages/EditInstitutionCenters.php b/app/Filament/Admin/Resources/InstitutionResource/Pages/EditInstitutionCenters.php index 82a37896..fd321705 100644 --- a/app/Filament/Admin/Resources/InstitutionResource/Pages/EditInstitutionCenters.php +++ b/app/Filament/Admin/Resources/InstitutionResource/Pages/EditInstitutionCenters.php @@ -4,6 +4,7 @@ namespace App\Filament\Admin\Resources\InstitutionResource\Pages; +use App\Actions\BackAction; use App\Filament\Admin\Resources\InstitutionResource; use App\Forms\Components\Repeater; use App\Models\Organization; @@ -38,6 +39,14 @@ public function getTitle(): string|Htmlable return $this->getRecord()->name; } + public function getHeaderActions(): array + { + return [ + BackAction::make() + ->url($this->getRedirectUrl()), + ]; + } + public function form(Form $form): Form { return $form->schema(self::getSchema()); diff --git a/app/Filament/Admin/Resources/InstitutionResource/Pages/EditInstitutionDetails.php b/app/Filament/Admin/Resources/InstitutionResource/Pages/EditInstitutionDetails.php index 240fe4fb..9b75b22e 100644 --- a/app/Filament/Admin/Resources/InstitutionResource/Pages/EditInstitutionDetails.php +++ b/app/Filament/Admin/Resources/InstitutionResource/Pages/EditInstitutionDetails.php @@ -4,6 +4,7 @@ namespace App\Filament\Admin\Resources\InstitutionResource\Pages; +use App\Actions\BackAction; use App\Enums\AreaType; use App\Enums\OrganizationType; use App\Filament\Admin\Resources\InstitutionResource; @@ -44,6 +45,14 @@ public function form(Form $form): Form return $form->schema(self::getSchema()); } + public function getHeaderActions(): array + { + return [ + BackAction::make() + ->url($this->getRedirectUrl()), + ]; + } + public static function getSchema(): array { return [ diff --git a/app/Filament/Admin/Resources/InstitutionResource/Pages/ViewInstitution.php b/app/Filament/Admin/Resources/InstitutionResource/Pages/ViewInstitution.php index 96efe681..95cb15e0 100644 --- a/app/Filament/Admin/Resources/InstitutionResource/Pages/ViewInstitution.php +++ b/app/Filament/Admin/Resources/InstitutionResource/Pages/ViewInstitution.php @@ -4,6 +4,7 @@ namespace App\Filament\Admin\Resources\InstitutionResource\Pages; +use App\Actions\BackAction; use App\Filament\Admin\Resources\InstitutionResource; use App\Filament\Admin\Resources\InstitutionResource\Actions\ActivateInstitution; use App\Filament\Admin\Resources\InstitutionResource\Actions\InactivateInstitution; @@ -36,6 +37,9 @@ public function getTitle(): string|Htmlable protected function getActions(): array { return [ + BackAction::make() + ->url(InstitutionResource::getUrl()), + ActivateInstitution::make(), InactivateInstitution::make(), diff --git a/app/Filament/Admin/Resources/ResultResource/Pages/CreateResult.php b/app/Filament/Admin/Resources/ResultResource/Pages/CreateResult.php index c4ff6e0f..35359586 100644 --- a/app/Filament/Admin/Resources/ResultResource/Pages/CreateResult.php +++ b/app/Filament/Admin/Resources/ResultResource/Pages/CreateResult.php @@ -4,6 +4,7 @@ namespace App\Filament\Admin\Resources\ResultResource\Pages; +use App\Actions\BackAction; use App\Concerns\PreventMultipleSubmit; use App\Concerns\PreventSubmitFormOnEnter; use App\Filament\Admin\Resources\ResultResource; @@ -36,4 +37,12 @@ protected function getRedirectUrl(): string { return self::$resource::getUrl(); } + + public function getHeaderActions(): array + { + return [ + BackAction::make() + ->url(ResultResource::getUrl()), + ]; + } } diff --git a/app/Filament/Admin/Resources/ResultResource/Pages/EditResult.php b/app/Filament/Admin/Resources/ResultResource/Pages/EditResult.php index 6470b099..86b4ecd4 100644 --- a/app/Filament/Admin/Resources/ResultResource/Pages/EditResult.php +++ b/app/Filament/Admin/Resources/ResultResource/Pages/EditResult.php @@ -4,6 +4,7 @@ namespace App\Filament\Admin\Resources\ResultResource\Pages; +use App\Actions\BackAction; use App\Filament\Admin\Actions\ChangeNomenclatureStatusAction; use App\Filament\Admin\Resources\ResultResource; use Filament\Actions; @@ -30,6 +31,9 @@ public function getTitle(): string|Htmlable protected function getHeaderActions(): array { return [ + BackAction::make() + ->url(ResultResource::getUrl()), + ChangeNomenclatureStatusAction::make(), Actions\DeleteAction::make() diff --git a/app/Filament/Admin/Resources/RoleResource/Pages/CreateRole.php b/app/Filament/Admin/Resources/RoleResource/Pages/CreateRole.php index 9f790f76..51cf3227 100644 --- a/app/Filament/Admin/Resources/RoleResource/Pages/CreateRole.php +++ b/app/Filament/Admin/Resources/RoleResource/Pages/CreateRole.php @@ -4,6 +4,7 @@ namespace App\Filament\Admin\Resources\RoleResource\Pages; +use App\Actions\BackAction; use App\Concerns\PreventMultipleSubmit; use App\Concerns\PreventSubmitFormOnEnter; use App\Filament\Admin\Resources\RoleResource; @@ -31,4 +32,12 @@ public function getBreadcrumbs(): array RoleResource::getUrl('create') => __('nomenclature.actions.add_role'), ]; } + + protected function getHeaderActions(): array + { + return [ + BackAction::make() + ->url(RoleResource::getUrl()), + ]; + } } diff --git a/app/Filament/Admin/Resources/RoleResource/Pages/EditRole.php b/app/Filament/Admin/Resources/RoleResource/Pages/EditRole.php index 2990f948..5ed88bae 100644 --- a/app/Filament/Admin/Resources/RoleResource/Pages/EditRole.php +++ b/app/Filament/Admin/Resources/RoleResource/Pages/EditRole.php @@ -4,6 +4,7 @@ namespace App\Filament\Admin\Resources\RoleResource\Pages; +use App\Actions\BackAction; use App\Filament\Admin\Actions\ChangeNomenclatureStatusAction; use App\Filament\Admin\Resources\RoleResource; use Filament\Actions\DeleteAction; @@ -35,6 +36,9 @@ protected function getRedirectUrl(): ?string protected function getHeaderActions(): array { return [ + BackAction::make() + ->url($this->getRedirectUrl()), + ChangeNomenclatureStatusAction::make(), DeleteAction::make() diff --git a/app/Filament/Admin/Resources/RoleResource/Pages/ViewRole.php b/app/Filament/Admin/Resources/RoleResource/Pages/ViewRole.php index 73fbdaab..496a9449 100644 --- a/app/Filament/Admin/Resources/RoleResource/Pages/ViewRole.php +++ b/app/Filament/Admin/Resources/RoleResource/Pages/ViewRole.php @@ -4,6 +4,7 @@ namespace App\Filament\Admin\Resources\RoleResource\Pages; +use App\Actions\BackAction; use App\Filament\Admin\Resources\RoleResource; use Filament\Actions; use Filament\Infolists\Components\Section; @@ -29,9 +30,12 @@ public function getBreadcrumbs(): array ]; } - protected function getActions(): array + protected function getHeaderActions(): array { return [ + BackAction::make() + ->url(RoleResource::getUrl()), + Actions\EditAction::make() ->label(__('nomenclature.actions.edit_role')), ]; diff --git a/app/Filament/Admin/Resources/ServiceResource/Pages/CreateService.php b/app/Filament/Admin/Resources/ServiceResource/Pages/CreateService.php index 666c425b..96e4e6f7 100644 --- a/app/Filament/Admin/Resources/ServiceResource/Pages/CreateService.php +++ b/app/Filament/Admin/Resources/ServiceResource/Pages/CreateService.php @@ -4,6 +4,7 @@ namespace App\Filament\Admin\Resources\ServiceResource\Pages; +use App\Actions\BackAction; use App\Concerns\PreventMultipleSubmit; use App\Concerns\PreventSubmitFormOnEnter; use App\Filament\Admin\Resources\ServiceResource; @@ -31,4 +32,12 @@ public function getBreadcrumbs(): array self::$resource::getUrl('create') => __('nomenclature.actions.add_service'), ]; } + + public function getHeaderActions(): array + { + return [ + BackAction::make() + ->url(ServiceResource::getUrl()), + ]; + } } diff --git a/app/Filament/Admin/Resources/ServiceResource/Pages/EditService.php b/app/Filament/Admin/Resources/ServiceResource/Pages/EditService.php index 26b236d6..d9b4c302 100644 --- a/app/Filament/Admin/Resources/ServiceResource/Pages/EditService.php +++ b/app/Filament/Admin/Resources/ServiceResource/Pages/EditService.php @@ -4,6 +4,7 @@ namespace App\Filament\Admin\Resources\ServiceResource\Pages; +use App\Actions\BackAction; use App\Filament\Admin\Actions\ChangeNomenclatureStatusAction; use App\Filament\Admin\Resources\ServiceResource; use Filament\Actions\DeleteAction; @@ -35,6 +36,9 @@ public function getTitle(): string|Htmlable protected function getActions(): array { return [ + BackAction::make() + ->url($this->getRedirectUrl()), + ChangeNomenclatureStatusAction::make() ->relationship('organizationServices'), diff --git a/app/Filament/Admin/Resources/ServiceResource/Pages/ViewService.php b/app/Filament/Admin/Resources/ServiceResource/Pages/ViewService.php index 4ef8f776..6faeabbf 100644 --- a/app/Filament/Admin/Resources/ServiceResource/Pages/ViewService.php +++ b/app/Filament/Admin/Resources/ServiceResource/Pages/ViewService.php @@ -4,6 +4,7 @@ namespace App\Filament\Admin\Resources\ServiceResource\Pages; +use App\Actions\BackAction; use App\Enums\CounselingSheet; use App\Filament\Admin\Resources\ServiceResource; use App\Filament\Admin\Resources\ServiceResource\Widgets\InterventionsWidget; @@ -37,6 +38,9 @@ public function getTitle(): string|Htmlable protected function getActions(): array { return [ + BackAction::make() + ->url(ServiceResource::getUrl()), + Actions\EditAction::make() ->label(__('nomenclature.actions.edit_service')), ]; diff --git a/app/Filament/Admin/Resources/UserInstitutionResource/Pages/EditUserInstitution.php b/app/Filament/Admin/Resources/UserInstitutionResource/Pages/EditUserInstitution.php index acc3e617..f319efcb 100644 --- a/app/Filament/Admin/Resources/UserInstitutionResource/Pages/EditUserInstitution.php +++ b/app/Filament/Admin/Resources/UserInstitutionResource/Pages/EditUserInstitution.php @@ -4,6 +4,7 @@ namespace App\Filament\Admin\Resources\UserInstitutionResource\Pages; +use App\Actions\BackAction; use App\Concerns\HasParentResource; use App\Concerns\PreventSubmitFormOnEnter; use App\Filament\Admin\Resources\InstitutionResource; @@ -46,6 +47,14 @@ public function getTitle(): string|Htmlable return $this->getRecord()->full_name; } + public function getHeaderActions(): array + { + return [ + BackAction::make() + ->url($this->getRedirectUrl()), + ]; + } + public function form(Form $form): Form { return $form->schema([ diff --git a/app/Filament/Admin/Resources/UserInstitutionResource/Pages/ViewUserInstitution.php b/app/Filament/Admin/Resources/UserInstitutionResource/Pages/ViewUserInstitution.php index ee27acec..8b4fd1a6 100644 --- a/app/Filament/Admin/Resources/UserInstitutionResource/Pages/ViewUserInstitution.php +++ b/app/Filament/Admin/Resources/UserInstitutionResource/Pages/ViewUserInstitution.php @@ -4,6 +4,7 @@ namespace App\Filament\Admin\Resources\UserInstitutionResource\Pages; +use App\Actions\BackAction; use App\Concerns\HasParentResource; use App\Filament\Admin\Resources\InstitutionResource; use App\Filament\Admin\Resources\UserInstitutionResource; @@ -52,6 +53,9 @@ public function getTitle(): string|Htmlable protected function getHeaderActions(): array { return [ + BackAction::make() + ->url($this->getRedirectUrl()), + ActivateUserAction::make(), DeactivateUserAction::make(),