From 7a60c0f7e3ab33b0056746b2ddb4a6c328f51d40 Mon Sep 17 00:00:00 2001 From: Alex Popa Date: Fri, 10 Jan 2025 02:41:49 +0200 Subject: [PATCH 1/3] Sort service interventions and benefit types --- .../Admin/Resources/BenefitResource.php | 6 ++++ .../Admin/Resources/ServiceResource.php | 15 ++++++-- app/Models/BenefitType.php | 8 +++++ app/Models/Scopes/SortOrder.php | 34 +++++++++++++++++++ app/Models/ServiceIntervention.php | 8 +++++ ..._column_in_service_interventions_table.php | 17 ++++++++++ ...add_sort_column_in_benefit_types_table.php | 17 ++++++++++ lang/ro/nomenclature.php | 2 ++ 8 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 app/Models/Scopes/SortOrder.php create mode 100644 database/migrations/2025_01_09_221922_add_sort_column_in_service_interventions_table.php create mode 100644 database/migrations/2025_01_10_002445_add_sort_column_in_benefit_types_table.php diff --git a/app/Filament/Admin/Resources/BenefitResource.php b/app/Filament/Admin/Resources/BenefitResource.php index 3159533f..ee29da9a 100644 --- a/app/Filament/Admin/Resources/BenefitResource.php +++ b/app/Filament/Admin/Resources/BenefitResource.php @@ -10,6 +10,7 @@ use App\Models\Benefit; use App\Models\BenefitService; use Filament\Forms\Components\Actions\Action; +use Filament\Forms\Components\Hidden; use Filament\Forms\Components\Section; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\Toggle; @@ -41,10 +42,15 @@ public static function form(Form $form): Form TableRepeater::make('benefitTypes') ->relationship('benefitTypes') ->label(__('nomenclature.headings.benefit_types')) + ->helperText(__('nomenclature.helper_texts.benefit_types')) + ->reorderable() + ->orderColumn() ->columnSpanFull() ->hideLabels() ->addActionLabel(__('nomenclature.actions.add_benefit_type')) ->schema([ + Hidden::make('sort'), + TextInput::make('name') ->label(__('nomenclature.labels.benefit_type_name')) ->maxLength(200), diff --git a/app/Filament/Admin/Resources/ServiceResource.php b/app/Filament/Admin/Resources/ServiceResource.php index c4eb6513..2b1524a6 100644 --- a/app/Filament/Admin/Resources/ServiceResource.php +++ b/app/Filament/Admin/Resources/ServiceResource.php @@ -13,6 +13,7 @@ use App\Models\Service; use App\Models\ServiceIntervention; use Filament\Forms\Components\Actions\Action; +use Filament\Forms\Components\Hidden; use Filament\Forms\Components\Placeholder; use Filament\Forms\Components\Section; use Filament\Forms\Components\TextInput; @@ -77,10 +78,15 @@ public static function form(Form $form): Form TableRepeater::make('serviceInterventions') ->relationship('serviceInterventions') ->label(__('nomenclature.headings.service_intervention')) + ->helperText(__('nomenclature.helper_texts.service_interventions')) + ->reorderable() + ->orderColumn() ->columnSpanFull() ->addActionLabel(__('nomenclature.actions.add_intervention')) ->schema([ - Placeholder::make('id') + Hidden::make('sort'), + + Placeholder::make('index') ->label(__('nomenclature.labels.nr')) ->content(function () { static $index = 1; @@ -88,6 +94,7 @@ public static function form(Form $form): Form return $index++; }) ->hiddenLabel(), + TextInput::make('name') ->columnSpanFull() ->hiddenLabel() @@ -107,7 +114,11 @@ public static function form(Form $form): Form ]) ->deleteAction( fn (Action $action) => $action - ->disabled(function (array $arguments, TableRepeater $component): bool { + ->disabled(function (array $arguments, TableRepeater $component, string $operation): bool { + if ($operation === 'create') { + return false; + } + $items = $component->getState(); $currentItem = $items[$arguments['item']]; diff --git a/app/Models/BenefitType.php b/app/Models/BenefitType.php index 8aa0df50..c916462f 100644 --- a/app/Models/BenefitType.php +++ b/app/Models/BenefitType.php @@ -5,6 +5,7 @@ namespace App\Models; use App\Concerns\HasGeneralStatus; +use App\Models\Scopes\SortOrder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -17,8 +18,15 @@ class BenefitType extends Model protected $fillable = [ 'benefit_id', 'name', + 'sort', ]; + protected static function booted() + { + parent::booted(); + static::addGlobalScope(new SortOrder); + } + public function benefit(): BelongsTo { return $this->belongsTo(Benefit::class); diff --git a/app/Models/Scopes/SortOrder.php b/app/Models/Scopes/SortOrder.php new file mode 100644 index 00000000..a801c21a --- /dev/null +++ b/app/Models/Scopes/SortOrder.php @@ -0,0 +1,34 @@ +column = $column; + $this->direction = $direction; + } + + /** + * Apply the scope to a given Eloquent query builder. + * + * @param Builder $builder + * @param Model $model + * @return void + */ + public function apply(Builder $builder, Model $model): void + { + $builder->orderBy($this->column, $this->direction); + } +} diff --git a/app/Models/ServiceIntervention.php b/app/Models/ServiceIntervention.php index 4c1fcf93..cc5e45e1 100644 --- a/app/Models/ServiceIntervention.php +++ b/app/Models/ServiceIntervention.php @@ -5,6 +5,7 @@ namespace App\Models; use App\Concerns\HasGeneralStatus; +use App\Models\Scopes\SortOrder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -19,8 +20,15 @@ class ServiceIntervention extends Model protected $fillable = [ 'service_id', 'name', + 'sort', ]; + protected static function booted() + { + parent::booted(); + static::addGlobalScope(new SortOrder); + } + public function service(): BelongsTo { return $this->belongsTo(Service::class); diff --git a/database/migrations/2025_01_09_221922_add_sort_column_in_service_interventions_table.php b/database/migrations/2025_01_09_221922_add_sort_column_in_service_interventions_table.php new file mode 100644 index 00000000..34ec2791 --- /dev/null +++ b/database/migrations/2025_01_09_221922_add_sort_column_in_service_interventions_table.php @@ -0,0 +1,17 @@ +integer('sort')->default(0); + }); + } +}; diff --git a/database/migrations/2025_01_10_002445_add_sort_column_in_benefit_types_table.php b/database/migrations/2025_01_10_002445_add_sort_column_in_benefit_types_table.php new file mode 100644 index 00000000..c9647576 --- /dev/null +++ b/database/migrations/2025_01_10_002445_add_sort_column_in_benefit_types_table.php @@ -0,0 +1,17 @@ +integer('sort')->default(0); + }); + } +}; diff --git a/lang/ro/nomenclature.php b/lang/ro/nomenclature.php index 2b74e9c6..b9577f6d 100644 --- a/lang/ro/nomenclature.php +++ b/lang/ro/nomenclature.php @@ -66,6 +66,8 @@ 'inactivate_result_modal' => 'Prin inactivarea rezultatului, acesta nu va mai fi disponibil pentru fi adăugat în nomenclatoarele de rezultate ale organizațiilor Sunrise. Pentru organizațiile care au folosit deja acest rezultat, acesta va fi retras din nomenclatoare, fără să se șteargă din istoricul planului de interventie pentru care a fost folosit.', 'delete_benefit' => 'Beneficiile sociale utilizate deja în fișe de beneficiar nu mai pot fi șterse. Aveți doar opțiunea de a le deactiva.', 'result' => 'Definește un rezultat care va deveni disponibil pentru a fi inclus în nomenclatoarele tuturor organizațiilor Sunrise.', + 'service_interventions' => 'Ordinea intervențiilor din această listă va fi păstrată în platforma Sunrise pentru afișarea opțiunilor în selectorul de intervenții', + 'benefit_types' => 'Ordinea beneficiilor din această listă va fi păstrată în platforma Sunrise pentru afișarea opțiunilor în selectorul de beneficii sociale.', ], 'actions' => [ From 156f90e00ed6e9f0c31709a2e689e97dca2c01d4 Mon Sep 17 00:00:00 2001 From: Alex Popa Date: Fri, 10 Jan 2025 11:33:56 +0200 Subject: [PATCH 2/3] Reorder nomenclature items --- app/Concerns/HasSortOrder.php | 20 + .../Admin/Resources/BenefitResource.php | 10 + .../Admin/Resources/ResultResource.php | 10 + app/Filament/Admin/Resources/RoleResource.php | 10 + .../Admin/Resources/ServiceResource.php | 10 + app/Models/Benefit.php | 2 + app/Models/BenefitType.php | 10 +- app/Models/Result.php | 2 + app/Models/Role.php | 2 + app/Models/Service.php | 2 + app/Models/ServiceIntervention.php | 10 +- ...4906_add_sort_column_in_services_table.php | 17 + ...5052_add_sort_column_in_benefits_table.php | 17 + ...05204_add_sort_column_in_results_table.php | 17 + ..._005232_add_sort_column_in_roles_table.php | 17 + lang/vendor/filament-tables/ro/table.php | 16 + .../vendor/filament-tables/index.blade.php | 1298 +++++++++++++++++ 17 files changed, 1454 insertions(+), 16 deletions(-) create mode 100644 app/Concerns/HasSortOrder.php create mode 100644 database/migrations/2025_01_10_004906_add_sort_column_in_services_table.php create mode 100644 database/migrations/2025_01_10_005052_add_sort_column_in_benefits_table.php create mode 100644 database/migrations/2025_01_10_005204_add_sort_column_in_results_table.php create mode 100644 database/migrations/2025_01_10_005232_add_sort_column_in_roles_table.php create mode 100644 lang/vendor/filament-tables/ro/table.php create mode 100644 resources/views/vendor/filament-tables/index.blade.php diff --git a/app/Concerns/HasSortOrder.php b/app/Concerns/HasSortOrder.php new file mode 100644 index 00000000..320e94fd --- /dev/null +++ b/app/Concerns/HasSortOrder.php @@ -0,0 +1,20 @@ +fillable[] = 'sort'; + } + + protected static function bootHasSortOrder(): void + { + static::addGlobalScope(new SortOrder); + } +} diff --git a/app/Filament/Admin/Resources/BenefitResource.php b/app/Filament/Admin/Resources/BenefitResource.php index ee29da9a..ba2f3d47 100644 --- a/app/Filament/Admin/Resources/BenefitResource.php +++ b/app/Filament/Admin/Resources/BenefitResource.php @@ -16,6 +16,7 @@ use Filament\Forms\Components\Toggle; use Filament\Forms\Form; use Filament\Resources\Resource; +use Filament\Tables\Actions\Action as TableAction; use Filament\Tables\Actions\CreateAction; use Filament\Tables\Actions\ViewAction; use Filament\Tables\Columns\TextColumn; @@ -87,6 +88,15 @@ public static function table(Table $table): Table ->url(self::getUrl('create')), ]) ->heading(__('nomenclature.headings.benefit_table')) + ->reorderable('sort') + ->defaultSort('sort') + ->reorderRecordsTriggerAction( + fn (TableAction $action) => $action + ->icon(null) + ->button() + ->outlined() + ->color('primary') + ) ->columns([ TextColumn::make('name') ->label(__('nomenclature.labels.benefit')), diff --git a/app/Filament/Admin/Resources/ResultResource.php b/app/Filament/Admin/Resources/ResultResource.php index a501dce3..56429538 100644 --- a/app/Filament/Admin/Resources/ResultResource.php +++ b/app/Filament/Admin/Resources/ResultResource.php @@ -13,6 +13,7 @@ use Filament\Forms\Components\TextInput; use Filament\Forms\Form; use Filament\Resources\Resource; +use Filament\Tables\Actions\Action as TableAction; use Filament\Tables\Actions\CreateAction; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Table; @@ -48,6 +49,15 @@ public static function table(Table $table): Table CreateAction::make() ->label(__('nomenclature.actions.add_result')), ]) + ->reorderable('sort') + ->defaultSort('sort') + ->reorderRecordsTriggerAction( + fn (TableAction $action) => $action + ->icon(null) + ->button() + ->outlined() + ->color('primary') + ) ->columns([ TextColumn::make('name') ->label(__('nomenclature.labels.result_name')), diff --git a/app/Filament/Admin/Resources/RoleResource.php b/app/Filament/Admin/Resources/RoleResource.php index 859dcd05..0b8bdaad 100644 --- a/app/Filament/Admin/Resources/RoleResource.php +++ b/app/Filament/Admin/Resources/RoleResource.php @@ -18,6 +18,7 @@ use Filament\Forms\Components\Toggle; use Filament\Forms\Form; use Filament\Resources\Resource; +use Filament\Tables\Actions\Action as TableAction; use Filament\Tables\Actions\CreateAction; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Filters\SelectFilter; @@ -81,6 +82,15 @@ public static function table(Table $table): Table ->label(__('nomenclature.actions.add_role')), ]) + ->reorderable('sort') + ->defaultSort('sort') + ->reorderRecordsTriggerAction( + fn (TableAction $action) => $action + ->icon(null) + ->button() + ->outlined() + ->color('primary') + ) ->columns([ TextColumn::make('name') ->label(__('nomenclature.labels.role_name')), diff --git a/app/Filament/Admin/Resources/ServiceResource.php b/app/Filament/Admin/Resources/ServiceResource.php index 2b1524a6..353f2bf2 100644 --- a/app/Filament/Admin/Resources/ServiceResource.php +++ b/app/Filament/Admin/Resources/ServiceResource.php @@ -21,6 +21,7 @@ use Filament\Forms\Form; use Filament\Forms\Get; use Filament\Resources\Resource; +use Filament\Tables\Actions\Action as TableAction; use Filament\Tables\Actions\CreateAction; use Filament\Tables\Actions\ViewAction; use Filament\Tables\Columns\TextColumn; @@ -141,6 +142,15 @@ public static function table(Table $table): Table { return $table ->modifyQueryUsing(fn (Builder $query) => $query->withCount(['organizationServices'])) + ->reorderable('sort') + ->defaultSort('sort') + ->reorderRecordsTriggerAction( + fn (TableAction $action) => $action + ->icon(null) + ->button() + ->outlined() + ->color('primary') + ) ->columns([ TextColumn::make('name') ->label(__('nomenclature.labels.name')) diff --git a/app/Models/Benefit.php b/app/Models/Benefit.php index 0e36d7c9..714e25d8 100644 --- a/app/Models/Benefit.php +++ b/app/Models/Benefit.php @@ -5,6 +5,7 @@ namespace App\Models; use App\Concerns\HasGeneralStatus; +use App\Concerns\HasSortOrder; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -14,6 +15,7 @@ class Benefit extends Model { use HasFactory; use HasGeneralStatus; + use HasSortOrder; protected $fillable = [ 'name', diff --git a/app/Models/BenefitType.php b/app/Models/BenefitType.php index c916462f..ea24f6bb 100644 --- a/app/Models/BenefitType.php +++ b/app/Models/BenefitType.php @@ -5,7 +5,7 @@ namespace App\Models; use App\Concerns\HasGeneralStatus; -use App\Models\Scopes\SortOrder; +use App\Concerns\HasSortOrder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -14,19 +14,13 @@ class BenefitType extends Model { use HasFactory; use HasGeneralStatus; + use HasSortOrder; protected $fillable = [ 'benefit_id', 'name', - 'sort', ]; - protected static function booted() - { - parent::booted(); - static::addGlobalScope(new SortOrder); - } - public function benefit(): BelongsTo { return $this->belongsTo(Benefit::class); diff --git a/app/Models/Result.php b/app/Models/Result.php index 48596f5a..dd5c2d40 100644 --- a/app/Models/Result.php +++ b/app/Models/Result.php @@ -5,6 +5,7 @@ namespace App\Models; use App\Concerns\HasGeneralStatus; +use App\Concerns\HasSortOrder; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -14,6 +15,7 @@ class Result extends Model { use HasFactory; use HasGeneralStatus; + use HasSortOrder; protected $fillable = [ 'name', diff --git a/app/Models/Role.php b/app/Models/Role.php index 0781891e..55755fcf 100644 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -5,6 +5,7 @@ namespace App\Models; use App\Concerns\HasGeneralStatus; +use App\Concerns\HasSortOrder; use App\Enums\AdminPermission; use App\Enums\CasePermission; use Illuminate\Database\Eloquent\Casts\AsEnumCollection; @@ -16,6 +17,7 @@ class Role extends Model { use HasFactory; use HasGeneralStatus; + use HasSortOrder; protected $fillable = [ 'name', diff --git a/app/Models/Service.php b/app/Models/Service.php index f7763688..469dae8c 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -5,6 +5,7 @@ namespace App\Models; use App\Concerns\HasGeneralStatus; +use App\Concerns\HasSortOrder; use App\Enums\CounselingSheet; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -15,6 +16,7 @@ class Service extends Model { use HasFactory; use HasGeneralStatus; + use HasSortOrder; protected $fillable = [ 'name', diff --git a/app/Models/ServiceIntervention.php b/app/Models/ServiceIntervention.php index cc5e45e1..e217f50c 100644 --- a/app/Models/ServiceIntervention.php +++ b/app/Models/ServiceIntervention.php @@ -5,7 +5,7 @@ namespace App\Models; use App\Concerns\HasGeneralStatus; -use App\Models\Scopes\SortOrder; +use App\Concerns\HasSortOrder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -16,19 +16,13 @@ class ServiceIntervention extends Model { use HasFactory; use HasGeneralStatus; + use HasSortOrder; protected $fillable = [ 'service_id', 'name', - 'sort', ]; - protected static function booted() - { - parent::booted(); - static::addGlobalScope(new SortOrder); - } - public function service(): BelongsTo { return $this->belongsTo(Service::class); diff --git a/database/migrations/2025_01_10_004906_add_sort_column_in_services_table.php b/database/migrations/2025_01_10_004906_add_sort_column_in_services_table.php new file mode 100644 index 00000000..25a977ad --- /dev/null +++ b/database/migrations/2025_01_10_004906_add_sort_column_in_services_table.php @@ -0,0 +1,17 @@ +integer('sort')->default(0); + }); + } +}; diff --git a/database/migrations/2025_01_10_005052_add_sort_column_in_benefits_table.php b/database/migrations/2025_01_10_005052_add_sort_column_in_benefits_table.php new file mode 100644 index 00000000..647e475d --- /dev/null +++ b/database/migrations/2025_01_10_005052_add_sort_column_in_benefits_table.php @@ -0,0 +1,17 @@ +integer('sort')->default(0); + }); + } +}; diff --git a/database/migrations/2025_01_10_005204_add_sort_column_in_results_table.php b/database/migrations/2025_01_10_005204_add_sort_column_in_results_table.php new file mode 100644 index 00000000..0199c89b --- /dev/null +++ b/database/migrations/2025_01_10_005204_add_sort_column_in_results_table.php @@ -0,0 +1,17 @@ +integer('sort')->default(0); + }); + } +}; diff --git a/database/migrations/2025_01_10_005232_add_sort_column_in_roles_table.php b/database/migrations/2025_01_10_005232_add_sort_column_in_roles_table.php new file mode 100644 index 00000000..4b4a6133 --- /dev/null +++ b/database/migrations/2025_01_10_005232_add_sort_column_in_roles_table.php @@ -0,0 +1,17 @@ +integer('sort')->default(0); + }); + } +}; diff --git a/lang/vendor/filament-tables/ro/table.php b/lang/vendor/filament-tables/ro/table.php new file mode 100644 index 00000000..6e6ec4e2 --- /dev/null +++ b/lang/vendor/filament-tables/ro/table.php @@ -0,0 +1,16 @@ + [ + + 'disable_reordering' => [ + 'label' => 'Salvează modificările', + ], + + 'enable_reordering' => [ + 'label' => 'Ordonează lista', + ], + ], +]; diff --git a/resources/views/vendor/filament-tables/index.blade.php b/resources/views/vendor/filament-tables/index.blade.php new file mode 100644 index 00000000..01d02307 --- /dev/null +++ b/resources/views/vendor/filament-tables/index.blade.php @@ -0,0 +1,1298 @@ +@php + use Filament\Support\Enums\Alignment; + use Filament\Support\Enums\VerticalAlignment; + use Filament\Support\Facades\FilamentView; + use Filament\Tables\Columns\Column; + use Filament\Tables\Columns\ColumnGroup; + use Filament\Tables\Enums\ActionsPosition; + use Filament\Tables\Enums\FiltersLayout; + use Filament\Tables\Enums\RecordCheckboxPosition; + use Illuminate\Support\Str; + + $actions = $getActions(); + $flatActionsCount = count($getFlatActions()); + $actionsAlignment = $getActionsAlignment(); + $actionsPosition = $getActionsPosition(); + $actionsColumnLabel = $getActionsColumnLabel(); + $activeFiltersCount = $getActiveFiltersCount(); + $columns = $getVisibleColumns(); + $collapsibleColumnsLayout = $getCollapsibleColumnsLayout(); + $columnsLayout = $getColumnsLayout(); + $content = $getContent(); + $contentGrid = $getContentGrid(); + $contentFooter = $getContentFooter(); + $filterIndicators = $getFilterIndicators(); + $hasColumnGroups = $hasColumnGroups(); + $hasColumnsLayout = $hasColumnsLayout(); + $hasSummary = $hasSummary(); + $header = $getHeader(); + $headerActions = array_filter( + $getHeaderActions(), + fn (\Filament\Tables\Actions\Action | \Filament\Tables\Actions\BulkAction | \Filament\Tables\Actions\ActionGroup $action): bool => $action->isVisible(), + ); + $headerActionsPosition = $getHeaderActionsPosition(); + $heading = $getHeading(); + $group = $getGrouping(); + $bulkActions = array_filter( + $getBulkActions(), + fn (\Filament\Tables\Actions\BulkAction | \Filament\Tables\Actions\ActionGroup $action): bool => $action->isVisible(), + ); + $groups = $getGroups(); + $description = $getDescription(); + $isGroupsOnly = $isGroupsOnly() && $group; + $isReorderable = $isReorderable(); + $isReordering = $isReordering(); + $areGroupingSettingsVisible = (! $isReordering) && count($groups) && (! $areGroupingSettingsHidden()); + $isGroupingDirectionSettingHidden = $isGroupingDirectionSettingHidden(); + $isColumnSearchVisible = $isSearchableByColumn(); + $isGlobalSearchVisible = $isSearchable(); + $isSearchOnBlur = $isSearchOnBlur(); + $isSelectionEnabled = $isSelectionEnabled() && (! $isGroupsOnly); + $selectsCurrentPageOnly = $selectsCurrentPageOnly(); + $recordCheckboxPosition = $getRecordCheckboxPosition(); + $isStriped = $isStriped(); + $isLoaded = $isLoaded(); + $hasFilters = $isFilterable(); + $filtersLayout = $getFiltersLayout(); + $filtersTriggerAction = $getFiltersTriggerAction(); + $hasFiltersDialog = $hasFilters && in_array($filtersLayout, [FiltersLayout::Dropdown, FiltersLayout::Modal]); + $hasFiltersAboveContent = $hasFilters && in_array($filtersLayout, [FiltersLayout::AboveContent, FiltersLayout::AboveContentCollapsible]); + $hasFiltersAboveContentCollapsible = $hasFilters && ($filtersLayout === FiltersLayout::AboveContentCollapsible); + $hasFiltersBelowContent = $hasFilters && ($filtersLayout === FiltersLayout::BelowContent); + $hasColumnToggleDropdown = $hasToggleableColumns(); + $hasHeader = $header || $heading || $description || ($headerActions && (! $isReordering)) || $isReorderable || $areGroupingSettingsVisible || $isGlobalSearchVisible || $hasFilters || count($filterIndicators) || $hasColumnToggleDropdown; + $hasHeaderToolbar = $isReorderable || $areGroupingSettingsVisible || $isGlobalSearchVisible || $hasFiltersDialog || $hasColumnToggleDropdown; + $pluralModelLabel = $getPluralModelLabel(); + $records = $isLoaded ? $getRecords() : null; + $searchDebounce = $getSearchDebounce(); + $allSelectableRecordsCount = ($isSelectionEnabled && $isLoaded) ? $getAllSelectableRecordsCount() : null; + $columnsCount = count($columns); + $reorderRecordsTriggerAction = $getReorderRecordsTriggerAction($isReordering); + $toggleColumnsTriggerAction = $getToggleColumnsTriggerAction(); + $page = $this->getTablePage(); + $defaultSortOptionLabel = $getDefaultSortOptionLabel(); + + if (count($actions) && (! $isReordering)) { + $columnsCount++; + } + + if ($isSelectionEnabled || $isReordering) { + $columnsCount++; + } + + if ($group) { + $groupedSummarySelectedState = $this->getTableSummarySelectedState($this->getAllTableSummaryQuery(), modifyQueryUsing: fn (\Illuminate\Database\Query\Builder $query) => $group->groupQuery($query, model: $getQuery()->getModel())); + } + + $getHiddenClasses = function (Column | ColumnGroup $column): ?string { + if ($breakpoint = $column->getHiddenFrom()) { + return match ($breakpoint) { + 'sm' => 'sm:hidden', + 'md' => 'md:hidden', + 'lg' => 'lg:hidden', + 'xl' => 'xl:hidden', + '2xl' => '2xl:hidden', + }; + } + + if ($breakpoint = $column->getVisibleFrom()) { + return match ($breakpoint) { + 'sm' => 'hidden sm:table-cell', + 'md' => 'hidden md:table-cell', + 'lg' => 'hidden lg:table-cell', + 'xl' => 'hidden xl:table-cell', + '2xl' => 'hidden 2xl:table-cell', + }; + } + + return null; + }; +@endphp + +
$records === null, + ]) +> + +
+ + {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::HEADER_BEFORE, scopes: static::class) }} + + @if ($header) + {{ $header }} + @elseif (($heading || $description || $headerActions) && ! $isReordering) + @php + if ($reorderRecordsTriggerAction){ + array_unshift($headerActions, $reorderRecordsTriggerAction); + } + @endphp + + + + @elseif($isReordering && $reorderRecordsTriggerAction) + + {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_REORDER_TRIGGER_BEFORE, scopes: static::class) }} + + + + {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_REORDER_TRIGGER_AFTER, scopes: static::class) }} + + @endif + + {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::HEADER_AFTER, scopes: static::class) }} + + @if ($hasFiltersAboveContent) +
+ + + @if ($hasFiltersAboveContentCollapsible) + + {{ $filtersTriggerAction->badge($activeFiltersCount) }} + + @endif +
+ @endif + + {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_BEFORE, scopes: static::class) }} + +
+ {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_START, scopes: static::class) }} + +
+ + @if ((! $isReordering) && count($bulkActions)) + + @endif + + {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_GROUPING_SELECTOR_BEFORE, scopes: static::class) }} + + @if ($areGroupingSettingsVisible) + + @endif + + {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_GROUPING_SELECTOR_AFTER, scopes: static::class) }} +
+ + @if ($isGlobalSearchVisible || $hasFiltersDialog || $hasColumnToggleDropdown) +
+ {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_SEARCH_BEFORE, scopes: static::class) }} + + @if ($isGlobalSearchVisible) + + @endif + + {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_SEARCH_AFTER, scopes: static::class) }} + + @if ($hasFiltersDialog || $hasColumnToggleDropdown) + @if ($hasFiltersDialog) + + @endif + + {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_TOGGLE_COLUMN_TRIGGER_BEFORE, scopes: static::class) }} + + @if ($hasColumnToggleDropdown) + + @endif + + {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_TOGGLE_COLUMN_TRIGGER_AFTER, scopes: static::class) }} + @endif +
+ @endif + + {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_END) }} +
+ + {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\Tables\View\TablesRenderHook::TOOLBAR_AFTER) }} +
+ + @if ($isReordering) + + @elseif ($isSelectionEnabled && $isLoaded) + + @endif + + @if (count($filterIndicators)) + + @endif + +
! $hasHeader, + ]) + > + @if (($content || $hasColumnsLayout) && ($records !== null) && count($records)) + @if (! $isReordering) + @php + $sortableColumns = array_filter( + $columns, + fn (\Filament\Tables\Columns\Column $column): bool => $column->isSortable(), + ); + @endphp + + @if ($isSelectionEnabled || count($sortableColumns)) +
+ @if ($isSelectionEnabled && (! $isReordering)) + + @endif + + @if (count($sortableColumns)) +
+ + + +
+ @endif +
+ @endif + @endif + + @if ($content) + {{ $content->with(['records' => $records]) }} + @else + $contentGrid, + 'pt-0' => $contentGrid && $this->getTableGrouping(), + 'gap-y-px bg-gray-200 dark:bg-white/5' => ! $contentGrid, + ]) + > + @php + $previousRecord = null; + $previousRecordGroupKey = null; + $previousRecordGroupTitle = null; + @endphp + + @foreach ($records as $record) + @php + $recordAction = $getRecordAction($record); + $recordKey = $getRecordKey($record); + $recordUrl = $getRecordUrl($record); + $openRecordUrlInNewTab = $shouldOpenRecordUrlInNewTab($record); + $recordGroupKey = $group?->getStringKey($record); + $recordGroupTitle = $group?->getTitle($record); + + $collapsibleColumnsLayout?->record($record); + $hasCollapsibleColumnsLayout = (bool) $collapsibleColumnsLayout?->isVisible(); + @endphp + + @if ($recordGroupTitle !== $previousRecordGroupTitle) + @if ($hasSummary && (! $isReordering) && filled($previousRecordGroupTitle)) + + + + @endif + + $contentGrid, + ]) + :x-bind:class="$hasSummary ? null : '{ \'-mb-4 border-b-0\': isGroupCollapsed(' . \Illuminate\Support\Js::from($recordGroupTitle) . ') }'" + > + @if ($isSelectionEnabled) + +
+ +
+
+ @endif +
+ @endif + +
($recordUrl || $recordAction) && (! $contentGrid), + 'hover:bg-gray-50 dark:hover:bg-white/10 dark:hover:ring-white/20' => ($recordUrl || $recordAction) && $contentGrid, + 'rounded-xl shadow-sm ring-1 ring-gray-950/5 dark:bg-white/5 dark:ring-white/10' => $contentGrid, + ...$getRecordClasses($record), + ]) + x-bind:class="{ + 'hidden': + {{ $group?->isCollapsible() ? 'true' : 'false' }} && + isGroupCollapsed( + {{ \Illuminate\Support\Js::from($recordGroupTitle) }}, + ), + {{ ($contentGrid ? '\'bg-gray-50 dark:bg-white/10 dark:ring-white/20\'' : '\'bg-gray-50 dark:bg-white/5 before:absolute before:start-0 before:inset-y-0 before:w-0.5 before:bg-primary-600 dark:before:bg-primary-500\'') . ': isRecordSelected(\'' . $recordKey . '\')' }}, + {{ $contentGrid ? '\'bg-white dark:bg-white/5 dark:ring-white/10\': ! isRecordSelected(\'' . $recordKey . '\')' : '\'\':\'\'' }}, + }" + > + @php + $hasItemBeforeRecordContent = $isReordering || ($isSelectionEnabled && $isRecordSelectable($record)); + $isRecordCollapsible = $hasCollapsibleColumnsLayout && (! $isReordering); + $hasItemAfterRecordContent = $isRecordCollapsible; + $recordHasActions = count($actions) && (! $isReordering); + + $recordContentHorizontalPaddingClasses = \Illuminate\Support\Arr::toCssClasses([ + 'ps-3' => (! $contentGrid) && $hasItemBeforeRecordContent, + 'ps-4 sm:ps-6' => (! $contentGrid) && (! $hasItemBeforeRecordContent), + 'pe-3' => (! $contentGrid) && $hasItemAfterRecordContent, + 'pe-4 sm:pe-6' => (! $contentGrid) && (! $hasItemAfterRecordContent), + 'ps-2' => $contentGrid && $hasItemBeforeRecordContent, + 'ps-4' => $contentGrid && (! $hasItemBeforeRecordContent), + 'pe-2' => $contentGrid && $hasItemAfterRecordContent, + 'pe-4' => $contentGrid && (! $hasItemAfterRecordContent), + ]); + + $recordActionsClasses = \Illuminate\Support\Arr::toCssClasses([ + 'md:ps-3' => (! $contentGrid), + 'order-first' => $actionsPosition === ActionsPosition::BeforeColumns, + 'ps-3' => (! $contentGrid) && $hasItemBeforeRecordContent, + 'ps-4 sm:ps-6' => (! $contentGrid) && (! $hasItemBeforeRecordContent), + 'pe-3' => (! $contentGrid) && $hasItemAfterRecordContent, + 'pe-4 sm:pe-6' => (! $contentGrid) && (! $hasItemAfterRecordContent), + 'ps-2' => $contentGrid && $hasItemBeforeRecordContent, + 'ps-4' => $contentGrid && (! $hasItemBeforeRecordContent), + 'pe-2' => $contentGrid && $hasItemAfterRecordContent, + 'pe-4' => $contentGrid && (! $hasItemAfterRecordContent), + ]); + @endphp + +
(! $contentGrid) && $hasItemBeforeRecordContent, + 'pe-1 sm:pe-3' => (! $contentGrid) && $hasItemAfterRecordContent, + 'ps-1' => $contentGrid && $hasItemBeforeRecordContent, + 'pe-1' => $contentGrid && $hasItemAfterRecordContent, + ]) + > + @if ($isReordering) + + @elseif ($isSelectionEnabled && $isRecordSelectable($record)) + + @endif + + @php + $recordContentClasses = \Illuminate\Support\Arr::toCssClasses([ + $recordContentHorizontalPaddingClasses, + 'block w-full', + ]); + @endphp + +
! $contentGrid, + ]) + > +
+ @if ($recordUrl) + + + + @elseif ($recordAction) + @php + $recordWireClickAction = $getAction($recordAction) + ? "mountTableAction('{$recordAction}', '{$recordKey}')" + : $recordWireClickAction = "{$recordAction}('{$recordKey}')"; + @endphp + + + @else +
+ +
+ @endif + + @if ($hasCollapsibleColumnsLayout && (! $isReordering)) +
+ {{ $collapsibleColumnsLayout->viewData(['recordKey' => $recordKey]) }} +
+ @endif +
+ + @if ($recordHasActions) + + @endif +
+ + @if ($isRecordCollapsible) + + @endif +
+
+ + @php + $previousRecordGroupKey = $recordGroupKey; + $previousRecordGroupTitle = $recordGroupTitle; + $previousRecord = $record; + @endphp + @endforeach + + @if ($hasSummary && (! $isReordering) && filled($previousRecordGroupTitle) && ((! $records instanceof \Illuminate\Contracts\Pagination\Paginator) || (! $records->hasMorePages()))) + + + + @endif +
+ @endif + + @if (($content || $hasColumnsLayout) && $contentFooter) + {{ + $contentFooter->with([ + 'columns' => $columns, + 'records' => $records, + ]) + }} + @endif + + @if ($hasSummary && (! $isReordering)) + + + + @endif + @elseif (($records !== null) && count($records)) + + @if ($hasColumnGroups) + + @if ($isReordering) + + @else + @if (count($actions) && in_array($actionsPosition, [ActionsPosition::BeforeCells, ActionsPosition::BeforeColumns])) + + @endif + + @if ($isSelectionEnabled && $recordCheckboxPosition === RecordCheckboxPosition::BeforeCells) + + @endif + @endif + + @foreach ($columnsLayout as $columnGroup) + @if ($columnGroup instanceof Column) + @if ($columnGroup->isVisible() && (! $columnGroup->isToggledHidden())) + + @endif + @elseif ($columnGroup instanceof ColumnGroup) + @php + $columnGroupAlignment = $columnGroup->getAlignment(); + $columnGroupColumnsCount = count($columnGroup->getVisibleColumns()); + $isColumnGroupHeaderWrapped = $columnGroup->isHeaderWrapped(); + @endphp + + @if ($columnGroupColumnsCount) + getExtraHeaderAttributeBag()->class([ + 'fi-table-header-group-cell border-gray-200 px-3 py-2 dark:border-white/5 sm:first-of-type:ps-6 sm:last-of-type:pe-6 [&:not(:first-of-type)]:border-s [&:not(:last-of-type)]:border-e', + ]) + }} + > +
! $isColumnGroupHeaderWrapped, + 'whitespace-normal' => $isColumnGroupHeaderWrapped, + match ($columnGroupAlignment) { + Alignment::Start => 'justify-start', + Alignment::Center => 'justify-center', + Alignment::End => 'justify-end', + Alignment::Left => 'justify-start rtl:flex-row-reverse', + Alignment::Right => 'justify-end rtl:flex-row-reverse', + Alignment::Justify, Alignment::Between => 'justify-between', + default => $columnGroupAlignment, + }, + $getHiddenClasses($columnGroup), + ]) + > + + {{ $columnGroup->getLabel() }} + +
+ + @endif + @endif + @endforeach + + @if (! $isReordering) + @if (count($actions) && in_array($actionsPosition, [ActionsPosition::AfterColumns, ActionsPosition::AfterCells])) + + @endif + + @if ($isSelectionEnabled && $recordCheckboxPosition === RecordCheckboxPosition::AfterCells) + + @endif + @endif +
+ @endif + + + @if ($isReordering) + + @else + @if (count($actions) && $actionsPosition === ActionsPosition::BeforeCells) + @if ($actionsColumnLabel) + + {{ $actionsColumnLabel }} + + @else + + @endif + @endif + + @if ($isSelectionEnabled && $recordCheckboxPosition === RecordCheckboxPosition::BeforeCells) + + + + @endif + + @if (count($actions) && $actionsPosition === ActionsPosition::BeforeColumns) + @if ($actionsColumnLabel) + + {{ $actionsColumnLabel }} + + @else + + @endif + @endif + @endif + + @foreach ($columns as $column) + @php + $columnWidth = $column->getWidth(); + @endphp + + + {{ $column->getLabel() }} + + @endforeach + + @if (! $isReordering) + @if (count($actions) && $actionsPosition === ActionsPosition::AfterColumns) + @if ($actionsColumnLabel) + + {{ $actionsColumnLabel }} + + @else + + @endif + @endif + + @if ($isSelectionEnabled && $recordCheckboxPosition === RecordCheckboxPosition::AfterCells) + + + + @endif + + @if (count($actions) && $actionsPosition === ActionsPosition::AfterCells) + @if ($actionsColumnLabel) + + {{ $actionsColumnLabel }} + + @else + + @endif + @endif + @endif + + + @if ($isColumnSearchVisible) + + @if ($isReordering) + + @else + @if (count($actions) && in_array($actionsPosition, [ActionsPosition::BeforeCells, ActionsPosition::BeforeColumns])) + + @endif + + @if ($isSelectionEnabled && $recordCheckboxPosition === RecordCheckboxPosition::BeforeCells) + + @endif + @endif + + @foreach ($columns as $column) + getName())->camel()->kebab(), + 'px-3 py-2', + ]) + > + @if ($column->isIndividuallySearchable()) + + @endif + + @endforeach + + @if (! $isReordering) + @if (count($actions) && in_array($actionsPosition, [ActionsPosition::AfterColumns, ActionsPosition::AfterCells])) + + @endif + + @if ($isSelectionEnabled && $recordCheckboxPosition === RecordCheckboxPosition::AfterCells) + + @endif + @endif + + @endif + + @if (($records !== null) && count($records)) + @php + $isRecordRowStriped = false; + $previousRecord = null; + $previousRecordGroupKey = null; + $previousRecordGroupTitle = null; + @endphp + + @foreach ($records as $record) + @php + $recordAction = $getRecordAction($record); + $recordKey = $getRecordKey($record); + $recordUrl = $getRecordUrl($record); + $openRecordUrlInNewTab = $shouldOpenRecordUrlInNewTab($record); + $recordGroupKey = $group?->getStringKey($record); + $recordGroupTitle = $group?->getTitle($record); + @endphp + + @if ($recordGroupTitle !== $previousRecordGroupTitle) + @if ($hasSummary && (! $isReordering) && filled($previousRecordGroupTitle)) + + @endif + + @if (! $isGroupsOnly) + + @php + $groupHeaderColspan = $columnsCount; + + if ($isSelectionEnabled) { + $groupHeaderColspan--; + + if ( + ($recordCheckboxPosition === RecordCheckboxPosition::BeforeCells) && + count($actions) && + ($actionsPosition === ActionsPosition::BeforeCells) + ) { + $groupHeaderColspan--; + } + } + @endphp + + @if ($isSelectionEnabled && $recordCheckboxPosition === RecordCheckboxPosition::BeforeCells) + @if (count($actions) && $actionsPosition === ActionsPosition::BeforeCells) + + @endif + + + + + @endif + + + + + + @if ($isSelectionEnabled && $recordCheckboxPosition === RecordCheckboxPosition::AfterCells) + + + + @endif + + @endif + + @php + $isRecordRowStriped = false; + @endphp + @endif + + @if (! $isGroupsOnly) + $isReordering, + ...$getRecordClasses($record), + ]) + > + @if ($isReordering) + + + + @endif + + @if (count($actions) && $actionsPosition === ActionsPosition::BeforeCells && (! $isReordering)) + + + + @endif + + @if ($isSelectionEnabled && ($recordCheckboxPosition === RecordCheckboxPosition::BeforeCells) && (! $isReordering)) + + @if ($isRecordSelectable($record)) + + @endif + + @endif + + @if (count($actions) && $actionsPosition === ActionsPosition::BeforeColumns && (! $isReordering)) + + + + @endif + + @foreach ($columns as $column) + @php + $column->record($record); + $column->rowLoop($loop->parent); + @endphp + + + + + @endforeach + + @if (count($actions) && $actionsPosition === ActionsPosition::AfterColumns && (! $isReordering)) + + + + @endif + + @if ($isSelectionEnabled && $recordCheckboxPosition === RecordCheckboxPosition::AfterCells && (! $isReordering)) + + @if ($isRecordSelectable($record)) + + @endif + + @endif + + @if (count($actions) && $actionsPosition === ActionsPosition::AfterCells) + $isReordering, + ]) + > + + + @endif + + @endif + + @php + $isRecordRowStriped = ! $isRecordRowStriped; + $previousRecord = $record; + $previousRecordGroupKey = $recordGroupKey; + $previousRecordGroupTitle = $recordGroupTitle; + @endphp + @endforeach + + @if ($hasSummary && (! $isReordering) && filled($previousRecordGroupTitle) && ((! $records instanceof \Illuminate\Contracts\Pagination\Paginator) || (! $records->hasMorePages()))) + + @endif + + @if ($hasSummary && (! $isReordering)) + + @endif + + @if ($contentFooter) + + {{ + $contentFooter->with([ + 'columns' => $columns, + 'records' => $records, + ]) + }} + + @endif + @endif +
+ @elseif ($records === null) +
+ @elseif ($emptyState = $getEmptyState()) + {{ $emptyState }} + @else + + + + + + @endif +
+ + @if ((($records instanceof \Illuminate\Contracts\Pagination\Paginator) || ($records instanceof \Illuminate\Contracts\Pagination\CursorPaginator)) && + ((! ($records instanceof \Illuminate\Contracts\Pagination\LengthAwarePaginator)) || $records->total())) + + @endif + + @if ($hasFiltersBelowContent) + + @endif +
+ + +
From 534c582d312c94c633ccab2fa999cd1ca8790819 Mon Sep 17 00:00:00 2001 From: Alex Popa Date: Fri, 10 Jan 2025 12:10:39 +0200 Subject: [PATCH 3/3] move add sort column in roles migration before move case manager permission json in column migration --- ...e.php => 2024_11_07_005232_add_sort_column_in_roles_table.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename database/migrations/{2025_01_10_005232_add_sort_column_in_roles_table.php => 2024_11_07_005232_add_sort_column_in_roles_table.php} (100%) diff --git a/database/migrations/2025_01_10_005232_add_sort_column_in_roles_table.php b/database/migrations/2024_11_07_005232_add_sort_column_in_roles_table.php similarity index 100% rename from database/migrations/2025_01_10_005232_add_sort_column_in_roles_table.php rename to database/migrations/2024_11_07_005232_add_sort_column_in_roles_table.php