LP#1724019 Offline Circulation Orgs Alphabetized
authorMike Risher <mrisher@catalyte.io>
Fri, 7 Aug 2020 20:14:40 +0000 (20:14 +0000)
committerBill Erickson <berickxx@gmail.com>
Mon, 17 Aug 2020 14:22:08 +0000 (10:22 -0400)
On the offline circulation interface adjust the orgs so that they're
sorted alphabetically.  Preserve the org hierarchy.

Signed-off-by: Mike Risher <mrisher@catalyte.io>
 Changes to be committed:
modified:   Open-ILS/web/js/ui/default/staff/services/env.js
modified:   Open-ILS/web/js/ui/default/staff/services/lovefield.js

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/web/js/ui/default/staff/services/env.js
Open-ILS/web/js/ui/default/staff/services/lovefield.js

index cf768b1..2d0f197 100644 (file)
@@ -157,6 +157,14 @@ function($q,  $window , $injector , egAuth,  egPCRUD,  egIDL) {
      */
     service.loadClasses = ['aou'];
 
+    // sort orgs at each level by shortname
+    service.sort_aou = function(node) {
+        node.children(node.children().sort(function(a, b) {
+            return a.shortname() < b.shortname() ? -1 : 1;
+        }));
+        angular.forEach(node.children(), service.sort_aou);
+    }
+
     /*
      * Default class loaders.  Only add classes directly to this file
      * that are loaded practically always.  All other app-specific
@@ -184,19 +192,11 @@ function($q,  $window , $injector , egAuth,  egPCRUD,  egIDL) {
                     return $q.when(tree);
                 }
     
-                // sort orgs at each level by shortname
-                function sort_aou(node) {
-                    node.children(node.children().sort(function(a, b) {
-                        return a.shortname() < b.shortname() ? -1 : 1;
-                    }));
-                    angular.forEach(node.children(), sort_aou);
-                }
-    
                 return egPCRUD.search('aou', {parent_ou : null}, 
                     {flesh : -1, flesh_fields : {aou : ['children', 'ou_type']}}
                 ).then(
                     function(tree) {
-                        sort_aou(tree);
+                        service.sort_aou(tree);
                         $window.sessionStorage.setItem(
                             'eg.env.aou.tree', js2JSON(tree));
                         service.absorbTree(tree, 'aou');
index 683390a..0e7d2b3 100644 (file)
@@ -448,6 +448,11 @@ angular.module('egCoreMod')
                     }
                 });
 
+                if (type == 'aou') {
+                    // Sort the org tree before absorbing
+                    egCore.env.sort_aou(top);
+                }
+
                 egCore.env.absorbTree(top, type, true)
                 return $q.when(true)
             });