Skip to content

Commit

Permalink
Back action
Browse files Browse the repository at this point in the history
  • Loading branch information
alexPopaCode4 committed Dec 20, 2024
1 parent 43ca6d0 commit 3e95da2
Show file tree
Hide file tree
Showing 36 changed files with 313 additions and 26 deletions.
24 changes: 24 additions & 0 deletions app/Actions/BackAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace App\Actions;

use Filament\Actions\Action;

class BackAction extends Action
{
protected function setUp(): void
{
parent::setUp();

$this->icon('heroicon-o-chevron-left');
$this->hiddenLabel();
$this->link();
}

public function getName(): ?string
{
return 'back_action';
}
}
18 changes: 18 additions & 0 deletions app/Concerns/HasBackAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace App\Concerns;

use App\Actions\BackAction;

trait HasBackAction
{
protected function getHeaderActions(): array
{
return [
BackAction::make()
->url($this->getRedirectUrl()),
];
}
}
2 changes: 2 additions & 0 deletions app/Concerns/RedirectToCloseFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

trait RedirectToCloseFile
{
use HasBackAction;

protected function getRedirectUrl(): string
{
return self::$resource::getUrl('view_close_file', [
Expand Down
2 changes: 2 additions & 0 deletions app/Concerns/RedirectToDetailedEvaluation.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

trait RedirectToDetailedEvaluation
{
use HasBackAction;

protected function getRedirectUrl(): string
{
return self::$resource::getUrl('view_detailed_evaluation', [
Expand Down
2 changes: 2 additions & 0 deletions app/Concerns/RedirectToIdentity.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

trait RedirectToIdentity
{
use HasBackAction;

protected function getRedirectUrl(): string
{
return static::getResource()::getUrl('view_identity', [
Expand Down
2 changes: 2 additions & 0 deletions app/Concerns/RedirectToInitialEvaluation.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

trait RedirectToInitialEvaluation
{
use HasBackAction;

protected function getRedirectUrl(): string
{
return self::$resource::getUrl('view_initial_evaluation', [
Expand Down
2 changes: 2 additions & 0 deletions app/Concerns/RedirectToMonitoring.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

trait RedirectToMonitoring
{
use HasBackAction;

protected function getRedirectUrl(): ?string
{
return self::getParentResource()::getUrl('monitorings.view', [
Expand Down
2 changes: 2 additions & 0 deletions app/Concerns/RedirectToPersonalInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

trait RedirectToPersonalInformation
{
use HasBackAction;

protected function getRedirectUrl(): string
{
return static::getResource()::getUrl('view_personal_information', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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([
Expand Down
Loading

0 comments on commit 3e95da2

Please sign in to comment.