Skip to content

Commit

Permalink
Merge pull request #249 from code4romania/239-general-implement-click…
Browse files Browse the repository at this point in the history
…-on-row-for-all-the-tables-in-the-platform

Table clickable row
  • Loading branch information
gheorghelupu17 authored Nov 8, 2024
2 parents 0ee7cd6 + 1d3b853 commit afe4046
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function infolist(Infolist $infolist): Infolist

TextEntry::make('date')
->label(__('intervention_plan.labels.date'))
->formatStateUsing(fn (InterventionMeeting $record, Carbon $state) => $state->format('Y-m-d') . ' ' . $record->time?->format('H:i')),
->formatStateUsing(fn (InterventionMeeting $record, Carbon | string $state) => (\is_string($state) ? $state : $state->format('Y-m-d')) . ' ' . $record->time?->format('H:i')),
TextEntry::make('duration')
->label(__('intervention_plan.labels.duration')),
TextEntry::make('user.full_name')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public function table(Table $table): Table
'record' => $this->record,
])),
])
->recordUrl(fn () => InterventionServiceResource::getUrl('view_meetings', [
'parent' => $this->record->interventionService,
'record' => $this->record,
]))
->emptyStateHeading(__('intervention_plan.headings.empty_state_service_table'))
->emptyStateDescription(__('intervention_plan.labels.empty_state_service_table'))
->emptyStateIcon('heroicon-o-document');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Filament\Organizations\Resources\BeneficiaryResource;
use App\Filament\Organizations\Resources\InterventionServiceResource;
use App\Models\Beneficiary;
use App\Models\BeneficiaryIntervention;
use App\Models\InterventionPlan;
use Filament\Tables\Actions\Action;
use Filament\Tables\Actions\ViewAction;
Expand Down Expand Up @@ -58,11 +59,15 @@ public function table(Table $table): Table
->actions([
ViewAction::make('view_intervention')
->label(__('intervention_plan.actions.view_intervention'))
->url(fn ($record) => InterventionServiceResource::getUrl('view_intervention', [
->url(fn (BeneficiaryIntervention $record) => InterventionServiceResource::getUrl('view_intervention', [
'parent' => $record->intervention_service_id,
'record' => $record,
])),
])
->recordUrl(fn (BeneficiaryIntervention $record) => InterventionServiceResource::getUrl('view_intervention', [
'parent' => $record->intervention_service_id,
'record' => $record,
]))
->headerActions([
Action::make('view_intervention_plan')
->label(__('intervention_plan.actions.view_intervention_plan'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function table(Table $table): Table
->color('primary')
->url(fn (Beneficiary $record) => BeneficiaryResource::getUrl('view', ['record' => $record->id])),
])
->recordUrl(fn (Beneficiary $record) => BeneficiaryResource::getUrl('view', ['record' => $record->id]))
->defaultSort('id', 'desc');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@ public function table(Table $table): Table
->actions([
ViewAction::make()
->label(__('general.action.view_details'))
->url(fn ($record) => InterventionPlanResource::getUrl('view_intervention_service', [
->url(fn (InterventionService $record) => InterventionPlanResource::getUrl('view_intervention_service', [
'parent' => $this->record,
'record' => $record,
])),
])
->recordUrl(fn (InterventionService $record) => InterventionPlanResource::getUrl('view_intervention_service', [
'parent' => $this->record,
'record' => $record,
]))
->emptyStateHeading(__('intervention_plan.headings.empty_state_service_table'))
->emptyStateDescription(__('intervention_plan.labels.empty_state_service_table'))
->emptyStateIcon('heroicon-o-document');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Filament\Organizations\Resources\BeneficiaryInterventionResource;
use App\Filament\Organizations\Resources\InterventionServiceResource;
use App\Models\BeneficiaryIntervention;
use App\Models\InterventionService;
use Filament\Forms\Components\Hidden;
use Filament\Tables;
Expand Down Expand Up @@ -51,11 +52,15 @@ public function table(Table $table): Table
->actions([
Tables\Actions\ViewAction::make()
->label(__('general.action.view_details'))
->url(fn ($record) => InterventionServiceResource::getUrl('view_meetings', [
->url(fn (BeneficiaryIntervention $record) => InterventionServiceResource::getUrl('view_meetings', [
'parent' => $this->record,
'record' => $record,
])),
])
->recordUrl(fn (BeneficiaryIntervention $record) => InterventionServiceResource::getUrl('view_meetings', [
'parent' => $this->record,
'record' => $record,
]))
->emptyStateHeading(__('intervention_plan.headings.empty_state_service_intervention_table'))
->emptyStateDescription(__('intervention_plan.labels.empty_state_service_intervention_table'))
->emptyStateIcon('heroicon-o-document');
Expand Down

0 comments on commit afe4046

Please sign in to comment.