From: Bill Erickson Date: Tue, 16 Jun 2015 01:54:44 +0000 (-0400) Subject: LP#1464767 Sort browser client org selector X-Git-Tag: sprint4-merge-nov22~602 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=db936941e578a32ec4a12d5f4a33575ed262b571;p=working%2FEvergreen.git LP#1464767 Sort browser client org selector 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 Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/web/js/ui/default/staff/services/env.js b/Open-ILS/web/js/ui/default/staff/services/env.js index 25198fae7c..ad41fc12d5 100644 --- a/Open-ILS/web/js/ui/default/staff/services/env.js +++ b/Open-ILS/web/js/ui/default/staff/services/env.js @@ -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')