-
-
Notifications
You must be signed in to change notification settings - Fork 657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drag to reorder table rows #2370
Comments
Hi, @giant-robot Can you help me understand the idea better? Because I'm looking at the above example and I don't understand. For example, I swapped positions 3 and 7. What value will come to the |
Hey @tabuna, the current implementation will not pass arguments to the
You can access those directly from the So, for the code given above:
I hope that makes it clearer. |
I like the idea of having this in a package. But I think we need to decide a few things before we release it:
public function columns(): array
{
return [
Sortable::make('method', 'string or closure'),
...
];
}
public function reorder(Role $role, int $offset): array
{
//...
}
I will try to work with you to improve these points in the near future. |
I've converted the sorting handle from an action to a Extending public function columns(): array
{
return [
ReorderHandle::make('id')
->method('reorder'),
...
];
} Running the Regarding the actual change of the sort key of the reordered models, I see your point but it feels to me like an implementation detail. There are more than one ways to do it and it really depends on the model itself. Cheers, |
It is not an uncommon need to be able to reorder rows in a table layout. Since SortableJS is already a project dependency, it shouldn't be too hard to implement
I have put together a proof of concept that enables the feature with the minimum amount of changes in the platform.
It introduces a new action that can be added to a dedicated column. This is an example applied to the
RoleListLayout
:Not sure this is the best way to go about it, though. Thoughts?
The text was updated successfully, but these errors were encountered: