Skip to content

Commit

Permalink
Merge pull request #385 from code4romania/335-ngo-admin-specialist-ca…
Browse files Browse the repository at this point in the history
…zuri-plan-de-interventie-move-delete-buttons-placement-for-service-and-intervention

Extra footer actions
  • Loading branch information
gheorghelupu17 authored Dec 9, 2024
2 parents a328d10 + 35dcb36 commit 8563931
Show file tree
Hide file tree
Showing 10 changed files with 815 additions and 12 deletions.
25 changes: 25 additions & 0 deletions app/Concerns/HasModalExtraFooterActionsAlignment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace App\Concerns;

use Closure;
use Filament\Support\Enums\Alignment;

trait HasModalExtraFooterActionsAlignment
{
protected Alignment | string | Closure | null $modalExtraFooterActionsAlignment = null;

public function getModalExtraFooterActionsAlignment(): string | Alignment | null
{
return $this->evaluate($this->modalExtraFooterActionsAlignment);
}

public function modalExtraFooterActionsAlignment(Alignment | string | Closure | null $modalExtraFooterActionsAlignment): self
{
$this->modalExtraFooterActionsAlignment = $modalExtraFooterActionsAlignment;

return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use App\Forms\Components\DatePicker;
use App\Forms\Components\Select;
use App\Infolists\Components\Actions\CreateAction;
use App\Infolists\Components\Actions\Edit;
use App\Infolists\Components\SectionHeader;
use App\Models\InterventionMeeting;
use App\Services\Breadcrumb\InterventionPlanBreadcrumb;
Expand All @@ -25,6 +26,7 @@
use Filament\Infolists\Components\TextEntry;
use Filament\Infolists\Infolist;
use Filament\Resources\Pages\ViewRecord;
use Filament\Support\Enums\Alignment;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\Carbon;

Expand Down Expand Up @@ -124,18 +126,16 @@ public function infolist(Infolist $infolist): Infolist
})
->badge(fn (InterventionMeeting $record) => $record->status)
->action(
Action::make('edit')
->label(__('general.action.edit'))
Edit::make('edit')
->icon('heroicon-o-pencil')
->link()
->modalHeading(__('general.action.edit'))
->form($this->getFormSchema())
->fillForm(fn (InterventionMeeting $record) => $record->toArray())
->extraModalFooterActions(
fn () => [
Action::make('delete')
->label(__('intervention_plan.actions.delete_meeting'))
->outlined()
->link()
->color('danger')
->cancelParentActions()
->action(function (InterventionMeeting $record) {
Expand All @@ -147,6 +147,7 @@ public function infolist(Infolist $infolist): Infolist
}),
]
)
->modalExtraFooterActionsAlignment(Alignment::Left)
->action(fn (array $data, InterventionMeeting $record) => $record->update($data))
->successRedirectUrl(fn () => InterventionServiceResource::getUrl('view_meetings', [
'parent' => $this->getRecord()->interventionService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
use App\Models\Specialist;
use App\Models\User;
use App\Models\UserRole;
use App\Tables\Actions\EditAction;
use Filament\Facades\Filament;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Get;
use Filament\Forms\Set;
use Filament\Support\Colors\Color;
use Filament\Support\Enums\Alignment;
use Filament\Tables\Actions\CreateAction;
use Filament\Tables\Actions\DeleteAction;
use Filament\Tables\Actions\EditAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
Expand Down Expand Up @@ -67,8 +68,10 @@ public function table(Table $table): Table
->cancelParentActions()
->label(__('beneficiary.section.specialists.action.delete'))
->modalHeading(__('beneficiary.section.specialists.heading.delete_modal'))
->link()
->icon(null),
]),
])
->modalExtraFooterActionsAlignment(Alignment::Left),
])
->filters([
SelectFilter::make('status')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
use App\Forms\Components\Select;
use App\Models\BenefitType;
use App\Models\InterventionPlan;
use App\Tables\Actions\EditAction;
use Filament\Forms\Components\CheckboxList;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Get;
use Filament\Support\Enums\Alignment;
use Filament\Tables\Actions\CreateAction;
use Filament\Tables\Actions\DeleteAction;
use Filament\Tables\Actions\EditAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget as BaseWidget;
Expand Down Expand Up @@ -63,12 +64,14 @@ public function table(Table $table): Table
->extraModalFooterActions([
DeleteAction::make()
->label(__('intervention_plan.actions.delete_benefit'))
->outlined()
->link()
->icon(null)
->cancelParentActions()
->modalHeading(__('intervention_plan.headings.delete_benefit_modal'))
->modalDescription(fn ($record) => $record->benefit->name)
->modalSubmitActionLabel(__('intervention_plan.actions.delete_benefit')),
]),
])
->modalExtraFooterActionsAlignment(Alignment::Left),
])
->emptyStateHeading(__('intervention_plan.headings.empty_state_benefit_table'))
->emptyStateDescription(__('intervention_plan.labels.empty_state_benefit_table'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
use App\Forms\Components\Select;
use App\Models\InterventionPlan;
use App\Models\User;
use App\Tables\Actions\EditAction;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\Grid;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Get;
use Filament\Support\Enums\Alignment;
use Filament\Tables;
use Filament\Tables\Actions\DeleteAction;
use Filament\Tables\Columns\TextColumn;
Expand Down Expand Up @@ -72,18 +74,20 @@ public function table(Table $table): Table
->html(),
])
->actions([
Tables\Actions\EditAction::make()
EditAction::make()
->label(__('general.action.change'))
->form($this->getFormSchema())
->modalHeading(__('intervention_plan.headings.edit_result'))
->extraModalFooterActions([
DeleteAction::make()
->cancelParentActions()
->label(__('intervention_plan.actions.delete_result'))
->link()
->modalHeading(__('intervention_plan.actions.delete_result'))
->modalSubmitActionLabel(__('intervention_plan.actions.delete_result'))
->icon(null),
]),
])
->modalExtraFooterActionsAlignment(Alignment::Left),
])
->emptyStateHeading(__('intervention_plan.headings.empty_state_result_table'))
->emptyStateDescription(__('intervention_plan.labels.empty_state_result_table'))
Expand Down
3 changes: 3 additions & 0 deletions app/Infolists/Components/Actions/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

namespace App\Infolists\Components\Actions;

use App\Concerns\HasModalExtraFooterActionsAlignment;
use Filament\Infolists\Components\Actions\Action;

class Edit extends Action
{
use HasModalExtraFooterActionsAlignment;

public static function getDefaultName(): ?string
{
return 'edit';
Expand Down
13 changes: 13 additions & 0 deletions app/Tables/Actions/EditAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace App\Tables\Actions;

use App\Concerns\HasModalExtraFooterActionsAlignment;
use Filament\Tables\Actions\EditAction as BaseEditAction;

class EditAction extends BaseEditAction
{
use HasModalExtraFooterActionsAlignment;
}
2 changes: 1 addition & 1 deletion lang/ro/intervention_plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
'delete_meeting' => 'Șterge ședința',
'add_institution' => 'Adaugă încă o instituție',
'add_benefit' => 'Adaugă beneficiu',
'delete_benefit' => 'Sterge beneficiu',
'delete_benefit' => 'Șterge beneficiu',
'delete_beneficiary_intervention' => 'Șterge intervenția',
'view_intervention' => 'Vezi intervenția',
'download_meetings' => 'Descarcă tabel',
Expand Down
Loading

0 comments on commit 8563931

Please sign in to comment.