simsalabim/sisyphus

Prevent restore

Closed this issue · 6 comments

Hi, guys,

is there a way to prevent sisyphus restore the form in onBeforeRestore callback?

Returning false from the onBeforeRestore doesn't seem to work. Any way to do this?

Hi @larryzhao, why do you need this? As for me this sounds quite senseless. If you don't want the data to be restored, you obviously shouldn't include those fields in protected scope.

When a user returns to a page, it does make sense to ask if he wants to restore his form-data.

@simsalabim I have the same scenario as @julesjanssen describes. Sisyphus is really a great work for a "one time" form. But in my project, user is composing a writing, so in most cases, it is not finished once, and especially if a user writes on computer A, and then writes on computer B and then on computer A again, he will find he could not see what he wrote on computer B because I use Sisyphus to restore the data stored on computer A in the first place.

But in reality, I found that it also doesn't make any sense to ask the user "Do you want to restore?". Because he really doesn't know what will be restored to the form if he chooses YES.

So I made it this way, I just let Sisyphus restore for the user first, and give the user an Undo button to get back to the server version if the restored one is not what he wants.

This is the detail of why I came up with this requirement. I thinks it's not a big problem to Sisyphus without supporting this, but it would be a good if this functionality is there. Maybe in other scenarios it really makes sense.

Thanks.

Thank you all, just added this possibility: in onBeforeRestore returns false then data restoration will be interrupted.
Available in v1.1

Thank you @simsalabim !