Close Modal After Bulk Action
I have a confirmation modal for a custom bulk action. I neeed to close this modal when process is done. How I can do this?
18 Replies
This is my Bulk Action:
->bulkActions([
Tables\Actions\BulkAction::make('download')
->action(function (Collection $records, array $data) {
self::saveRelationPublicityCustomers($records, $data['product_id']);
self::downloadCustomersWithAddressForWord($records->load('city', 'province')->whereNotNull('address'));
})
->deselectRecordsAfterCompletion()
->icon('heroicon-o-document-download')
->label('Exportar a etiquetas')
->form([
Forms\Components\Select::make('product_id')
->reactive()
->options(Product::query()->pluck(column: 'name', key: 'id'))
->required()
->label('Producto'),
])
]);
You could try to dispatch the browser event
GitHub
filament/packages/admin/src/Pages/Concerns/HasActions.php at 1afcb8...
Admin panel, form builder and table builder for Laravel. Built with the TALL stack. Designed for humans. - filament/packages/admin/src/Pages/Concerns/HasActions.php at 1afcb8e2f6cef0f04223423adedc2...
I don't know how I have to use this in my code...
If I try to do this:
->after(fn(Component $livewire) => $livewire->dispatchBrowserEvent('close-modal', [
'id' => $livewire->id
]))
It's not workswhere are you defining the modal in blade
No, My modal is in the table for Customer Resource. I did this:
->after(fn(Component $livewire) => $livewire->dispatchBrowserEvent('close-modal', [
'id' => $livewire->id.'-table-bulk-action'
]))
And now it works!ohhhh
it should close after the process is done anyway...
you shouldnt need to tell it to
thats very weird
weird
you could try this instead of $livewire:
it should still close....
@Dan Harrin @leandro_ferreira I think it's not closing the modal properly because at the end of the process I have the following:
if(Storage::disk('public')->exists($nameFile)) {
$urlFile = Storage::disk('public')->url($nameFile);
return redirect($urlFile);
}
Redirect is the problem I think. But it's the only way I have managed to download the .docx file after the entire process.try
return response()->download($urlFile)
Livewire
File Downloads | Livewire
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
With this I' getting this error:
APP_ENV('URL')/storage/clientes.docx does not exist. If I write this URL in the browser directly, it's working
π΅βπ«
maybe you need a path to the file instead of the url
check the docs i sent
I try:
return response()->download(Storage::disk('public')->path($nameFile));
return Storage::disk('public')->download($nameFile);
And nothing... the process end correctly, but not downloaded in the browserI don't know, sorry
thank you for your help!
Maybe let the modal close naturally and send a Notification with a link / action to download the file.