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

Edit action does not work: method sholdOpenModal does not exists

Open kuzovkov opened this issue 1 year ago • 2 comments

Hi, I got such error. image

When click on edit button on tree element I got error as on screen.

kuzovkov avatar Apr 15 '24 14:04 kuzovkov

I fixed it by extend SolutionForest\FilamentTree\Actions\EditAction and SolutionForest\FilamentTree\Actions\DeleteAction classes and put fake method shouldOpenModal to each of them:

<?php

namespace App\Filament\Resources\SupplierProductCategoryResource\Pages;

use App\Filament\Resources\SupplierProductCategoryResource;
use Filament\Pages\Actions\CreateAction;
use SolutionForest\FilamentTree\Actions;
use SolutionForest\FilamentTree\Actions\EditAction as BaseEditAction;
use SolutionForest\FilamentTree\Actions\DeleteAction as BaseDeleteAction;
use SolutionForest\FilamentTree\Concern;
use SolutionForest\FilamentTree\Resources\Pages\TreePage as BasePage;
use SolutionForest\FilamentTree\Support\Utils;
use Filament\Actions as FilamentActions;


class EditAction extends BaseEditAction
{
    public function shouldOpenModal($checkForFormUsing)
    {
        return true;
    }
}

class DeleteAction extends BaseDeleteAction
{
    public function shouldOpenModal($checkForFormUsing)
    {
        return true;
    }
}


class SupplierProductCategoryTree extends BasePage
{
    protected static string $resource = SupplierProductCategoryResource::class;

    protected static int $maxDepth = 3;

    protected function getActions(): array
    {
        return [
            $this->getCreateAction(),
        ];
    }

    protected function getTreeActions(): array
    {
        return [
            EditAction::make(),
            DeleteAction::make()
        ];
    }

    protected function hasDeleteAction(): bool
    {
        return false;
    }

    protected function hasEditAction(): bool
    {
        return false;
    }

    protected function hasViewAction(): bool
    {
        return false;
    }

    protected function getHeaderWidgets(): array
    {
        return [];
    }

    protected function getFooterWidgets(): array
    {
        return [];
    }

    // CUSTOMIZE ICON OF EACH RECORD, CAN DELETE
    // public function getTreeRecordIcon(?\Illuminate\Database\Eloquent\Model $record = null): ?string
    // {
    //     return null;
    // }
}

kuzovkov avatar Apr 16 '24 07:04 kuzovkov

I am also getting exactly same error and also tried above changes which didn't worked for me.

raviroshanmehta avatar May 06 '24 17:05 raviroshanmehta

kuzovkov Thanks for the solution it works

creativeplus2 avatar Jun 03 '24 03:06 creativeplus2

In version 2.1.0, we have added back this logics. Please upgrade to the latest version and check if the issue you were experiencing still occurs.

cklei-carly avatar Aug 05 '24 10:08 cklei-carly