offline: use egUnloadPrompt to alert the user to unsaved transactions, and attach...
authorMike Rylander <mrylander@gmail.com>
Fri, 23 Jun 2017 13:57:38 +0000 (09:57 -0400)
committerMike Rylander <mrylander@gmail.com>
Fri, 23 Jun 2017 13:57:38 +0000 (09:57 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/web/js/ui/default/staff/offline.js

index 8bd3752..a4eef87 100644 (file)
@@ -250,8 +250,8 @@ function($routeProvider , $locationProvider , $compileProvider) {
 ])
 
 .controller('OfflineCtrl', 
-           ['$q','$scope','$window','$location','$rootScope','egCore','egLovefield','$routeParams','$timeout','$http','ngToast','egConfirmDialog',
-    function($q , $scope , $window , $location , $rootScope , egCore , egLovefield , $routeParams , $timeout , $http , ngToast , egConfirmDialog) {
+           ['$q','$scope','$window','$location','$rootScope','egCore','egLovefield','$routeParams','$timeout','$http','ngToast','egConfirmDialog','egUnloadPrompt',
+    function($q , $scope , $window , $location , $rootScope , egCore , egLovefield , $routeParams , $timeout , $http , ngToast , egConfirmDialog , egUnloadPrompt) {
         $scope.active_tab = $routeParams.tab || 'checkout';
 
         var today = new Date();
@@ -437,6 +437,7 @@ function($routeProvider , $locationProvider , $compileProvider) {
             }
 
             return $q.all(promises.concat(prints)).finally(function() {
+                egUnloadPrompt.clear();
                 if (prints.length > 1) $scope.printed = true;
                 $scope.all_xact = [];
                 $scope.xact_page = { checkin:[], checkout:[], renew:[], in_house_use:[] };
@@ -662,6 +663,7 @@ function($routeProvider , $locationProvider , $compileProvider) {
             );
 
             $scope.all_xact.push(xact)
+            egUnloadPrompt.attach($rootScope);
 
             $scope[xtype] = {};
 
@@ -1955,13 +1957,13 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore ,
         // 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);
+        egUnloadPrompt.attach($rootScope);
     }
 
     // also monitor when form is changed *by the user*, as using
     // an ng-change handler doesn't work with eg-date-input
     $scope.$watch('reg_form.$pristine', function(newVal, oldVal) {
-        if (!newVal) egUnloadPrompt.attach($scope);
+        if (!newVal) egUnloadPrompt.attach($rootScope);
     });
 
     // username regex (if present) must be removed any time