|
5 | 5 | use Filament\Actions\CreateAction;
|
6 | 6 | use Filament\Actions\LocaleSwitcher;
|
7 | 7 | use Illuminate\Database\Eloquent\Model;
|
| 8 | +use Illuminate\Support\HtmlString; |
8 | 9 | use SolutionForest\FilamentTree\Actions\DeleteAction;
|
9 | 10 | use SolutionForest\FilamentTree\Actions\EditAction;
|
10 | 11 | use SolutionForest\FilamentTree\Concern\TreeRecords\Translatable;
|
@@ -39,11 +40,6 @@ public function getModel(): string
|
39 | 40 | return FilamentFlexibleContentBlockPages::config()->getMenuItemModel()::class;
|
40 | 41 | }
|
41 | 42 |
|
42 |
| - public function getTranslatableLocales(): array |
43 |
| - { |
44 |
| - return static::getResource()::getTranslatableLocales(); |
45 |
| - } |
46 |
| - |
47 | 43 | public function getTitle(): string
|
48 | 44 | {
|
49 | 45 | return flexiblePagesTrans('menu_items.manage.title', [
|
@@ -111,6 +107,42 @@ public function getTreeRecordTitle(?Model $record = null): string
|
111 | 107 | return $record->getDisplayLabel($locale);
|
112 | 108 | }
|
113 | 109 |
|
| 110 | + public function getTreeRecordDescription(?Model $record = null): string|HtmlString|null |
| 111 | + { |
| 112 | + /** @var MenuItem $record */ |
| 113 | + if (! $record) { |
| 114 | + return null; |
| 115 | + } |
| 116 | + |
| 117 | + $description = $this->getMenuItemTypeDescription($record); |
| 118 | + |
| 119 | + // Add visibility indicator if hidden |
| 120 | + if (! $record->is_visible) { |
| 121 | + $hiddenText = flexiblePagesTrans('menu_items.status.hidden'); |
| 122 | + $eyeSlashIcon = svg('heroicon-o-eye-slash', 'w-4 h-4 inline text-warning-600 dark:text-warning-400')->toHtml(); |
| 123 | + $description .= " • <span class=\"text-warning-600 dark:text-warning-400\">{$eyeSlashIcon} {$hiddenText}</span>"; |
| 124 | + } |
| 125 | + |
| 126 | + return new HtmlString($description); |
| 127 | + } |
| 128 | + |
| 129 | + protected function getMenuItemTypeDescription(MenuItem $record): string |
| 130 | + { |
| 131 | + if ($record->linkable_type && $record->linkable) { |
| 132 | + return flexiblePagesTrans('menu_items.tree.linked_to') . ' ' . class_basename($record->linkable_type); |
| 133 | + } |
| 134 | + |
| 135 | + if ($record->url) { |
| 136 | + return flexiblePagesTrans('menu_items.tree.external_url') . ': ' . $record->url; |
| 137 | + } |
| 138 | + |
| 139 | + if ($record->route) { |
| 140 | + return flexiblePagesTrans('menu_items.tree.route') . ': ' . $record->route; |
| 141 | + } |
| 142 | + |
| 143 | + return flexiblePagesTrans('menu_items.tree.no_link'); |
| 144 | + } |
| 145 | + |
114 | 146 | public function getTreeRecordIcon(?\Illuminate\Database\Eloquent\Model $record = null): ?string
|
115 | 147 | {
|
116 | 148 | // TODO
|
|
0 commit comments