diff --git a/resources/lang/en/menu-builder.php b/resources/lang/en/menu-builder.php index adda2bf..61a7d52 100644 --- a/resources/lang/en/menu-builder.php +++ b/resources/lang/en/menu-builder.php @@ -37,6 +37,9 @@ 'label' => 'Assigned Menu', ], ], + 'empty' => [ + 'heading' => 'No locations registered', + ], ], ], 'items' => [ diff --git a/resources/lang/vi/menu-builder.php b/resources/lang/vi/menu-builder.php index d79f0ff..81ff5a7 100644 --- a/resources/lang/vi/menu-builder.php +++ b/resources/lang/vi/menu-builder.php @@ -37,6 +37,9 @@ 'label' => 'Menu đã gán', ], ], + 'empty' => [ + 'heading' => 'Không có vị trí nào được đăng ký', + ], ], ], 'items' => [ diff --git a/resources/views/components/empty-state.blade.php b/resources/views/components/empty-state.blade.php deleted file mode 100644 index 62261d4..0000000 --- a/resources/views/components/empty-state.blade.php +++ /dev/null @@ -1,11 +0,0 @@ -@props([ - 'heading' => __('filament-menu-builder::menu-builder.panel.empty.heading'), - 'description' => __('filament-menu-builder::menu-builder.panel.empty.description'), - 'icon' => 'heroicon-o-link-slash', -]) - - diff --git a/src/Concerns/HasLocationAction.php b/src/Concerns/HasLocationAction.php index 42ef536..d41385e 100644 --- a/src/Concerns/HasLocationAction.php +++ b/src/Concerns/HasLocationAction.php @@ -22,6 +22,7 @@ public function getLocationAction(): Action ->modalDescription(__('filament-menu-builder::menu-builder.actions.locations.description')) ->modalSubmitActionLabel(__('filament-menu-builder::menu-builder.actions.locations.submit')) ->modalWidth(MaxWidth::Large) + ->modalSubmitAction($this->getRegisteredLocations()->isEmpty() ? false : null) ->color('gray') ->fillForm(fn () => $this->getRegisteredLocations()->map(fn ($location, $key) => [ 'location' => $location, @@ -55,7 +56,7 @@ public function getLocationAction(): Action ->success() ->send(); }) - ->form(fn () => $this->getRegisteredLocations()->map( + ->form($this->getRegisteredLocations()->map( fn ($location, $key) => Components\Grid::make(2) ->statePath($key) ->schema([ @@ -70,7 +71,13 @@ public function getLocationAction(): Action ->hiddenLabel($key !== $this->getRegisteredLocations()->keys()->first()) ->options($this->getModel()::all()->pluck('name', 'id')->all()), ]) - )->all()); + )->all() ?: [ + Components\View::make('filament-tables::components.empty-state.index') + ->viewData([ + 'heading' => __('filament-menu-builder::menu-builder.actions.locations.empty.heading'), + 'icon' => 'heroicon-o-x-mark', + ]), + ]); } protected function getMenuLocations(): Collection diff --git a/src/Livewire/MenuPanel.php b/src/Livewire/MenuPanel.php index 90c7b6e..b82f53d 100644 --- a/src/Livewire/MenuPanel.php +++ b/src/Livewire/MenuPanel.php @@ -106,7 +106,12 @@ public function form(Form $form): Form return $form ->schema([ - Components\View::make('filament-menu-builder::components.empty-state') + Components\View::make('filament-tables::components.empty-state.index') + ->viewData([ + 'heading' => __('filament-menu-builder::menu-builder.panel.empty.heading'), + 'description' => __('filament-menu-builder::menu-builder.panel.empty.description'), + 'icon' => 'heroicon-o-link-slash', + ]) ->visible($items->isEmpty()), Components\CheckboxList::make('data')