|
45 | 45 | use SolutionForest\InspireCms\Models\Contracts\Content as ModelsContent; |
46 | 46 | use SolutionForest\InspireCms\Support\Helpers\KeyHelper; |
47 | 47 | use SolutionForest\InspireCms\Support\MediaLibrary\Forms\Components\MediaPicker; |
| 48 | +use SolutionForest\InspireCms\Support\Models\Scopes\NestableTreeDetailScope; |
48 | 49 |
|
49 | 50 | class ContentResource extends Resource implements ClusterSectionResource |
50 | 51 | { |
@@ -251,9 +252,11 @@ public static function getPreviewBuilderEditorSchema(string $builderName): Forms |
251 | 252 | public static function table(Table $table): Table |
252 | 253 | { |
253 | 254 | return $table |
254 | | - ->defaultSort('created_at', 'desc') |
| 255 | + ->defaultSort('nestable_tree_order', 'asc') |
255 | 256 | ->modifyQueryUsing(function ($query, $livewire) { |
256 | | - $query->with('publishedVersions'); |
| 257 | + $query |
| 258 | + ->with('publishedVersions') |
| 259 | + ->withGlobalScope(NestableTreeDetailScope::class, new NestableTreeDetailScope); |
257 | 260 | if ($livewire instanceof ChildrenRelationManager) { |
258 | 261 | $query->with('parent'); |
259 | 262 | } |
@@ -295,6 +298,11 @@ public static function table(Table $table): Table |
295 | 298 | ->fontFamily('mono') |
296 | 299 | ->limit(20)->tooltip(fn ($state) => $state), |
297 | 300 |
|
| 301 | + Tables\Columns\TextColumn::make('nestable_tree_order') |
| 302 | + ->label(__('inspirecms::inspirecms.order')) |
| 303 | + ->sortable() |
| 304 | + ->toggleable(), |
| 305 | + |
298 | 306 | Tables\Columns\TextColumn::make('parent') |
299 | 307 | ->label(__('inspirecms::resources/content.parent.label')) |
300 | 308 | ->getStateUsing(function (Model | ModelsContent $record) { |
|
0 commit comments