lp1744756 Utilize Parent Trees
authorKyle Huckins <khuckins@catalyte.io>
Wed, 29 Aug 2018 15:20:17 +0000 (15:20 +0000)
committerKathy Lussier <klussier@masslnc.org>
Thu, 30 Aug 2018 16:09:03 +0000 (12:09 -0400)
- Allow Patron Edit interface to make use of Parent OU trees when
expect tree doesn't exist.

Signed-off-by: Kyle Huckins <khuckins@catalyte.io>

 Changes to be committed:
modified:   Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js

Signed-off-by: Kathy Lussier <klussier@masslnc.org>

Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js

index 640bb3b..6a2d092 100644 (file)
@@ -483,14 +483,23 @@ angular.module('egCoreMod')
         }
     }
 
+    service.searchPermGroupEntries = function(org) {
+        return egCore.pcrud.search('pgtde', {org: org, parent: null},
+            {flesh: -1, flesh_fields: {pgtde: ['grp', 'children']}}, {atomic: true}
+        ).then(function(treeArray) {
+            if (!treeArray.length && egCore.org.get(org).parent_ou()) {
+                return service.searchPermGroupEntries(egCore.org.get(org).parent_ou());
+            }
+            return treeArray;
+        });
+    }
+
     service.get_perm_group_entries = function() {
         if (egCore.env.pgtde) {
             service.profile_entries = egCore.env.pgtde.list;
             return service.set_edit_profile_entries();
         } else {
-            return egCore.pcrud.search('pgtde', {org: egCore.auth.user().ws_ou(), parent: null},
-                {flesh : -1, flesh_fields : {pgtde : ['grp', 'children']}}, {atomic : true}
-            ).then(function(treeArray) {
+            return service.searchPermGroupEntries(egCore.auth.user().ws_ou()).then(function(treeArray) {
                 function compare(a,b) {
                   if (a.position() > b.position())
                     return -1;