From 83f8c75e36f24f1158367c47fa2f15b7e057f335 Mon Sep 17 00:00:00 2001 From: Lionel Guichard Date: Wed, 20 Dec 2023 14:02:19 +0100 Subject: [PATCH 1/7] Move default pagination to 20, 50, 100, all --- packages/admin/src/Support/Pages/BaseListRecords.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/admin/src/Support/Pages/BaseListRecords.php b/packages/admin/src/Support/Pages/BaseListRecords.php index 9f59f3c3b5..202113b934 100644 --- a/packages/admin/src/Support/Pages/BaseListRecords.php +++ b/packages/admin/src/Support/Pages/BaseListRecords.php @@ -3,9 +3,18 @@ namespace Lunar\Admin\Support\Pages; use Filament\Resources\Pages\ListRecords; +use Filament\Tables\Table; abstract class BaseListRecords extends ListRecords { use Concerns\ExtendsHeaderActions; use \Lunar\Admin\Support\Concerns\CallsHooks; -} + + public function table(Table $table): Table + { + parent::table($table); + + return $table + ->paginated([20, 50, 100, 'all']); + } +} \ No newline at end of file From 229d7d7f87a02807bb795e379d3b79e8cdaa4100 Mon Sep 17 00:00:00 2001 From: Lionel Guichard Date: Wed, 20 Dec 2023 16:16:30 +0100 Subject: [PATCH 2/7] Remove all option --- packages/admin/src/Support/Pages/BaseListRecords.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/admin/src/Support/Pages/BaseListRecords.php b/packages/admin/src/Support/Pages/BaseListRecords.php index 202113b934..515f5aefd3 100644 --- a/packages/admin/src/Support/Pages/BaseListRecords.php +++ b/packages/admin/src/Support/Pages/BaseListRecords.php @@ -15,6 +15,6 @@ public function table(Table $table): Table parent::table($table); return $table - ->paginated([20, 50, 100, 'all']); + ->paginated([20, 50, 100]); } } \ No newline at end of file From 415358aad2e9a1058c04be9fe805823a53f15eed Mon Sep 17 00:00:00 2001 From: Lionel Guichard Date: Fri, 22 Dec 2023 11:16:34 +0100 Subject: [PATCH 3/7] Code style --- packages/admin/src/Support/Pages/BaseListRecords.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/admin/src/Support/Pages/BaseListRecords.php b/packages/admin/src/Support/Pages/BaseListRecords.php index 515f5aefd3..447a2318c9 100644 --- a/packages/admin/src/Support/Pages/BaseListRecords.php +++ b/packages/admin/src/Support/Pages/BaseListRecords.php @@ -12,9 +12,6 @@ abstract class BaseListRecords extends ListRecords public function table(Table $table): Table { - parent::table($table); - - return $table - ->paginated([20, 50, 100]); + return parent::table($table)->paginated([20, 50, 100]); } } \ No newline at end of file From 221b65977a1e42803248f0358c06ea46cd717901 Mon Sep 17 00:00:00 2001 From: lguichard Date: Fri, 22 Dec 2023 19:39:37 +0100 Subject: [PATCH 4/7] Move changes on provider --- packages/admin/src/LunarPanelManager.php | 7 +++++++ packages/admin/src/Support/Pages/BaseListRecords.php | 5 ----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/admin/src/LunarPanelManager.php b/packages/admin/src/LunarPanelManager.php index ce5f215d83..d7d6d0b273 100644 --- a/packages/admin/src/LunarPanelManager.php +++ b/packages/admin/src/LunarPanelManager.php @@ -12,6 +12,7 @@ use Filament\Support\Colors\Color; use Filament\Support\Facades\FilamentColor; use Filament\Support\Facades\FilamentIcon; +use Filament\Tables\Table; use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse; use Illuminate\Cookie\Middleware\EncryptCookies; use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken; @@ -128,6 +129,12 @@ public function register(): self 'chartSecondary' => Color::Green, ]); + Table::configureUsing(function (Table $table): void { + $table + ->paginationPageOptions([20, 50, 100]) + ->defaultPaginationPageOption(20); + }); + return $this; } diff --git a/packages/admin/src/Support/Pages/BaseListRecords.php b/packages/admin/src/Support/Pages/BaseListRecords.php index 447a2318c9..ccfc9ce11e 100644 --- a/packages/admin/src/Support/Pages/BaseListRecords.php +++ b/packages/admin/src/Support/Pages/BaseListRecords.php @@ -9,9 +9,4 @@ abstract class BaseListRecords extends ListRecords { use Concerns\ExtendsHeaderActions; use \Lunar\Admin\Support\Concerns\CallsHooks; - - public function table(Table $table): Table - { - return parent::table($table)->paginated([20, 50, 100]); - } } \ No newline at end of file From 00d6bf868979f20c50617e3b3bde6e80d356beca Mon Sep 17 00:00:00 2001 From: Glenn Jacobs Date: Mon, 11 Mar 2024 20:28:18 +0000 Subject: [PATCH 5/7] Update OrderResource.php --- packages/admin/src/Filament/Resources/OrderResource.php | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/admin/src/Filament/Resources/OrderResource.php b/packages/admin/src/Filament/Resources/OrderResource.php index 871c2b1d22..b6380f963b 100644 --- a/packages/admin/src/Filament/Resources/OrderResource.php +++ b/packages/admin/src/Filament/Resources/OrderResource.php @@ -72,7 +72,6 @@ public static function getDefaultTable(Table $table): Table ]) ->filters(static::getTableFilters()) ->defaultSort('id', 'DESC') - ->paginated([10, 25, 50, 100]) ->selectCurrentPageOnly() ->deferLoading() ->poll('60s'); From c445165450dfe49b47f10f9b2032e52b3a84d46a Mon Sep 17 00:00:00 2001 From: Glenn Jacobs Date: Mon, 11 Mar 2024 20:30:03 +0000 Subject: [PATCH 6/7] Update LunarPanelManager.php --- packages/admin/src/LunarPanelManager.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/admin/src/LunarPanelManager.php b/packages/admin/src/LunarPanelManager.php index 19aedd9747..d9e51efa55 100644 --- a/packages/admin/src/LunarPanelManager.php +++ b/packages/admin/src/LunarPanelManager.php @@ -146,10 +146,10 @@ public function register(): self Table::configureUsing(function (Table $table): void { $table - ->paginationPageOptions([20, 50, 100]) - ->defaultPaginationPageOption(20); + ->paginationPageOptions([10, 25, 50, 100]) + ->defaultPaginationPageOption(25); }); - + return $this; } From 81d75706cc80eb828c4f417799ed98afaf40f309 Mon Sep 17 00:00:00 2001 From: Glenn Jacobs Date: Mon, 11 Mar 2024 20:41:17 +0000 Subject: [PATCH 7/7] Make all list pages use paginate --- .../Resources/ProductResource/Pages/ListProducts.php | 5 ----- packages/admin/src/Support/Pages/BaseListRecords.php | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/admin/src/Filament/Resources/ProductResource/Pages/ListProducts.php b/packages/admin/src/Filament/Resources/ProductResource/Pages/ListProducts.php index 9846d55f9d..105ba6a5aa 100644 --- a/packages/admin/src/Filament/Resources/ProductResource/Pages/ListProducts.php +++ b/packages/admin/src/Filament/Resources/ProductResource/Pages/ListProducts.php @@ -91,11 +91,6 @@ public function getTabs(): array ]; } - protected function paginateTableQuery(Builder $query): Paginator - { - return $query->simplePaginate($this->getTableRecordsPerPage()); - } - public function getMaxContentWidth(): MaxWidth { return MaxWidth::Full; diff --git a/packages/admin/src/Support/Pages/BaseListRecords.php b/packages/admin/src/Support/Pages/BaseListRecords.php index 2e978ec95a..42d2821b82 100644 --- a/packages/admin/src/Support/Pages/BaseListRecords.php +++ b/packages/admin/src/Support/Pages/BaseListRecords.php @@ -3,6 +3,7 @@ namespace Lunar\Admin\Support\Pages; use Filament\Resources\Pages\ListRecords; +use Illuminate\Contracts\Pagination\Paginator; use Illuminate\Database\Eloquent\Builder; use Lunar\Base\Traits\Searchable; @@ -49,4 +50,9 @@ protected function applySearchToTableQuery(Builder $query): Builder return $query; } + + protected function paginateTableQuery(Builder $query): Paginator + { + return $query->paginate($this->getTableRecordsPerPage()); + } }