mokhosh / filament-kanban

Add kanban boards to your Filament pages
https://filamentphp.com/plugins/mokhosh-kanban
MIT License
228 stars 32 forks source link

[Request]: Mountable Record Action for record #22

Open eele94 opened 4 months ago

eele94 commented 4 months ago

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

mokhosh commented 4 months ago

I'm thinking of integrating actions for v3.

CharlieEtienne commented 4 months ago

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

mokhosh commented 4 months ago

@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.

CharlieEtienne commented 4 months ago

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