Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List Draft/Revisions in a separate Filament Tab #11

Closed
mansoorkhan96 opened this issue Aug 23, 2023 · 1 comment
Closed

List Draft/Revisions in a separate Filament Tab #11

mansoorkhan96 opened this issue Aug 23, 2023 · 1 comment

Comments

@mansoorkhan96
Copy link
Contributor

Problem

For some reason the table actions for draft/revisions table would not work. I have tried to add them separately and also tried to allow user to pass those actions but nothing works.

Solution

The work around for me was to use Tabs on ListRecord pages to filter records. This allowed the usage of existing actions. Other benefit of using tabs is:

  • Less space on page
  • Better UI
  • Less code to maintain, we can remove the list-draftable-records view file and the livewire components it loads
  • We dont need to define/pass which fields, actions and filters to load. Those will be loaded from resource itself.

The code we need:

use Illuminate\Database\Eloquent\Builder;
use Filament\Resources\Pages\ListRecords\Tab;

public function getTabs(): array
{
    return [
        'all' => Tab::make()
            ->modifyQueryUsing(fn (Builder $query) => $query->withoutDrafts()),
        'drafts' => Tab::make()
            ->modifyQueryUsing(fn (Builder $query) => $query->onlyDrafts()->where('is_current', true)),
    ];
}

@LukasFreyCZ I am planning to send this Pull request. I need to hear your thoughts.

Thanks :)

@lukas-frey
Copy link
Contributor

Thanks a lot for the PR @mansoorkhan96 ! It's being merged now. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants