LP#1464767 Sort browser client org selector
authorBill Erickson <berickxx@gmail.com>
Tue, 16 Jun 2015 01:54:44 +0000 (21:54 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Thu, 25 Feb 2016 22:31:54 +0000 (17:31 -0500)
Sort each level of the shared org unit tree in the browser client by org
unit shortname.  This primarily affects org unit selectors / dropdowns
(unless otherwise sorted).

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

index 25198fa..ad41fc1 100644 (file)
@@ -146,10 +146,19 @@ function($q,  $window , 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);
                     $window.sessionStorage.setItem(
                         'eg.env.aou.tree', js2JSON(tree));
                     service.absorbTree(tree, 'aou')