Skip to content

Commit

Permalink
Merge branch 'main' into enhance/configurable-models
Browse files Browse the repository at this point in the history
  • Loading branch information
Log1x authored Aug 20, 2024
2 parents 484117f + 7793796 commit c7b2acb
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 15 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 @@ -21,6 +21,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 @@ -54,7 +55,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 @@ -69,7 +70,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
3 changes: 2 additions & 1 deletion src/Models/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Datlechin\FilamentMenuBuilder\Models;

use Datlechin\FilamentMenuBuilder\FilamentMenuBuilderPlugin;
use Illuminate\Contracts\Database\Query\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

Expand Down Expand Up @@ -41,7 +42,7 @@ public function menuItems(): HasMany
public static function location(string $location): ?self
{
return FilamentMenuBuilderPlugin::get()
->getMenuLocationModel()::with('menu')
->getMenuLocationModel()::with(['menu' => fn (Builder $query) => $query->where('is_visible', true)])
->where('location', $location)
->first()?->menu;
}
Expand Down

0 comments on commit c7b2acb

Please sign in to comment.