lp1724019 offline working locations unsorted
authorMike Risher <mrisher@catalyte.io>
Fri, 17 Jan 2020 21:15:25 +0000 (21:15 +0000)
committerMike Risher <mrisher@catalyte.io>
Tue, 11 Feb 2020 19:40:36 +0000 (19:40 +0000)
The offline working locations are not sorted alphabetically. This
fix involves removing all indenting and putting all orgs in
alphabetical order. This change is only being applied to the
offline working locations dropdown of orgs.

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

Open-ILS/src/templates/staff/offline-interface.tt2
Open-ILS/web/js/ui/default/staff/services/ui.js

index dc7b56b..eb8ca80 100644 (file)
@@ -18,7 +18,8 @@
       </div>
       <div class="input-group-addon"><b>[% l('Working location') %]</b></div>
       <div class="input-group-addon">
-        <eg-org-selector sticky-setting="eg.org.offline_location" selected="org"></eg-org-selector>
+        <eg-org-selector sticky-setting="eg.org.offline_location" selected="org"
+          alphabetized-orgs="true"></eg-org-selector>
       </div>
       <div class="input-group-addon">
         <button
index f8f7cd1..3ac9615 100644 (file)
@@ -1081,7 +1081,10 @@ function($uibModal , $interpolate , egCore) {
 
             // optional name of settings key for persisting
             // the last selected org unit
-            stickySetting : '@'
+            stickySetting : '@',
+
+            // if set to true, remove indenting and alphabetize org list
+            alphabetizedOrgs : '@'
         },
 
         templateUrl : './share/t_org_select',
@@ -1093,7 +1096,11 @@ function($uibModal , $interpolate , egCore) {
             var secretEmptyKey = '_INTERNAL_';
 
             function formatName(org) {
-                return " ".repeat(org.ou_type().depth()) + org.shortname();
+                if ($scope.alphabetizedOrgs == "true") {
+                    return " " + org.shortname();
+                } else {
+                    return " ".repeat(org.ou_type().depth()) + org.shortname();
+                }
             }
 
             // avoid linking the full fleshed tree to the scope by 
@@ -1112,9 +1119,7 @@ function($uibModal , $interpolate , egCore) {
                 }
             ).then(
                 function() {
-
                     $scope.selecteName = '';
-
                     $scope.shortNames = egCore.org.list()
                     .filter(function(org) {
                         return !(
@@ -1124,7 +1129,14 @@ function($uibModal , $interpolate , egCore) {
                     }).map(function(org) {
                         return formatName(org);
                     });
-    
+                    if ($scope.alphabetizedOrgs == "true" && $scope.shortNames) {
+                        $scope.shortNames.sort(function(a, b){
+                            if(a < b) { return -1; }
+                            if(a > b) { return 1; }
+                            return 0;
+                        })
+                    }
+
                     // Apply default values
     
                     if ($scope.stickySetting) {