<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>
$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;