LP#1452950 Remove unsaved data warning after click-thru
authorBill Erickson <berickxx@gmail.com>
Sat, 16 Jan 2016 20:15:01 +0000 (15:15 -0500)
committerGalen Charlton <gmc@esilibrary.com>
Thu, 25 Feb 2016 22:32:00 +0000 (17:32 -0500)
Once the user clicks through the unsaved data warning, clear the warning
for future navigation.  If more fields are changed, the warning will be
reinstated.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/web/js/ui/default/staff/services/ui.js

index 2ffbc22..7f84666 100644 (file)
@@ -202,6 +202,7 @@ function($window , egStrings) {
 
         // handle page change
         $($window).on('beforeunload', function() { 
+            service.clear();
             return msg || egStrings.EG_UNLOAD_PAGE_PROMPT_MSG;
         });
 
@@ -211,8 +212,13 @@ function($window , egStrings) {
         // similar to the page-page prompt.
         service.locChangeCancel = 
             $scope.$on('$locationChangeStart', function(evt, next, current) {
-            if (!confirm(msg || egStrings.EG_UNLOAD_CTRL_PROMPT_MSG)) 
+            if (confirm(msg || egStrings.EG_UNLOAD_CTRL_PROMPT_MSG)) {
+                // user allowed the page to change.  
+                // Clear the unload handler.
+                service.clear();
+            } else {
                 evt.preventDefault();
+            }
         });
     };