Skip to content

Commit 7fae8ec

Browse files
committed
chore: improve sorting reordering for property values
1 parent 799c9b9 commit 7fae8ec

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

src/Filament/Resources/PropertyValueResource.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,21 @@ public static function table(Table $table): Table
126126
]);
127127

128128
if ($property && $property->enable_sorting) {
129-
$table = $table->reorderable('sort')->defaultSort('sort');
129+
$table = $table
130+
->reorderable('sort')
131+
->defaultSort('sort')
132+
->reorderRecordsTriggerAction(
133+
fn (Tables\Actions\Action $action, bool $isReordering) => $action
134+
->button()
135+
->label($isReordering ? 'Disable reordering' : 'Enable reordering')
136+
->icon($isReordering ? 'heroicon-o-x-mark' : 'heroicon-o-arrows-up-down')
137+
->color($isReordering ? 'danger' : 'primary')
138+
);
130139
} else {
131140
$table = $table->defaultSort('value');
132141
}
133142

134-
return $table
135-
->modifyQueryUsing(function (Builder $query) {
136-
if (request()->has('property')) {
137-
$query->where('property_id', request('property'));
138-
}
139-
});
143+
return $table;
140144
}
141145

142146
public static function getPages(): array

0 commit comments

Comments
 (0)