Dear Bubble community,
Please forgive me for a long introduction to my two questions at the bottom:
I use copy list of things in my app to be able to edit data in a repeating group without resorting to the auto-bind functionality:
Assume these data below are in my table, and I want to be able to edit them. What I also want is the ability to cancel my attempt at editing them and be able to get back to the initial values.
Mydata:
1, ‘Item A’
2, ‘Item B’
3, ‘Item C’
For the lack of a better idea, I do the following:
-
Set two “variables”:
Set State IndexEndOriginal = mydata:count ie 3
Set State IndexStartCopies = mydata:count + 1 ie 4 -
Copy my list of data:
Mydata:
1, ‘Item A’
2, ‘Item B’
3, ‘Item C’
4, ‘Item A’
5, ‘Item B’
6, ‘Item C’ -
Restrict the data search in my repeating group to mydata:from IndexStartCopies
The Repeating group now displays:
1, ‘Item A’ (#4 copy of #1)
2, ‘Item B’ (#5 copy of #2)
3, ‘Item C’ (#6 copy of #3) -
Edit these data
-
Have the ability to save changes by deleting mydata:until IndexEndOriginal (it deletes original three entries and keeps the edited copies)
-
Have the ability to cancel changes by deleting mydata:from IndexStartCopies (it deletes copies and keeps the original entries)
Now my questions:
- Is there a smarter way to do this without duplicating a lot of data?
- When I copy a list of things, I notice that the copies do not necessarily respect the order of the originals ie
copying 1, ‘Item A’ 2, ‘Item B’ 3, ‘Item C’ would be:
1, ‘Item A’ 2, ‘Item B’ 3, ‘Item C’ 4, ‘Item C’ 5, ‘Item B’ 6, ‘Item A’
instead of:
1, ‘Item A’ 2, ‘Item B’ 3, ‘Item C’ 4, ‘Item A’ 5, ‘Item B’ 6, ‘Item C’
Copy a list of things, copies things in which way theoretically: ascending (or descending) order of created-date, modified-date, primary-field?
Sorry for the long text.