From: Mike Rylander Date: Fri, 23 Jun 2017 13:57:38 +0000 (-0400) Subject: offline: use egUnloadPrompt to alert the user to unsaved transactions, and attach... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4cf0eeae54a77e70ce8c8b6e9696c9813ee45392;p=working%2FEvergreen.git offline: use egUnloadPrompt to alert the user to unsaved transactions, and attach to $rootScope Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/web/js/ui/default/staff/offline.js b/Open-ILS/web/js/ui/default/staff/offline.js index 8bd3752802..a4eef877b2 100644 --- a/Open-ILS/web/js/ui/default/staff/offline.js +++ b/Open-ILS/web/js/ui/default/staff/offline.js @@ -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