filament-kanban icon indicating copy to clipboard operation
filament-kanban copied to clipboard

[Request]: Mountable Record Action for record

Open eele94 opened this issue 11 months ago • 4 comments

What happened?

Would be awesome to be able to add actions(e.g. tableactions) to the View

This way would be maybe doable to add comment functionality through a package like this https://github.com/parallax/filament-comments

I tried to make it working, but am failing to implement it in a clean way..

How to reproduce the bug

Package Version

2.6.1

PHP Version

8.3

Laravel Version

10.0

Which operating systems does with happen with?

No response

Which browsers does with happen with?

No response

Notes

No response

eele94 avatar Mar 08 '24 11:03 eele94

I'm thinking of integrating actions for v3.

mokhosh avatar Mar 08 '24 12:03 mokhosh

Hi, I was looking for a way to delete a record, is it currently possible? Or maybe through the edit modal?

CharlieEtienne avatar Mar 16 '24 00:03 CharlieEtienne

@CharlieEtienne Yes, it's not super elegant, but you can do it in the edit modal like this:

use Filament\Forms\Components\Actions;
use Filament\Forms\Components\Actions\Action;

protected function getEditModalFormSchema(?int $recordId): array
{
    return [
        Actions::make([
            Action::make('delete')
                ->icon('heroicon-m-x-mark')
                ->color('danger')
                ->requiresConfirmation()
                ->action(function () use ($recordId) {
                    static::$model::find($recordId)->delete();

                    $this->dispatch('close-modal', id: 'kanban--edit-record-modal');
                }),
        ]),
    ];
}

Hopefully I'll create more elegant ways of doing this in v3.

mokhosh avatar Mar 16 '24 22:03 mokhosh

Thanks, it's working. I just have one problem but I think it's not related: after I delete a record, the page loses scrollbar and I can't scroll up or down anymore. It's probably related to filament itself because I have the same problem with another plugin. EDIT: Found it

CharlieEtienne avatar Mar 17 '24 07:03 CharlieEtienne