LP#1402797 Profile Group no longer causes second search to fail, but it does not...
authorMike Rylander <mrylander@gmail.com>
Mon, 2 Feb 2015 17:06:04 +0000 (12:06 -0500)
committerBill Erickson <berickxx@gmail.com>
Wed, 25 Feb 2015 16:16:07 +0000 (11:16 -0500)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/web/js/ui/default/staff/circ/patron/app.js

index 4afa173..14a9bb8 100644 (file)
@@ -771,9 +771,26 @@ function($scope,  $q,  $routeParams,  $timeout,  $window,  $location,  egCore,
         propagate = patronSvc.urlSearch.search;
     }
 
+    if (egCore.env.pgt) {
+        $scope.profiles = egCore.env.pgt.list;
+    } else {
+        egCore.pcrud.search('pgt', {parent : null}, 
+            {flesh : -1, flesh_fields : {pgt : ['children']}}
+        ).then(
+            function(tree) {
+                egCore.env.absorbTree(tree, 'pgt')
+                $scope.profiles = egCore.env.pgt.list;
+            }
+        );
+    }
+
     if (propagate) {
         // populate the search form with our cached / preexisting search info
         angular.forEach(propagate, function(val, key) {
+            if (key == 'profile')
+                val.value = $scope.profiles.filter(function(p) { p.id() == val.value })[0];
+            if (key == 'home_ou')
+                val.value = egCore.org.get(val.value);
             $scope.searchArgs[key] = val.value;
         });
     }
@@ -884,19 +901,6 @@ function($scope,  $q,  $routeParams,  $timeout,  $window,  $location,  egCore,
 
     $scope.patronSearchGridProvider = provider;
 
-    if (egCore.env.pgt) {
-        $scope.profiles = egCore.env.pgt.list;
-    } else {
-        egCore.pcrud.search('pgt', {parent : null}, 
-            {flesh : -1, flesh_fields : {pgt : ['children']}}
-        ).then(
-            function(tree) {
-                egCore.env.absorbTree(tree, 'pgt')
-                $scope.profiles = egCore.env.pgt.list;
-            }
-        );
-    }
-
     // determine the tree depth of the profile group
     $scope.pgt_depth = function(grp) {
         var d = 0;