F
Filamentβ€’13mo ago
Nate

Tab change event

Currently clicking a tab changes the query for the list page but I also want to change the option in Table bulk actions. Is this possible? I wan't to change the bulk actions depending on the activeTab query param WITHOUT a page reload.
public function getTabs(): array
{
return [
null => ListRecords\Tab::make('All'),
'new' => ListRecords\Tab::make()->query(fn ($query) => $query->where('status', 'new')),
'processing' => ListRecords\Tab::make()->query(fn ($query) => $query->where('status', 'processing')), // Clicking this will emit event?
];
}
public function getTabs(): array
{
return [
null => ListRecords\Tab::make('All'),
'new' => ListRecords\Tab::make()->query(fn ($query) => $query->where('status', 'new')),
'processing' => ListRecords\Tab::make()->query(fn ($query) => $query->where('status', 'processing')), // Clicking this will emit event?
];
}
->groupedBulkActions([
// Check active tab or listen for tab change event to change the action?
Tables\Actions\DeleteBulkAction::make()
->action(function () {
Notification::make()
->title('Only show on new tab')
->warning()
->send();
}),
Tables\Actions\DeleteBulkAction::make()
->action(function () {
Notification::make()
->title('Only show on processing tab')
->warning()
->send();
}),
])
->groupedBulkActions([
// Check active tab or listen for tab change event to change the action?
Tables\Actions\DeleteBulkAction::make()
->action(function () {
Notification::make()
->title('Only show on new tab')
->warning()
->send();
}),
Tables\Actions\DeleteBulkAction::make()
->action(function () {
Notification::make()
->title('Only show on processing tab')
->warning()
->send();
}),
])
Solution:
Thank you @Dennis Koch this was the solution we were looking for. ```php BulkAction::make('Print Mailout') ->label('Print Mailout PDFs')...
Jump to solution
5 Replies
Dennis Koch
Dennis Kochβ€’13mo ago
I wan't to change the bulk actions depending on the activeTab query param WITHOUT a page reload.
Not sure whether that's gonna work, but you can try. The active tab should be stored as a property, and I guess you can access it trough fn ($livewire) => $livewire->activeTab
Solution
Nate
Nateβ€’13mo ago
Thank you @Dennis Koch this was the solution we were looking for.
BulkAction::make('Print Mailout')
->label('Print Mailout PDFs')
->visible(fn ($livewire) => $livewire->activeTab == 'whatever')
BulkAction::make('Print Mailout')
->label('Print Mailout PDFs')
->visible(fn ($livewire) => $livewire->activeTab == 'whatever')
Chriis
Chriisβ€’13mo ago
I asked a couple days ago but without success, so thanks a lot πŸ™‚ While we are in Tabs @Dennis Koch, is it possible to refresh the tab count without refreshing the page when a record switch to an other tab (after an action) ?
Dennis Koch
Dennis Kochβ€’13mo ago
I don't think it's possible without a refresh event
Chriis
Chriisβ€’13mo ago
Ah okay, but how does it work with delete, restore, etc ? Because it does not refresh the page but the count is refreshed ... I tried too search in these actions but I don't really see where its done 🫀
Want results from more Discord servers?
Add your server