mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Merge pull request #12826 from bensondevs/3.x
Feat: Adding grouping direction hidden method for the table grouping
This commit is contained in:
@@ -337,3 +337,18 @@ public function table(Table $table): Table
|
||||
->groupingSettingsHidden();
|
||||
}
|
||||
```
|
||||
|
||||
### Hiding the grouping direction setting only
|
||||
|
||||
You can hide the grouping direction select interface using the `groupingDirectionSettingHidden()` method:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultGroup('status');
|
||||
->groupingDirectionSettingHidden();
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@props([
|
||||
'directionSetting' => false,
|
||||
'dropdownOnDesktop' => false,
|
||||
'groups',
|
||||
'triggerAction',
|
||||
@@ -71,23 +72,24 @@
|
||||
</x-filament::input.wrapper>
|
||||
</label>
|
||||
|
||||
<label x-cloak x-show="group" class="grid gap-y-2">
|
||||
<span class="{{ $labelClasses }}">
|
||||
{{ __('filament-tables::table.grouping.fields.direction.label') }}
|
||||
</span>
|
||||
@if (! $directionSetting)
|
||||
<label x-cloak x-show="group" class="grid gap-y-2">
|
||||
<span class="{{ $labelClasses }}">
|
||||
{{ __('filament-tables::table.grouping.fields.direction.label') }}
|
||||
</span>
|
||||
<x-filament::input.wrapper>
|
||||
<x-filament::input.select x-model="direction">
|
||||
<option value="asc">
|
||||
{{ __('filament-tables::table.grouping.fields.direction.options.asc') }}
|
||||
</option>
|
||||
|
||||
<x-filament::input.wrapper>
|
||||
<x-filament::input.select x-model="direction">
|
||||
<option value="asc">
|
||||
{{ __('filament-tables::table.grouping.fields.direction.options.asc') }}
|
||||
</option>
|
||||
|
||||
<option value="desc">
|
||||
{{ __('filament-tables::table.grouping.fields.direction.options.desc') }}
|
||||
</option>
|
||||
</x-filament::input.select>
|
||||
</x-filament::input.wrapper>
|
||||
</label>
|
||||
<option value="desc">
|
||||
{{ __('filament-tables::table.grouping.fields.direction.options.desc') }}
|
||||
</option>
|
||||
</x-filament::input.select>
|
||||
</x-filament::input.wrapper>
|
||||
</label>
|
||||
@endif
|
||||
</div>
|
||||
</x-filament::dropdown>
|
||||
|
||||
@@ -116,23 +118,24 @@
|
||||
</x-filament::input.wrapper>
|
||||
</label>
|
||||
|
||||
<label x-cloak x-show="group">
|
||||
<span class="sr-only">
|
||||
{{ __('filament-tables::table.grouping.fields.direction.label') }}
|
||||
</span>
|
||||
@if (! $directionSetting)
|
||||
<label x-cloak x-show="group">
|
||||
<span class="sr-only">
|
||||
{{ __('filament-tables::table.grouping.fields.direction.label') }}
|
||||
</span>
|
||||
<x-filament::input.wrapper>
|
||||
<x-filament::input.select x-model="direction">
|
||||
<option value="asc">
|
||||
{{ __('filament-tables::table.grouping.fields.direction.options.asc') }}
|
||||
</option>
|
||||
|
||||
<x-filament::input.wrapper>
|
||||
<x-filament::input.select x-model="direction">
|
||||
<option value="asc">
|
||||
{{ __('filament-tables::table.grouping.fields.direction.options.asc') }}
|
||||
</option>
|
||||
|
||||
<option value="desc">
|
||||
{{ __('filament-tables::table.grouping.fields.direction.options.desc') }}
|
||||
</option>
|
||||
</x-filament::input.select>
|
||||
</x-filament::input.wrapper>
|
||||
</label>
|
||||
<option value="desc">
|
||||
{{ __('filament-tables::table.grouping.fields.direction.options.desc') }}
|
||||
</option>
|
||||
</x-filament::input.select>
|
||||
</x-filament::input.wrapper>
|
||||
</label>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
$isReorderable = $isReorderable();
|
||||
$isReordering = $isReordering();
|
||||
$areGroupingSettingsVisible = (! $isReordering) && count($groups) && (! $areGroupingSettingsHidden());
|
||||
$isGroupingDirectionSettingHidden = $isGroupingDirectionSettingHidden();
|
||||
$isColumnSearchVisible = $isSearchableByColumn();
|
||||
$isGlobalSearchVisible = $isSearchable();
|
||||
$isSearchOnBlur = $isSearchOnBlur();
|
||||
@@ -195,6 +196,7 @@
|
||||
|
||||
@if ($areGroupingSettingsVisible)
|
||||
<x-filament-tables::groups
|
||||
:direction-setting="$isGroupingDirectionSettingHidden"
|
||||
:dropdown-on-desktop="$areGroupingSettingsInDropdownOnDesktop()"
|
||||
:groups="$groups"
|
||||
:trigger-action="$getGroupRecordsTriggerAction()"
|
||||
|
||||
@@ -23,6 +23,8 @@ trait CanGroupRecords
|
||||
|
||||
protected bool | Closure $areGroupingSettingsHidden = false;
|
||||
|
||||
protected bool | Closure $isGroupingDirectionSettingHidden = false;
|
||||
|
||||
protected ?Closure $modifyGroupRecordsTriggerActionUsing = null;
|
||||
|
||||
public function groupRecordsTriggerAction(?Closure $callback): static
|
||||
@@ -56,6 +58,13 @@ trait CanGroupRecords
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function groupingDirectionSettingHidden(bool | Closure $condition = true): static
|
||||
{
|
||||
$this->isGroupingDirectionSettingHidden = $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function defaultGroup(string | Group | null $group): static
|
||||
{
|
||||
$this->defaultGroup = $group;
|
||||
@@ -130,6 +139,11 @@ trait CanGroupRecords
|
||||
return (bool) $this->evaluate($this->areGroupingSettingsHidden);
|
||||
}
|
||||
|
||||
public function isGroupingDirectionSettingHidden(): bool
|
||||
{
|
||||
return (bool) $this->evaluate($this->isGroupingDirectionSettingHidden);
|
||||
}
|
||||
|
||||
public function getDefaultGroup(): ?Group
|
||||
{
|
||||
if ($this->defaultGroup === null) {
|
||||
|
||||
Reference in New Issue
Block a user