buttonwoodcx / bcx-aurelia-reorderable-repeat

An Aurelia repeater supports drag & drop reordering automatically.
https://buttonwoodcx.github.io/doc-bcx-aurelia-dnd/reorderable-repeat
MIT License
19 stars 5 forks source link

Allow nesting in repeat.for #15

Closed RobertBinneman closed 4 years ago

RobertBinneman commented 4 years ago

To create a drag and drop aware kanban board with a variable number of columns it is necessary to be able to nest reorderable-repeat inside a repeat.for.

I have made a small change which seems to work OK, but as I am not so familiar with Karma, I could not get my test to run.

3cp commented 4 years ago

Thanks very much! From your code, I realized I hard coded the func getter on binding scope. Your fix will fix one level up, but aurelia binding scope can support unlimited parent context.

I will ship an alternative fix with proper aurelia binding getter which can work with multiple level of binding context.

3cp commented 4 years ago

Sorry, this has skipped from my mind. I will add to my todo.

3cp commented 4 years ago

repeat.for is not the only binding that introduces extra layer of binding context. if.bind and with.bind are the other two built-in binding that creates layer of binding context.

They are special custom attribute, called "template controller" attribute. User can create their own "template controller" attribute too, that also introduces layer of binding context.

My fix uses Aurelia's scope API getContextFor to search through the binding scope chain, so it will work with any number of layers of binding context. If you have interest on the test code, there are two new unit tests, one for one extra layer, another one for two extra layers.

v1.3.4 is released now, it should fix this bug.

Sorry for the long delay. I have been busy maintaining few projects alone with my day job. This bug totally slipped from my mind.

3cp commented 4 years ago

It seems my fix introduced a new bug only on Windows. I would find a win box to test it in few days.

3cp commented 4 years ago

No new bug introduced, it was a test setup issue on win10.