LP#1452950 re-attach unload warning after click-through
authorBill Erickson <berickxx@gmail.com>
Wed, 17 Feb 2016 01:56:26 +0000 (20:56 -0500)
committerGalen Charlton <gmc@esilibrary.com>
Thu, 25 Feb 2016 22:32:01 +0000 (17:32 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js
Open-ILS/web/js/ui/default/staff/services/ui.js

index 9385086..1d28a3b 100644 (file)
@@ -695,10 +695,11 @@ function PatronRegCtrl($scope, $routeParams,
     $scope.edit_passthru.vis_level = 0; 
     // TODO: add save/clone handlers here
 
-    var modify_tracked = false;
     $scope.field_modified = function() {
-        if (modify_tracked) return;
-        modify_tracked = true;
+        // Call attach with every field change, regardless of whether
+        // it's been called before.  This will allow for re-attach after
+        // the user clicks through the unload warning. egUnloadPrompt
+        // will ensure we only attach once.
         egUnloadPrompt.attach($scope);
     }
 
index 7f84666..d9f77fa 100644 (file)
@@ -195,10 +195,12 @@ function($modal, $interpolate) {
 .factory('egUnloadPrompt', [
         '$window','egStrings', 
 function($window , egStrings) {
-    var service = {};
+    var service = {attached : false};
 
     // attach a page/scope unload prompt
     service.attach = function($scope, msg) {
+        if (service.attached) return;
+        service.attached = true;
 
         // handle page change
         $($window).on('beforeunload', function() { 
@@ -227,6 +229,7 @@ function($window , egStrings) {
         $($window).off('beforeunload');
         if (service.locChangeCancel)
             service.locChangeCancel();
+        service.attached = false;
     }
 
     return service;