offline: force-save outstanding transactions on patron registration to avoid losing...
authorMike Rylander <mrylander@gmail.com>
Mon, 12 Jun 2017 17:05:45 +0000 (13:05 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 12 Jun 2017 21:13:15 +0000 (17:13 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/web/js/ui/default/staff/offline.js

index 58ea2a1..c924d64 100644 (file)
@@ -38,8 +38,8 @@ function($routeProvider , $locationProvider , $compileProvider) {
 }])
 
 .controller('OfflineSessionCtrl', 
-           ['$scope','$location','$window','egCore','$routeParams','$http','$q','$timeout','egPromptDialog','ngToast','egProgressDialog',
-    function($scope , $location , $window , egCore , $routeParams , $http , $q , $timeout , egPromptDialog , ngToast , egProgressDialog) {
+           ['$scope','$window','egCore','$routeParams','$http','$q','$timeout','egPromptDialog','ngToast','egProgressDialog',
+    function($scope , $window , egCore , $routeParams , $http , $q , $timeout , egPromptDialog , ngToast , egProgressDialog) {
         $scope.active_session_tab = 'pending';
 
         $scope.lookupNoncatTypeName = function (type) {
@@ -250,8 +250,8 @@ function($routeProvider , $locationProvider , $compileProvider) {
 ])
 
 .controller('OfflineCtrl', 
-           ['$q','$scope','$location','$window','egCore','egLovefield','$routeParams','$timeout','$http','ngToast','egConfirmDialog',
-    function($q , $scope , $location , $window , egCore , egLovefield , $routeParams , $timeout , $http , ngToast , egConfirmDialog) {
+           ['$q','$scope','$location','$rootScope','egCore','egLovefield','$routeParams','$timeout','$http','ngToast','egConfirmDialog',
+    function($q , $scope , $location , $rootScope , egCore , egLovefield , $routeParams , $timeout , $http , ngToast , egConfirmDialog) {
         $scope.active_tab = $routeParams.tab || 'checkout';
 
         $scope.minDate = new Date();
@@ -429,6 +429,8 @@ function($routeProvider , $locationProvider , $compileProvider) {
             });
         }
 
+        $rootScope.save_offline_xacts = function () { return $scope.save() };
+
         $scope.clear_pending = function (skip_confirm) {
             if (skip_confirm) {
                 return egLovefield.destroyPendingOfflineXacts().then(function () {
@@ -1363,11 +1365,12 @@ function($routeProvider , $locationProvider , $compileProvider) {
 .controller('PatronRegCtrl',
        ['$scope','$routeParams','$q','$uibModal','$window','egCore',
         'patronSvc','patronRegSvc','egUnloadPrompt','egAlertDialog',
-        'egWorkLog','$timeout','egLovefield',
+        'egWorkLog','$timeout','egLovefield','$rootScope',
 function($scope , $routeParams , $q , $uibModal , $window , egCore ,
          patronSvc , patronRegSvc , egUnloadPrompt, egAlertDialog ,
-         egWorkLog , $timeout , egLovefield) {
+         egWorkLog , $timeout , egLovefield , $rootScope) {
 
+    $scope.rs = $rootScope;
     patronRegSvc.org = $scope.workstation_obj.owning_lib;
     $scope.offline = true;
 
@@ -2021,6 +2024,7 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore ,
         var updated_user;
 
         patronRegSvc.save_user($scope.patron)
+        .then($scope.rs.save_offline_xacts)
         .then(function(new_user) { 
             // reload the current page
             $window.location.href = location.href;