From: Mike Risher Date: Fri, 7 Aug 2020 20:14:40 +0000 (+0000) Subject: LP#1724019 Offline Circulation Orgs Alphabetized X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a68ac98314c9d591843fe7ee19de0667381a45fe;p=evergreen%2Fequinox.git LP#1724019 Offline Circulation Orgs Alphabetized On the offline circulation interface adjust the orgs so that they're sorted alphabetically. Preserve the org hierarchy. Signed-off-by: Mike Risher 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 --- 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 cf768b122c..2d0f197474 100644 --- a/Open-ILS/web/js/ui/default/staff/services/env.js +++ b/Open-ILS/web/js/ui/default/staff/services/env.js @@ -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'); diff --git a/Open-ILS/web/js/ui/default/staff/services/lovefield.js b/Open-ILS/web/js/ui/default/staff/services/lovefield.js index 683390aafd..0e7d2b3804 100644 --- a/Open-ILS/web/js/ui/default/staff/services/lovefield.js +++ b/Open-ILS/web/js/ui/default/staff/services/lovefield.js @@ -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) });