lunar icon indicating copy to clipboard operation
lunar copied to clipboard

Move default pagination to 20, 50, 100, all

Open lguichard opened this issue 2 years ago • 17 comments

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

lguichard avatar Dec 20 '23 13:12 lguichard

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lunar-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 11, 2024 8:41pm

vercel[bot] avatar Dec 20 '23 13:12 vercel[bot]

This does raise the question as to whether we should have "all" as a default option.

Some tables will have thousands of records and so "all" is likely to be quite dangerous.

glennjacobs avatar Dec 20 '23 13:12 glennjacobs

This does raise the question as to whether we should have "all" as a default option.

Some tables will have thousands of records and so "all" is likely to be quite dangerous.

I usually remove it from my Filament tables for that reason, so +1 from me.

adevade avatar Dec 20 '23 14:12 adevade

@glennjacobs correct, i will remove 'all' option. During my tests, 100 lines was the maximum for having a quick load.

lguichard avatar Dec 20 '23 15:12 lguichard

There's an open Filament issue re: large table performance: https://github.com/filamentphp/filament/issues/9304. The consensus there was 100 max as well.

@glennjacobs I remember you saying something about wrangling with Livewire performance when creating Lunar’s current datatables package. Maybe you've got some insights you could share in the Filament issue to help the team improve this?

binaryfire avatar Dec 20 '23 23:12 binaryfire

There's an open Filament issue re: large table performance: https://github.com/filamentphp/filament/issues/9304. The consensus there was 100 max as well.

@glennjacobs I remember you saying something about wrangling with Livewire performance when creating Lunar’s current datatables package. Maybe you've got some insights you could share in the Filament issue to help the team improve this?

The performance there was mainly Eloquent related which Filament v3 seems to have addressed pretty well. I agree, 100 max.

glennjacobs avatar Dec 21 '23 00:12 glennjacobs

can this be configurable or use extension

wychoong avatar Dec 22 '23 10:12 wychoong

@wychoong Exactly, i can create config/panel.php with configuration variables of panel and move pagination default. @alecritson Do you have planned separate issue with global configuration of panel ?

lguichard avatar Dec 22 '23 10:12 lguichard

I'm not keen on the config approach initially.

Having looked at Filament there doesn't appear to be a way to set the options globally.

I do wonder if Filament would consider a PR to allow pagination values to be set globally on the panel or something. I'd need to look at how doable that would be. Then it would be easy for a developer to change.

glennjacobs avatar Dec 22 '23 10:12 glennjacobs

You mean setting global pagination settings like this?

Ahha! I was searching for that and couldn't find it... that's exactly it.

So we could look to use that in our service provider, as long as devs can override it in their app service provider.

glennjacobs avatar Dec 22 '23 13:12 glennjacobs

Nice thanks @sandervankasteel

Vous voulez dire définir des paramètres de pagination globale comme celui-ci  ?

We have two solutions to implement the global settings table configuration :

First : we create a new options on LunarPanel Facade

      LunarPanel::configureTable(fn(Table $table) : void {
           // ...
        });

Second : Add on LunarPanelManger

        /*
        *   Default global settings for Page
        */
        Table::configureUsing(function (Table $table): void {
            $table
                ->paginationPageOptions([20, 50, 100]);
        });

For custom by devs :

    // AppServiceProvider.php 
    // ...
    public function register(): void
    {
        // Register panel
        LunarPanel::register();

        // Override panel
        LunarPanel::panel(fn($panel) =>
            $panel->path('lunar')
                ->brandName('My custom name')
        )
        ->register();

        // Override default configuration
        Table::configureUsing(function (Table $table): void {
            $table
                ->paginationPageOptions([1, 5, 2]);
        });
       // ...

What do we do ? @glennjacobs

lguichard avatar Dec 22 '23 17:12 lguichard

I would put the following in the Lunar service provider

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

and then test that a developer can override this is their own app service provider.

glennjacobs avatar Dec 22 '23 17:12 glennjacobs

@glennjacobs This will make all Filament tables (including non-Lunar ones) use these pagination options.

binaryfire avatar Dec 22 '23 17:12 binaryfire

@glennjacobs This will make all Filament tables (including non-Lunar ones) to use these pagination options.

Ah yes, that's a good point.

glennjacobs avatar Dec 22 '23 17:12 glennjacobs

I would put the following in the Lunar service provider

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

and then test that a developer can override this is their own app service provider.

That's it, i test override on AppServiceProvider works well

lguichard avatar Dec 22 '23 18:12 lguichard

Use the resource extension, and a global in lunar panel manager. So that a global can be set there, and control for each resources

wychoong avatar Dec 23 '23 00:12 wychoong