LP#1702756 - WebStaff fix for bug that was introduced by 997e2772
authorCesar Velez <cesar.velez@equinoxinitiative.org>
Mon, 10 Jul 2017 20:47:26 +0000 (16:47 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Wed, 19 Jul 2017 15:57:28 +0000 (11:57 -0400)
While addressing LP#1696495 fixed the bug of user settings caching
improperly between patron edits, it caused an issue when the regctl
was loaded for registering a new patron. This corrects that.

Signed-off by: Cesar Velez <cesar.velez@equinoxinitiative.org>
Signed-off-by: Josh Stompro <stomproj@larl.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js

index 4e53fde..d0dcca8 100644 (file)
@@ -581,7 +581,7 @@ angular.module('egCoreMod')
     service.init_patron = function(current) {
 
         if (!current)
-            return service.init_new_patron();
+            return $q.when(service.init_new_patron());
 
         service.patron = current;
         return $q.when(service.init_existing_patron(current));
@@ -656,6 +656,7 @@ angular.module('egCoreMod')
         });
 
         service.patron = patron;
+        return patron;
     }
 
     service.init_new_patron = function() {
@@ -1180,13 +1181,12 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore ,
 
         patronRegSvc.init(),
 
-    ]).then(function(){ return patronRegSvc.init_patron(patronSvc ? patronSvc.current : null) })
-      .then(patronRegSvc.get_user_settings)
-      .then(function() {
+    ]).then(function(){ return patronRegSvc.init_patron(patronSvc ? patronSvc.current : patronRegSvc.patron ) })
+      .then(function(patron) {
         // called after initTab and patronRegSvc.init have completed
         // in standalone mode, we have no patronSvc
         var prs = patronRegSvc;
-        $scope.patron = prs.patron;
+        $scope.patron = patron;
         $scope.field_doc = prs.field_doc;
         $scope.edit_profiles = prs.edit_profiles;
         $scope.ident_types = prs.ident_types;
@@ -1206,14 +1206,14 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore ,
         prs.user_settings = {};
 
         extract_hold_notify();
+        if ($scope.patron.isnew)
+            set_new_patron_defaults(prs);
+        
         $scope.handle_home_org_changed();
 
         if ($scope.org_settings['ui.patron.edit.default_suggested'])
             $scope.edit_passthru.vis_level = 1;
 
-        if ($scope.patron.isnew) 
-            set_new_patron_defaults(prs);
-
         // Stat cats are fetched from open-ils.storage, where 't'==1
         $scope.hasRequiredStatCat = prs.stat_cats.filter(
                 function(cat) {return cat.required() == 1} ).length > 0;