Reorder items in custom state list?

Want to reorder items from a custom state list via up/down buttons. Was thinking the workflows would involve the index # or item # but I can’t anything related to either of those in possible workflow actions. Closest I can find is “make changes to a thing” but these items won’t be added to the database until the user clicks the Log button, so that won’t work either.

Any thoughts on how to achieve this?

Use plugin “List shifter”

1 Like

Hello @heythere

Have “orphaned” entries of the objects that will be copied/created after the user logs in … making the new ones “parented”.

Yeap … list shifter should be in order :grinning:

Hi there, @heythere… while I am sure the List Shifter plugin is the way to go here (well, I’m actually not sure at all because I have never used it), I love to try to do these types of things with vanilla Bubble. After messing around with this one for a bit, I have a working example that does what have you described by using two additional custom states and two hidden inputs in the repeating group. (Note that I only worked through the workflow for moving an item up in the list, but I’m sure I could get an item to move down, too.)

In a (probably pretty convoluted) nutshell, my example creates two new lists in the additional custom states using the hidden inputs (which are the current cell’s index minus 1 and the current cell’s index minus 2) to create the lists and then merges the lists together in the original custom state to show a reordered list.

So, let’s assume you have items 1, 2, 3, and 4 in the original list, and you want to move item 3 up to item 2’s spot. When the up arrow is clicked, the first workflow step creates a new list in one of the additional custom states that includes all of the items before item 2 and then adds item 3 to that list (so, you now have a custom state that is a list with items 1 and 3 in it). The next step of the workflow creates a new list in the other additional custom state that includes all of the items from item 2 (i.e., items 2, 3, and 4) and removes item 3 from that list (so, you now have a custom state that is a list with items 2 and 4 in it). The final step of the workflow merges those two lists together into the original custom state, and the repeating group now displays the items as 1, 3, 2, 4.

Anyway, this suggestion might be too hacky for you to consider, but since I worked through the example, I didn’t think it could hurt to throw the idea out there for you as food for thought in case you don’t want to go the plugin route. If you want more details about my example (or even screenshots), just let me know.

Best…
Mike

1 Like

@cmarchan thanks for this - been turning this over in my head and can’t quite figure out what you mean. would you mind expanding on it a bit?

Ditto - really wanted to figure this out using native functions if I could.

The process you laid out is actually pretty close to something I had figured out, but figured there must be a simpler way to do it. I don’t mind hacky solutions, but I do worry that when I hand this off to the client, the workflows will just be too confusing to decipher for anyone who works on the app in the future (even with documentation).

Anyways, what you’ve laid out is clearer than what I had done, so I’m gonna try it out and see how it goes. :slight_smile: Thanks!

1 Like