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

[Bug]: Error when we use UUID/ULID

Open envolute opened this issue 11 months ago • 4 comments

What happened?

Hi Mokhosh!!

I am using ULID in the model, so when I try to drag the item to another status or edit it, an error occurs... I found that the problem is that all declarations of the $recordId parameter were defined as integer int $recordId This way I found all the declarations and changed it to: int|string $recordId The changed methods were in the following files: "src/Concerns/HasStatusChange.php" "src/Concerns/HasEditRecordModal.php"

In this second file, we have the variable public ?int $editModalRecordId = null; Changed to: public null|int|string $editModalRecordId = null; And the method: getEditModalFormSchema(?int $recordId) Changed to getEditModalFormSchema(null|int|string $recordId)

Important: I also had to change the function calls: onStatusChanged(int|string $recordId, ...) getEditModalFormSchema(null|int|string $recordId, ...) In the page generated through the "make" command.

Reminder: It is necessary to change the test files and functions generated in the "make" command

Well, I believe that as the use of UUID or ULID is common, this correction is interesting...

How to reproduce the bug

Use UUID or ULID as record IDs. Then try to change them...

Package Version

v2.3.0

PHP Version

8.1.10

Laravel Version

10.10

Which operating systems does with happen with?

Windows

Which browsers does with happen with?

Chrome

Notes

No response

envolute avatar Mar 18 '24 14:03 envolute

Thanks for reporting. I'll look into it.

mokhosh avatar Mar 18 '24 14:03 mokhosh

I wrote new tests for models using ulid, and tests are passing, but this will be a breaking change, as it will change the signature of some KanbanBoard methods that are usually overrode.

I'll ship this in v3.

mokhosh avatar Mar 18 '24 19:03 mokhosh

Great!! In my project the changes have already been made and so far everything is ok... Of course, if I need to update or, certainly, use it again I will go to version 3...

Thank you for your attention and for the code that worked perfectly for my needs!!

envolute avatar Mar 19 '24 01:03 envolute

As a temporary fix:

  1. Make the board extends Filament Page class ToDoBoard extends Page implements HasForms

  2. Copy all data (properties and methods) from KanbanBoard to your board and make $record_id to be a string

  3. Create your own HasEditRecordModal and HasStatusChange traits and make $record_id to be a string

I got it working with UUID this way.

P.S.: Great work. Very usefull module.

milenmk avatar Jun 18 '24 15:06 milenmk

hello, any updates regarding this feature?

crisanT1231 avatar Oct 16 '24 13:10 crisanT1231

As a temporary fix:

  1. Make the board extends Filament Page class ToDoBoard extends Page implements HasForms
  2. Copy all data (properties and methods) from KanbanBoard to your board and make $record_id to be a string
  3. Create your own HasEditRecordModal and HasStatusChange traits and make $record_id to be a string

I got it working with UUID this way.

P.S.: Great work. Very usefull module.

thanks, this worked for me too

crisanT1231 avatar Oct 16 '24 13:10 crisanT1231