JBAS-2832 Trim copy editor shelf locations
authorBill Erickson <berickxx@gmail.com>
Mon, 4 Feb 2019 22:10:10 +0000 (17:10 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:49:28 +0000 (15:49 -0400)
Only show copy locations for workstation and parent org units in the
browser client copy edit UI, regardless of which orgs the user has
access to edit.

KCLS maintains a duplicate array of copy location for each org and
performs nightly jobs to ensure the location match the copy's circ lib.
Becuase of this, only a single list of locations need be displayed.

If a copy links to a location outside of the scope of here + parent org
units, add its copy location to the list as well, suffixed by owning lib
to differentiate.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/templates/staff/cat/volcopy/t_attr_edit.tt2
Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js

index 7e58ebb..c8fe573 100644 (file)
                 <div class="col-md-6" ng-class="{'bg-success': working.location !== undefined}">
                     <select class="form-control"
                         ng-disabled="!defaults.attributes.location" ng-model="working.location"
-                        ng-options="l.id() as i18n.ou_qualified_location_name(l) for l in location_list"
+                        ng-options="l.id() as l.name() for l in selectableLocations()"
                     ></select>
                     <div class="container" ng-show="working.MultiMap.location.length > 1 && working.location === undefined">
                         <eg-list-counts label="[% l('Multiple locations') %]" list="working.MultiMap.location" render="locationName" on-select="select_by_location"></eg-list-counts>
index 22a41ea..76dfb08 100644 (file)
@@ -1897,6 +1897,59 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore ,
         $scope.location_list = [];
         createSimpleUpdateWatcher('location');
 
+        // KCLS JBAS-2184
+        // Limit copy location selector to locations at the current
+        // workstation (and parent orgs) regardless of the copy's
+        // circ/owning lib.  Nightly CRON job applies the correct 
+        // location (matching by name) to any copies whose circ_lib
+        // does not match the location's owning lib.
+        $scope.selectableLocations = function() {
+            var orgs = egCore.org.fullPath(egCore.auth.user().ws_ou(), true)
+                .map(function(o) { return Number(o); });
+
+            var locs = $scope.location_list.filter(function(loc) {
+                return orgs.indexOf(Number(loc.owning_lib().id())) >= 0;
+            });
+
+            // See if the current working location points to a copy location
+            // that is outside of the set of local copy locations.
+            if ($scope.working && $scope.working.location) {
+                var curLoc = Number($scope.working.location);
+
+                var exists = locs.filter(
+                    function(l) {return Number(l.id()) === curLoc})[0];
+
+                if (!exists) {
+                    // The current working location points to a remote copy
+                    // location, add the remote copy location to the selector
+                    // so we can accurately represent the current copy location
+                    // value for the copy.
+
+                    var remoteLoc = $scope.location_list.filter(
+                        function(l) {return Number(l.id()) === curLoc})[0];
+
+                    if (remoteLoc) {
+                        if (!remoteLoc.name().match(/\)$/)) { // boo hack
+                            // When adding a remote copy location back to the
+                            // list, append the location name with the owning
+                            // library to differentiate it from the set of
+                            // local copy locations.  This helps avoid
+                            // confusing duplicates.
+                            remoteLoc.name(remoteLoc.name() + 
+                                ' (' + remoteLoc.owning_lib().shortname() + ')');
+                        }
+                        locs.push(remoteLoc);
+                        locs.sort(function(a, b) {
+                            // Ensure the new copy location is sorted into place
+                            return a.name().toUpperCase() < b.name().toUpperCase() ? -1 : 1
+                        });
+                    }
+                }
+            }
+
+            return locs;
+        }
+
         $scope.status_list = [];
         itemSvc.get_magic_statuses().then(function(list){
             $scope.magic_status_list = list;