Skip to content

Commit

Permalink
Move default pagination to 20, 50, 100, all (#1400)
Browse files Browse the repository at this point in the history
Currently, the default pagination use Filament default configuration. I
purpose to change this

It is more ergonomic and useful, show the products and items in a trice

---------

Co-authored-by: Alec Ritson <[email protected]>
Co-authored-by: Glenn Jacobs <[email protected]>
  • Loading branch information
3 people authored Mar 11, 2024
1 parent ce0e103 commit 6240b3c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
1 change: 0 additions & 1 deletion packages/admin/src/Filament/Resources/OrderResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions packages/admin/src/LunarPanelManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,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;
Expand Down Expand Up @@ -143,6 +144,12 @@ public function register(): self
'chartSecondary' => Color::Green,
]);

Table::configureUsing(function (Table $table): void {
$table
->paginationPageOptions([10, 25, 50, 100])
->defaultPaginationPageOption(25);
});

return $this;
}

Expand Down
6 changes: 6 additions & 0 deletions packages/admin/src/Support/Pages/BaseListRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -49,4 +50,9 @@ protected function applySearchToTableQuery(Builder $query): Builder

return $query;
}

protected function paginateTableQuery(Builder $query): Paginator
{
return $query->paginate($this->getTableRecordsPerPage());
}
}

0 comments on commit 6240b3c

Please sign in to comment.