I’m stuck a little bit What is the best way (without plugins and drag and drop) how to make reorder some RB with usual “up” and “down” icons. I have tried with youtube links and so on, but mainly I will start struggling when both “links” will get same rank. I use rank to sort my list and also I cannot “end” counting the rank. If one link is first position then i can add 10x +1 rank to the first link, and then first link i have rank 11 and second one 1. So i have to limit somehow, when this link is highest in rank, stop counting sr sth,
if using math to order the items you can do it be division
ie to move 3 to 2
plus item 1 and 2s number to get total, then divide by 2 to get the middle and write that to 3 to move it to the middle of 1 and 2
a better way would be to use states to temporarily hold items and then save them
ie on up arrow, get items in repeating group up to current index -2 (all items above it and the one above it). save as list above. then minus it from all items to get list below. minus current item from both lists. then merge above, plus item, plus below list.
states run client side so it’ll be faster an no wu until you save it to the server
drag and drop is easy enough, it’s basically option 2 using states but getting the index based on the drop location (you need a drop zone for above and below for each row)
on drop above row get dropped cells index then get repeating group items up to dropped cell minus the dropped cell (items above dropped area)
then add the dropped item and add the other items from the list after the dropped item
essentially
1
2
5 dropped here
3
4
needs to be:
above list 1,2
plus 5
plus below list 3,4
there is a little special logic for first index and last index but it’s fairly straightforward once you figure out the main reorder logic
normally I highlight the drop above or below in the row so the user can see whether it’ll drop above or below the current row