From 89c6e17c4d8350b139c38d0c9ff41a7fd0b79a4e Mon Sep 17 00:00:00 2001 From: Alex Popa Date: Mon, 30 Dec 2024 17:07:00 +0200 Subject: [PATCH] Table EditAction --- .../RelationManagers/UsersRelationManager.php | 3 +- .../Admin/Resources/ResultResource.php | 5 +-- app/Filament/Admin/Resources/RoleResource.php | 5 +-- app/Filament/Admin/Resources/UserResource.php | 3 +- .../BeneficiaryInterventionResource.php | 3 +- .../Widgets/ListSpecialistsWidget.php | 5 +-- .../Widgets/BenefitsWidget.php | 1 - .../Widgets/ResultsWidget.php | 1 - .../Resources/InterventionServiceResource.php | 37 ------------------- .../Widgets/ServiceDescriptionWidget.php | 8 +--- .../Resources/MonitoringResource.php | 26 ------------- app/Tables/Actions/EditAction.php | 8 ++++ lang/ro/beneficiary.php | 1 - lang/ro/intervention_plan.php | 1 - lang/ro/nomenclature.php | 1 - 15 files changed, 22 insertions(+), 86 deletions(-) diff --git a/app/Filament/Admin/Resources/OrganizationResource/RelationManagers/UsersRelationManager.php b/app/Filament/Admin/Resources/OrganizationResource/RelationManagers/UsersRelationManager.php index 56b3823b..355854e4 100644 --- a/app/Filament/Admin/Resources/OrganizationResource/RelationManagers/UsersRelationManager.php +++ b/app/Filament/Admin/Resources/OrganizationResource/RelationManagers/UsersRelationManager.php @@ -4,6 +4,7 @@ namespace App\Filament\Admin\Resources\OrganizationResource\RelationManagers; +use App\Tables\Actions\EditAction; use Filament\Forms; use Filament\Forms\Form; use Filament\Resources\RelationManagers\RelationManager; @@ -52,7 +53,7 @@ public function table(Table $table): Table Tables\Actions\CreateAction::make(), ]) ->actions([ - Tables\Actions\EditAction::make(), + EditAction::make(), Tables\Actions\DeleteAction::make(), ]) ->bulkActions([ diff --git a/app/Filament/Admin/Resources/ResultResource.php b/app/Filament/Admin/Resources/ResultResource.php index d7961773..a501dce3 100644 --- a/app/Filament/Admin/Resources/ResultResource.php +++ b/app/Filament/Admin/Resources/ResultResource.php @@ -7,12 +7,12 @@ use App\Enums\GeneralStatus; use App\Filament\Admin\Resources\ResultResource\Pages; use App\Models\Result; +use App\Tables\Actions\EditAction; use App\Tables\Filters\SelectFilter; use Filament\Forms\Components\Section; use Filament\Forms\Components\TextInput; use Filament\Forms\Form; use Filament\Resources\Resource; -use Filament\Tables; use Filament\Tables\Actions\CreateAction; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Table; @@ -66,8 +66,7 @@ public static function table(Table $table): Table ->options(GeneralStatus::options()), ]) ->actions([ - Tables\Actions\EditAction::make() - ->label(__('general.action.change')), + EditAction::make(), ]) ->emptyStateHeading(__('nomenclature.headings.empty_state_results_table')) ->emptyStateDescription(null) diff --git a/app/Filament/Admin/Resources/RoleResource.php b/app/Filament/Admin/Resources/RoleResource.php index 9609cef5..859dcd05 100644 --- a/app/Filament/Admin/Resources/RoleResource.php +++ b/app/Filament/Admin/Resources/RoleResource.php @@ -10,6 +10,7 @@ use App\Filament\Admin\Resources\RoleResource\Pages; use App\Forms\Components\Spacer; use App\Models\Role; +use App\Tables\Actions\EditAction; use Filament\Forms\Components\CheckboxList; use Filament\Forms\Components\Placeholder; use Filament\Forms\Components\Section; @@ -17,7 +18,6 @@ use Filament\Forms\Components\Toggle; use Filament\Forms\Form; use Filament\Resources\Resource; -use Filament\Tables; use Filament\Tables\Actions\CreateAction; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Filters\SelectFilter; @@ -106,8 +106,7 @@ public static function table(Table $table): Table ->options(GeneralStatus::options()), ]) ->actions([ - Tables\Actions\EditAction::make() - ->label(__('nomenclature.actions.edit')), + EditAction::make(), ]) ->emptyStateHeading(__('nomenclature.labels.empty_state_role_table')) ->emptyStateDescription(null) diff --git a/app/Filament/Admin/Resources/UserResource.php b/app/Filament/Admin/Resources/UserResource.php index b4d6a90a..021f314d 100644 --- a/app/Filament/Admin/Resources/UserResource.php +++ b/app/Filament/Admin/Resources/UserResource.php @@ -7,6 +7,7 @@ use App\Filament\Admin\Resources\UserResource\Pages; use App\Forms\Components\Select; use App\Models\User; +use App\Tables\Actions\EditAction; use Filament\Forms\Components\Radio; use Filament\Forms\Components\Section; use Filament\Forms\Components\TextInput; @@ -126,7 +127,7 @@ public static function table(Table $table): Table ->multiple(), ]) ->actions([ - Tables\Actions\EditAction::make(), + EditAction::make(), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ diff --git a/app/Filament/Organizations/Resources/BeneficiaryInterventionResource.php b/app/Filament/Organizations/Resources/BeneficiaryInterventionResource.php index b865abee..c48d1e6f 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryInterventionResource.php +++ b/app/Filament/Organizations/Resources/BeneficiaryInterventionResource.php @@ -11,6 +11,7 @@ use App\Models\BeneficiaryIntervention; use App\Models\InterventionService; use App\Models\OrganizationServiceIntervention; +use App\Tables\Actions\EditAction; use Filament\Forms\Components\Grid; use Filament\Forms\Components\Group; use Filament\Forms\Components\Section; @@ -127,7 +128,7 @@ public static function table(Table $table): Table // ]) ->actions([ - Tables\Actions\EditAction::make(), + EditAction::make(), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Widgets/ListSpecialistsWidget.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Widgets/ListSpecialistsWidget.php index 9bf65eae..ab827b87 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Widgets/ListSpecialistsWidget.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Widgets/ListSpecialistsWidget.php @@ -63,13 +63,12 @@ public function table(Table $table): Table EditAction::make() ->form($this->getFormSchema()) ->fillForm(function (Specialist $record) { - if (!$record->role_id) { + if (! $record->role_id) { $record->role_id = -1; } return $record->toArray(); }) - ->label(__('beneficiary.section.specialists.change_action')) ->modalHeading(__('beneficiary.section.specialists.heading.edit_modal')) ->extraModalFooterActions([ DeleteAction::make() @@ -128,7 +127,7 @@ public function getFormSchema(): array ->label(__('beneficiary.section.specialists.labels.name')) ->options( function (Get $get, $state) { - $roleID = (int)$get('role_id'); + $roleID = (int) $get('role_id'); if ($roleID === -1) { if ($state) { return [$state => User::find($state)->full_name]; diff --git a/app/Filament/Organizations/Resources/InterventionPlanResource/Widgets/BenefitsWidget.php b/app/Filament/Organizations/Resources/InterventionPlanResource/Widgets/BenefitsWidget.php index 07825311..0d29e85b 100644 --- a/app/Filament/Organizations/Resources/InterventionPlanResource/Widgets/BenefitsWidget.php +++ b/app/Filament/Organizations/Resources/InterventionPlanResource/Widgets/BenefitsWidget.php @@ -59,7 +59,6 @@ public function table(Table $table): Table ]) ->actions([ EditAction::make() - ->label(__('intervention_plan.actions.edit')) ->form($this->getBenefitSchema()) ->extraModalFooterActions([ DeleteAction::make() diff --git a/app/Filament/Organizations/Resources/InterventionPlanResource/Widgets/ResultsWidget.php b/app/Filament/Organizations/Resources/InterventionPlanResource/Widgets/ResultsWidget.php index dfdf2d7e..66c9ce3f 100644 --- a/app/Filament/Organizations/Resources/InterventionPlanResource/Widgets/ResultsWidget.php +++ b/app/Filament/Organizations/Resources/InterventionPlanResource/Widgets/ResultsWidget.php @@ -75,7 +75,6 @@ public function table(Table $table): Table ]) ->actions([ EditAction::make() - ->label(__('general.action.change')) ->form($this->getFormSchema()) ->modalHeading(__('intervention_plan.headings.edit_result')) ->extraModalFooterActions([ diff --git a/app/Filament/Organizations/Resources/InterventionServiceResource.php b/app/Filament/Organizations/Resources/InterventionServiceResource.php index 45e4f329..c3a28ce6 100644 --- a/app/Filament/Organizations/Resources/InterventionServiceResource.php +++ b/app/Filament/Organizations/Resources/InterventionServiceResource.php @@ -10,10 +10,7 @@ use App\Filament\Organizations\Resources\BeneficiaryInterventionResource\Pages\ViewUnfoldedMeetings; use App\Filament\Organizations\Resources\InterventionServiceResource\Pages; use App\Models\InterventionService; -use Filament\Forms\Form; use Filament\Resources\Resource; -use Filament\Tables; -use Filament\Tables\Table; class InterventionServiceResource extends Resource { @@ -23,40 +20,6 @@ class InterventionServiceResource extends Resource public static string $parentResource = InterventionPlanResource::class; - public static function form(Form $form): Form - { - return $form - ->schema([ - - ]); - } - - public static function table(Table $table): Table - { - return $table - ->columns([ - // - ]) - ->filters([ - // - ]) - ->actions([ - Tables\Actions\EditAction::make(), - ]) - ->bulkActions([ - Tables\Actions\BulkActionGroup::make([ - Tables\Actions\DeleteBulkAction::make(), - ]), - ]); - } - - public static function getRelations(): array - { - return [ - // - ]; - } - public static function getPages(): array { return [ diff --git a/app/Filament/Organizations/Resources/InterventionServiceResource/Widgets/ServiceDescriptionWidget.php b/app/Filament/Organizations/Resources/InterventionServiceResource/Widgets/ServiceDescriptionWidget.php index 2f89bbb5..02790080 100644 --- a/app/Filament/Organizations/Resources/InterventionServiceResource/Widgets/ServiceDescriptionWidget.php +++ b/app/Filament/Organizations/Resources/InterventionServiceResource/Widgets/ServiceDescriptionWidget.php @@ -5,10 +5,9 @@ namespace App\Filament\Organizations\Resources\InterventionServiceResource\Widgets; use App\Filament\Organizations\Resources\InterventionPlanResource; +use App\Infolists\Components\Actions\EditAction; use App\Models\InterventionService; use App\Widgets\InfolistWidget; -use Filament\Infolists\Components\Actions\Action; -//use Filament\Actions\Action; use Filament\Infolists\Components\Section; use Filament\Infolists\Components\TextEntry; @@ -28,10 +27,7 @@ protected function getInfolistSchema(): array ->maxWidth('3xl') ->columns() ->headerActions([ - Action::make('edit') - ->label(__('intervention_plan.actions.edit')) - ->icon('heroicon-o-pencil') - ->link() + EditAction::make('edit') ->url(InterventionPlanResource::getUrl('edit_intervention_service', [ 'parent' => $this->record->interventionPlan, 'record' => $this->record, diff --git a/app/Filament/Organizations/Resources/MonitoringResource.php b/app/Filament/Organizations/Resources/MonitoringResource.php index 62ef05e8..439ee179 100644 --- a/app/Filament/Organizations/Resources/MonitoringResource.php +++ b/app/Filament/Organizations/Resources/MonitoringResource.php @@ -25,30 +25,4 @@ public static function getRecordTitle(Model|null $record): string|null|Htmlable return $record->number; } - public static function form(Form $form): Form - { - return $form - ->schema([ - // - ]); - } - - public static function table(Table $table): Table - { - return $table - ->columns([ - // - ]) - ->filters([ - // - ]) - ->actions([ - Tables\Actions\EditAction::make(), - ]) - ->bulkActions([ - Tables\Actions\BulkActionGroup::make([ - Tables\Actions\DeleteBulkAction::make(), - ]), - ]); - } } diff --git a/app/Tables/Actions/EditAction.php b/app/Tables/Actions/EditAction.php index c8fbf262..05ec3d4a 100644 --- a/app/Tables/Actions/EditAction.php +++ b/app/Tables/Actions/EditAction.php @@ -10,4 +10,12 @@ class EditAction extends BaseEditAction { use HasModalExtraFooterActionsAlignment; + + protected function setUp(): void + { + parent::setUp(); + + $this->label(__('general.action.change')); + $this->icon(null); + } } diff --git a/lang/ro/beneficiary.php b/lang/ro/beneficiary.php index 67d468eb..2b3e298d 100644 --- a/lang/ro/beneficiary.php +++ b/lang/ro/beneficiary.php @@ -311,7 +311,6 @@ 'specialists' => [ 'title' => 'Echipa de caz', 'add_action' => 'Adaugă membru echipă', - 'change_action' => 'Modifică', 'heading' => [ 'add_modal' => 'Adaugă membru în echipă', 'edit_modal' => 'Modifică membru în echipă', diff --git a/lang/ro/intervention_plan.php b/lang/ro/intervention_plan.php index 8ce307b9..56d2ba90 100644 --- a/lang/ro/intervention_plan.php +++ b/lang/ro/intervention_plan.php @@ -253,7 +253,6 @@ 'actions' => [ 'create' => 'Creează plan', - 'edit' => 'Editează', 'edit_intervention_plan' => 'Actualizează detalii', 'add_service' => 'Adaugă serviciu', 'add_service_repeater' => 'Adaugă încă un serviciu', diff --git a/lang/ro/nomenclature.php b/lang/ro/nomenclature.php index d752a62a..2b74e9c6 100644 --- a/lang/ro/nomenclature.php +++ b/lang/ro/nomenclature.php @@ -83,7 +83,6 @@ 'add_role' => 'Adaugă rol specialist', 'edit_role' => 'Modifică rol specialist', 'delete_role' => 'Șterge rol', - 'edit' => 'Modifică', 'add_benefit' => 'Adaugă beneficiu social', 'add_benefit_type' => 'Adaugă încă un tip', 'edit_benefit' => 'Modifică beneficiu',