asantibanez/laravel-blade-sortable

Nested sortables with Livewire event handling

juliomotol opened this issue · 16 comments

Is there any way I could handle the wire:onSortOrderChange and know whether it has been move from one list to another?

I think my problem is related.
I need at least the group in the handleSortOrderChange method, or another customizable parameter.

Same problem here, right now theres no way to know in what dropzone you dragged your items. @asantibanez

Hi all! Thanks for your interest in the package.

This issue has been addressed in v1.1.0.

wire:onSortOrderChange gets called on any interaction with the drop zone: sorting, adding, removing.

Check it out.

Sorry, I don't understand. How was this resolved?

v1.1.0 is tagged at the same commit as v1.0.3 (commit 0bdd90f)
image

Thanks for the update @juliomotol .

Wrong version was tagged.

Just fixed. 👍

I still don't understand how that update fix this ?
Maybe I'm missing something.

Don't follow @SquareBeard . Inside your Livewire component you have 2 drop zones and want to get updated on both with wire:onSortOrderChange?

Sorry maybe I should have done another issue, it does not seem related anymore.
I want to know which drop zone is calling onSortOrderChange.
My drop zones are created dynamically, I can't use a different method for each zone. I just need the group name or some other parameter to identify the drop zone.
Something like

function handleSortOrderChange($order, $groupName) { ... }

Does that make more sense ?

I'm sorry @asantibanez, I'm with @SquareBeard on this one.

The concern was:

Is there any way I could handle the wire:onSortOrderChange and know whether it has been move from one list to another?

And yet, the new release feels like a refactor rather than a fix.

Taking an inspiration from SortableJs' event parameters, we could do:

function handleSortOrderChange($order, $toGroup, $fromGroup) { ... }

This is doable. How would you identify the containers? With an id in the sortable component?

Sounds good, but 'from' before 'to' feels more natural to me.

function handleSortOrderChange($order, $from, $to) { ... }

Hey @SquareBeard @juliomotol

Have this one working. I am sending this info the Livewire component:

image

Example callback

image

Demo

2021-03-26 18 24 57

How's that looking?

@asantibanez Looking like a charm. I really loved that you included the old sort order. Might come handy in the future.

Looks great, thank you.

Hello and thank you for creating this!

About the demo above. When you move "Andres" to the middle section. How I should get the data that "Andres" was moved to somewhere?

I was hoping the "name" param would show this..

I think the only way to get this data now is to compare sortOrder and previousSortOrder and remove duplicates