Skip to content

Commit a62697c

Browse files
committed
Merge branch 'feature/add_content_sorting_options' into 1.x
* feature/add_content_sorting_options: feat: Add "order" column for ContentTable, and set its as default sort column
2 parents 082e049 + 4502ff6 commit a62697c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Filament/Resources/ContentResource.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
use SolutionForest\InspireCms\Models\Contracts\Content as ModelsContent;
4646
use SolutionForest\InspireCms\Support\Helpers\KeyHelper;
4747
use SolutionForest\InspireCms\Support\MediaLibrary\Forms\Components\MediaPicker;
48+
use SolutionForest\InspireCms\Support\Models\Scopes\NestableTreeDetailScope;
4849

4950
class ContentResource extends Resource implements ClusterSectionResource
5051
{
@@ -251,9 +252,11 @@ public static function getPreviewBuilderEditorSchema(string $builderName): Forms
251252
public static function table(Table $table): Table
252253
{
253254
return $table
254-
->defaultSort('created_at', 'desc')
255+
->defaultSort('nestable_tree_order', 'asc')
255256
->modifyQueryUsing(function ($query, $livewire) {
256-
$query->with('publishedVersions');
257+
$query
258+
->with('publishedVersions')
259+
->withGlobalScope(NestableTreeDetailScope::class, new NestableTreeDetailScope);
257260
if ($livewire instanceof ChildrenRelationManager) {
258261
$query->with('parent');
259262
}
@@ -295,6 +298,11 @@ public static function table(Table $table): Table
295298
->fontFamily('mono')
296299
->limit(20)->tooltip(fn ($state) => $state),
297300

301+
Tables\Columns\TextColumn::make('nestable_tree_order')
302+
->label(__('inspirecms::inspirecms.order'))
303+
->sortable()
304+
->toggleable(),
305+
298306
Tables\Columns\TextColumn::make('parent')
299307
->label(__('inspirecms::resources/content.parent.label'))
300308
->getStateUsing(function (Model | ModelsContent $record) {

0 commit comments

Comments
 (0)