Skip to content

Commit

Permalink
Merge pull request #22 from Log1x/enhance/improve-menu-location-empty…
Browse files Browse the repository at this point in the history
…-state

💄 Improve menu location empty state
  • Loading branch information
datlechin authored Aug 20, 2024
2 parents 4d515a8 + e1d3bf4 commit 7793796
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
3 changes: 3 additions & 0 deletions resources/lang/en/menu-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
'label' => 'Assigned Menu',
],
],
'empty' => [
'heading' => 'No locations registered',
],
],
],
'items' => [
Expand Down
3 changes: 3 additions & 0 deletions resources/lang/vi/menu-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
'label' => 'Menu đã gán',
],
],
'empty' => [
'heading' => 'Không có vị trí nào được đăng ký',
],
],
],
'items' => [
Expand Down
11 changes: 0 additions & 11 deletions resources/views/components/empty-state.blade.php

This file was deleted.

11 changes: 9 additions & 2 deletions src/Concerns/HasLocationAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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([
Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/Livewire/MenuPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 7793796

Please sign in to comment.