-
-
Notifications
You must be signed in to change notification settings - Fork 490
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
Teach #move_to_child_with_index
to accept :root
as a target
#481
Teach #move_to_child_with_index
to accept :root
as a target
#481
Conversation
Looks like CI is broken on master, cuz rails-main depends on Ruby 3.x now. Fixed in #482 |
89b8739
to
d4c97c8
Compare
d4c97c8
to
292969f
Compare
@parndt ok, green after rebasing on master |
@botandrose given we already have this code |
@parndt I started the refactoring today, and its becoming clear to me that in order to remove the duplication, I'll need to introduce two more API additions:
My question for you is whether or not I should open separate PRs for these two items to evaluate and discuss one-by-one, or if you'd prefer this whole endeavour to live in this one PR as a coherent package? |
@botandrose happy for it to be one change if you are 😄 then it provides the whole context for anyone looking later. IF you'd prefer to do it separately, I'm fine with that too. |
…thin #move_to_child_with_index.
…ithin #move_to_child_with_index.
@parndt Okay, I'm pretty satisfied with this, now. Do you think it needs anything more before its good to merge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work on this!
Overview:
This PR enhances the
#move_to_child_with_index
method to accept:root
as a valid parent:Motivation:
The motivation was pairing ANS with a JavaScript drag-and-drop tree reordering library, and needing to persist the moves made to the database. The
#move_to_child_with_index
API was perfect for this, except it couldn't handle moves made to the top-level. This has been noted before in #446Questions:
Does this look like a reasonable addition to ANS? Is this the right API design? Would passing
nil
instead of:root
be more consistent with the rest of the API? Or perhaps it should be a new method entirely, like #447 ?Future work:
If this is the right API design, I'd like to refactor out the duplication in
#move_to_child_with_index
. Also, I'd like to add a few more tests.What do you think?