dandi / dandiarchive-legacy

Code for the DANDI Web app
https://dandiarchive.org
Apache License 2.0
9 stars 9 forks source link

meditor: changed state and undo #685

Closed satra closed 3 years ago

satra commented 3 years ago

we are asking for a lot of things that could be added using the meditor. i had someone enter some data and forgot to hit save, just hit the back button or something else. it would be nice if the meditor detected a change and prompted the user that they were navigating away without saving.

on a more general note, some of the elements are complex and we don't really have an undo mechanism. an accidental delete of a complex object (e.g. person/organization) could be quite frustrating. perhaps we can look into how to confirm any delete operation on objects.

yarikoptic commented 3 years ago

In the long term I guess should be done within vjsf itself to provide proper history of changes and undo/redo stepping through changes? Even if a full metadata record copy stored at each modification, shouldn't be prohibitive

waxlamp commented 3 years ago

I agree that we can likely keep state change snapshots in the database, and if that turns out to be too heavyweight, we can probably find library or cook up a way to store diffs instead.

jjnesbitt commented 3 years ago

it would be nice if the meditor detected a change and prompted the user that they were navigating away without saving.

This should be pretty easy to do.

on a more general note, some of the elements are complex and we don't really have an undo mechanism. an accidental delete of a complex object (e.g. person/organization) could be quite frustrating. perhaps we can look into how to confirm any delete operation on objects.

I'm not sure what functionality exists within VJSF to hook into the delete action, but I'd think if it did exist we'd have an alert show up to confirm delete, the same way we would for the above issue.

I can also look into keeping a buffer of the last few actions, to allow for undo. If that causes a significant performance hit, we might have to try a different approach.

mvandenburgh commented 3 years ago

I addressed some of the issues brought up here in #714.

it would be nice if the meditor detected a change and prompted the user that they were navigating away without saving.

This is done. I also made a change to the way the save button works - before, both the save button and back button would close the meditor. That essentially means that using the back button will always result in unsaved changes being lost, so I changed the functionality of the save button to keep the user on the meditor screen after saving.

on a more general note, some of the elements are complex and we don't really have an undo mechanism. an accidental delete of a complex object (e.g. person/organization) could be quite frustrating. perhaps we can look into how to confirm any delete operation on objects.

I'm not sure what functionality exists within VJSF to hook into the delete action, but I'd think if it did exist we'd have an alert show up to confirm delete, the same way we would for the above issue.

I wasn't able to find any existing functionality that allows for hooking into the delete action. I was still able to implement undo/redo, but I had to use some hacky workarounds to get it working due to the limitations of VJSF. I tried a couple different ways of doing it, but I think a cleaner solution would require VJSF to handle some additional functionality.

I can also look into keeping a buffer of the last few actions, to allow for undo. If that causes a significant performance hit, we might have to try a different approach.

As of right now previous actions are stored in a buffer, but it could be switched to localStorage without too much trouble if performance becomes an issue.

yarikoptic commented 3 years ago

I wasn't able to find any existing functionality that allows for hooking into the delete action. ... a cleaner solution would require VJSF to handle some additional functionality.

:+1: on that. I think it might be worth filing an issue within VJSF right away, describing ongoing here development (may be it could later be done/migrate to vjsf itself?)