Editing data in a repeating group via an input

Hi

I am struggling with how to best edit data in a repeating group.

I have built an article builder which allows a user to create articles and insert specific sections for call outs, quotes, images etc.

The idea is, the user adds a section, adds text to the section, adds another section and so on.

This is fine. The issue i have is updating the article.

Currently i have set autobinding on the input in the form so the data base is updated straight away. This is for text and images. Te article section thing has a type which records the type of section (body, image, quote, call out, etc) an image field to record and display an image and a text field to record the text to display in the section.

But, if the user opens the editor, makes changes, and then does not want to save those changes i need a way to revert the data.

I have tried setting a state that is a list of texts to record the opening data, but I could n’t get to where i needed with it, and i struggled with the list of images (which also have a text caption). Also, and i think i’m missing something, i tried to push the states to the inputs but I couldn’t work out how to update the states in the individual inputs.

My solution was to create a temporary record that replicates the section. If a user presses save after their updates then everything is as is. If they x out and do not save the updates, I loop over the temporary records and compare them to the actual, then update appropriately.

Whether the user saves or not, all temporary records are then deleted - if save occurs, they are deleted immediately, if user x outs, once i have looped over the record to compare with original i then delete it.

This seems quite resource intensive and wondering if anyone could point me in a better direction at all. Or if what i am doing is reasonable?

@tylerboodman @johnny @bestbubbledev

One way to do it is when they hit Edit have it do “Copy a list of things” (:converted to a list if its just one thing) and make a duplicate of the thing to work on as a draft.

If they hit Save then just make that the new thing. If the hit cancel then delete it.

The feasibility of this depends on how you have things structured, if there are a lot of linked datatypes you would need to copy all of those and re-link all the copies to the new thing, etc.

@tylerboodman thanks man! thats basically what I am doing. Just wanted to see if there was a better way of handling it via states or other.

I think for simplicity that is what I would do… with Bubble’s limitations you can’t make on-page objects without resorting to plugins I think. Unless your datatype has really rigid structure where you can just make a custom state for every field.