esmero / webform_strawberryfield

Provides Webform integrations to feed a field of Strawberries. Mr. Wizard of WebOz
GNU Lesser General Public License v3.0
2 stars 6 forks source link

Provide button to clear autosaved webform content #113

Closed patdunlavey closed 3 years ago

patdunlavey commented 3 years ago

From @dmer : "I’ve had this experience a few times where I had abandoned a new object without saving and then later attempting to make a new object and finding some of the values I’d previously entered - I know this is the “draft” saving which I love since it will certainly save work from being lost. I’m just wondering how those values are persisted and if I can somehow clear them if I want to."

DiegoPino commented 3 years ago

@patdunlavey if you have the time, this is not too complex. Requires some Ajax to make it work but can also be a simple re-load if Ajax is not desired.

Here is an example (not the only place, we have two widgets) where the session is used.

https://github.com/esmero/webform_strawberryfield/blob/680270b3bda51832b5170e4a43255158f5ccd214/src/Plugin/Field/FieldWidget/StrawberryFieldWebFormInlineWidget.php#L282-L300

The idea is to add an extra button by the message that allows the Widget Form to be reloaded with that temp Store cleaned up (Ajax call would do that). On Form rebuild the Webform won't have the previous session anymore.

DiegoPino commented 3 years ago

@patdunlavey @dmer @alliomeria. I will take this one since there is a little bit (lot) to modify. But I have a question. You want to clear the saved progress or stash it? stash means = do not use it but keep it. I feel clearing is simpler so I would recommend that route but want to be sure you are OK with that. Thanks!

dmer commented 3 years ago

@DiegoPino I vote strongly for just clear it - stashing feels like it introduces potential for confusion, more admin, etc.

DiegoPino commented 3 years ago

@dmer @patdunlavey this should be ready by tomorrow afternoon. I will need some "UI" feedback but the logic itself won't be a problem. Will let you all know. Thanks

DiegoPino commented 3 years ago

Fixed via https://github.com/esmero/webform_strawberryfield/commit/57a6c43b19d027bfff2ba0d5ee419a7869fa87bb