-
Notifications
You must be signed in to change notification settings - Fork 17
Add exit dialog if user has not saved curation #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add exit dialog if user has not saved curation #197
Conversation
|
For panel is there a way to change the message ? |
spikeinterface_gui/curationview.py
Outdated
| # Add a listener which will warn the user when the browser tab is closed | ||
| js_code = """ | ||
| <script> | ||
| window.addEventListener('beforeunload', function (e) { | ||
| e.preventDefault(); | ||
| e.returnValue = ''; | ||
| }); | ||
| </script> | ||
| """ | ||
| on_close_prompt = pn.pane.HTML(js_code, width=0, height=0, margin=0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this runs regardless of the curation being saved or not, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. It runs if the user has made any modifications to the page. I don't exactly know what a modification is, but if you just look through units it doesn't activate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, we can edit the code in pn.pane.HTML at any time, I think. So should be able to only have this listener on when it's needed... lemme try...
spikeinterface_gui/curationview.py
Outdated
| self.notify_unit_visibility_changed() | ||
|
|
||
| def _panel_on_manual_curation_updated(self): | ||
| import panel as pn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alejoe91 I'm going mad. Can you think of a better way to check if there is already a warning message present?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, not sure we should use the warning, since it has a close button! We could just add a markdown pane in the refresh function so we have full control of it. What do you think?
|
Great, just added a missing "notify" (when labeling within the table) and set save current curation to True if submitting to parent (which is a way of delegating the save) |
If the user has done some curation, and not saved the curation when they try to exit, this PR adds a dialog window.
In QT. Pretty easy. We keep a
current_curation_savedin the controller. If it's false at exit, a window pops-up:In panel, we add a warning in CurationView if the curation is not saved.
It's very difficult to add a listener to a browser tab closure.