From 48f329ff2544e1e8ee469932dc7f38672f3a7fb5 Mon Sep 17 00:00:00 2001 From: Tieme Alberts <52133032+sitenzo@users.noreply.github.com> Date: Tue, 28 Nov 2023 21:53:27 +0100 Subject: [PATCH 1/6] Update QuickCreatePlugin.php Added sortBy --- src/QuickCreatePlugin.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/QuickCreatePlugin.php b/src/QuickCreatePlugin.php index b7d710f..8b44523 100644 --- a/src/QuickCreatePlugin.php +++ b/src/QuickCreatePlugin.php @@ -94,12 +94,13 @@ public function getResources(): array 'action_name' => $actionName, 'action' => ! $resource->hasPage('create') ? 'mountAction(\'' . $actionName . '\')' : null, 'url' => $resource->hasPage('create') ? $resource::getUrl('create') : null, + 'navigationsort' => $resource->getNavigationSort() ]; } return null; }) - ->when($this->isSortable(), fn ($collection) => $collection->sortBy('label')) + ->when($this->isSortable(), fn ($collection) => $collection->sortBy($this->sortBy)) ->values() ->toArray(); @@ -150,4 +151,15 @@ public function sort(bool | Closure $condition = true): static return $this; } + + public function sortBy(string | Closure $sortBy = 'label'): static + { + if(!in_array(['label','navigation'])){ + $sortBy = 'label'; + } + + $this->sortBy = $sortBy; + + return $this; + } } From 8c2c3b06833b92c8c568df7b53a53472dd799eb2 Mon Sep 17 00:00:00 2001 From: Tieme Alberts <52133032+sitenzo@users.noreply.github.com> Date: Tue, 28 Nov 2023 21:54:26 +0100 Subject: [PATCH 2/6] Update QuickCreatePlugin.php Typo --- src/QuickCreatePlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/QuickCreatePlugin.php b/src/QuickCreatePlugin.php index 8b44523..9714900 100644 --- a/src/QuickCreatePlugin.php +++ b/src/QuickCreatePlugin.php @@ -94,7 +94,7 @@ public function getResources(): array 'action_name' => $actionName, 'action' => ! $resource->hasPage('create') ? 'mountAction(\'' . $actionName . '\')' : null, 'url' => $resource->hasPage('create') ? $resource::getUrl('create') : null, - 'navigationsort' => $resource->getNavigationSort() + 'navigation' => $resource->getNavigationSort() ]; } From 3751f797532d3cb40f0d7e7a7be5642b3409743d Mon Sep 17 00:00:00 2001 From: Tieme Alberts <52133032+sitenzo@users.noreply.github.com> Date: Tue, 28 Nov 2023 21:57:41 +0100 Subject: [PATCH 3/6] Update README.md --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 650857d..aeb9e53 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ public function panel(Panel $panel): Panel ### Sorting -By default, Quick Create will sort all the displayed options in descending order. This can be disabled should you choose. In which case they will be displayed in the order they are registered with Filament. +By default, Quick Create will sort all the displayed options in descending order by Label. This can be disabled should you choose. In which case they will be displayed in the order they are registered with Filament. ```php use Awcodes\FilamentQuickCreate\QuickCreatePlugin; @@ -101,6 +101,23 @@ public function panel(Panel $panel): Panel } ``` +### Sorting by recourse navigation + +By default, Quick Create will sort all the displayed options by Label. This can be changed to resource navigation sort should you choose. In which case they will be displayed in the order they are displayed in de navigation. + +```php +use Awcodes\FilamentQuickCreate\QuickCreatePlugin; + +public function panel(Panel $panel): Panel +{ + return $panel + ->plugins([ + QuickCreatePlugin::make() + ->sortBy('navigation'), + ]) +} +``` + ### Slide Overs By default, Quick Create will render simple resources in a standard modal. If you would like to render them in a slide over instead you may use the `slideOver()` modifier to do so. From cce9bc87d20986f37bee0d2d59e3a2899fa829f6 Mon Sep 17 00:00:00 2001 From: Tieme Alberts <52133032+sitenzo@users.noreply.github.com> Date: Thu, 30 Nov 2023 21:42:38 +0100 Subject: [PATCH 4/6] Update QuickCreatePlugin.php --- src/QuickCreatePlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/QuickCreatePlugin.php b/src/QuickCreatePlugin.php index 9714900..4878782 100644 --- a/src/QuickCreatePlugin.php +++ b/src/QuickCreatePlugin.php @@ -154,7 +154,7 @@ public function sort(bool | Closure $condition = true): static public function sortBy(string | Closure $sortBy = 'label'): static { - if(!in_array(['label','navigation'])){ + if(!in_array($sortBy, ['label','navigation'])){ $sortBy = 'label'; } From b9046fe69252857f3d206c8af0f72de7f0ff1380 Mon Sep 17 00:00:00 2001 From: Tieme Alberts <52133032+sitenzo@users.noreply.github.com> Date: Thu, 30 Nov 2023 21:44:27 +0100 Subject: [PATCH 5/6] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aeb9e53..e651974 100644 --- a/README.md +++ b/README.md @@ -101,9 +101,9 @@ public function panel(Panel $panel): Panel } ``` -### Sorting by recourse navigation +### Sorting by resource navigation -By default, Quick Create will sort all the displayed options by Label. This can be changed to resource navigation sort should you choose. In which case they will be displayed in the order they are displayed in de navigation. +By default, Quick Create will sort all the displayed options by Label. This can be changed to resource navigation sort should you choose. In which case they will be displayed in the order they are displayed in the navigation. ```php use Awcodes\FilamentQuickCreate\QuickCreatePlugin; From 0861dadadca3bc1babda7dc9d08cd991ec1d2d8d Mon Sep 17 00:00:00 2001 From: Tieme Alberts <52133032+sitenzo@users.noreply.github.com> Date: Thu, 30 Nov 2023 21:45:42 +0100 Subject: [PATCH 6/6] Update QuickCreatePlugin.php --- src/QuickCreatePlugin.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/QuickCreatePlugin.php b/src/QuickCreatePlugin.php index 4878782..9b5e8fe 100644 --- a/src/QuickCreatePlugin.php +++ b/src/QuickCreatePlugin.php @@ -25,6 +25,8 @@ class QuickCreatePlugin implements Plugin protected bool | Closure | null $shouldUseSlideOver = null; + protected string | Closure $sortBy = 'label'; + public function boot(Panel $panel): void { Livewire::component('quick-create-menu', Components\QuickCreateMenu::class);