From 551995ccf510c58b202940ba8a16d24b89ef826b Mon Sep 17 00:00:00 2001 From: juanf <juanf@ethz.ch> Date: Fri, 1 Sep 2023 10:38:23 +0200 Subject: [PATCH] SSDM-13894: Avoid system pop up when leaving a view with changes --- .../html/js/controllers/MainController.js | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js b/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js index d121a757f23..52967707541 100644 --- a/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js +++ b/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js @@ -377,22 +377,31 @@ function MainController(profile) { this.changeView = function(newViewChange, arg, shouldStateBePushToHistory) { this._changeView(newViewChange, arg, true, shouldStateBePushToHistory); } + this._changeView = function(newViewChange, arg, shouldURLBePushToHistory, shouldStateBePushToHistory) { LayoutManager.isBlocked = false; + var _this = this; + var _next = function() { + Util.unblockUI(); + _this._changeViewNext(newViewChange, arg, shouldURLBePushToHistory, shouldStateBePushToHistory); + } // // Dirty forms management, to avoid loosing changes. // var discardChanges = null; - if( this.currentView && - this.currentView.isDirty && + if( this.currentView && + this.currentView.isDirty && this.currentView.isDirty()) { //Ask the user if wants to leave the view in case is dirty - discardChanges = window.confirm("Leaving this window will discard any changes, are you sure?"); - } - - if(discardChanges != null && !discardChanges) { - return; + Util.blockUIConfirm("Leaving this window will discard any changes, are you sure?", _next, null /* Do nothing */); + } else { + _next(); } + } + + this._changeViewNext = function(newViewChange, arg, shouldURLBePushToHistory, shouldStateBePushToHistory) { + LayoutManager.isBlocked = false; + // // Finalize view, used to undo mayor modifications to how layout and events are handled // -- GitLab