diff --git a/CHANGELOG.md b/CHANGELOG.md index 3329fec30d..1c5058475a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -173,6 +173,9 @@ Miscellaneous: - The navigate-with-project setting of a stack viewer is now respected in stored layouts. +- Clicking the Home link in the upper left corner with a project open, will now + also ask for confirmation (like clicking any data view entry in the menu). + ## Maintenance updates - Node distance measurements: computation of straight line distance has been diff --git a/django/applications/catmaid/static/js/init.js b/django/applications/catmaid/static/js/init.js index 6c5efe157a..f6dd0736eb 100644 --- a/django/applications/catmaid/static/js/init.js +++ b/django/applications/catmaid/static/js/init.js @@ -577,6 +577,12 @@ var project; document.getElementById( "account" ).onkeydown = login_oninputreturn; document.getElementById( "password" ).onkeydown = login_oninputreturn; + document.getElementById( "home_button" ).addEventListener('click', event => { + CATMAID.client.confirmLoadHomeView() + .catch(CATMAID.handleError); + return false; + }); + CATMAID.DataViews.list().then(dataviews => { this._knownDataViews = dataviews; this._updateDataViewMenu(); @@ -1818,7 +1824,7 @@ var project; // If a project is active, ask for confirmation before closing it. if (project) { if (!confirm('Are you sure you want to close all widgets and views?')) { - return; + return Promise.reject(new CATMAID.Warning('Cancelled by user')); } project.destroy(); } else { @@ -1887,6 +1893,21 @@ var project; } }; + /** + * Ask the user whether to close an active project, before loading the home + * view. + */ + Client.prototype.confirmLoadHomeView = function(backgroundDataView = false) { + // If a project is active, ask for confirmation before closing it. + if (project) { + if (!confirm('Are you sure you want to close the active project including all windows?')) { + return Promise.reject(new CATMAID.Warning('Cancelled by user')); + } + project.destroy(); + } + return CATMAID.client.loadHomeView(backgroundDataView); + }; + /** * Load a particular data view. * @@ -1925,7 +1946,7 @@ var project; */ Client.prototype.load_default_dataview = function(background) { var self = this; - CATMAID.DataViews.getDefaultConfig() + return CATMAID.DataViews.getDefaultConfig() .then(function(config) { // If no data view is defined on the back-end, use a default data view. if (!config || !config.id || CATMAID.tools.isEmpty(config.config)) { diff --git a/django/applications/catmaid/templates/catmaid/index.html b/django/applications/catmaid/templates/catmaid/index.html index 89a952d47a..daac10ad33 100644 --- a/django/applications/catmaid/templates/catmaid/index.html +++ b/django/applications/catmaid/templates/catmaid/index.html @@ -78,7 +78,7 @@