$scope.holdings_cb_changed(item.checkbox,item.checked);
}
+ $scope.orgClassCallback = {
+ apply: function(id, orgs) {
+ if (orgs.includes(id)) return {'font-weight': 'bold'};
+ return {};
+ },
+ orgs: []
+ };
+
+ egCore.net.request(
+ 'open-ils.search',
+ 'open-ils.search.biblio.copy_counts.retrieve.staff',
+ $scope.record_id
+ ).then(function(res) {
+ if (res) {
+ angular.forEach(res, function(copy_count) {
+ $scope.orgClassCallback.orgs.push(copy_count[0]);
+ });
+ }
+ });
+
function gatherSelectedHoldingsIds () {
var cp_id_list = [];
angular.forEach(
// optional name of settings key for persisting
// the last selected org unit
- stickySetting : '@'
+ stickySetting : '@',
+
+ // Function which should return a string value representing
+ // a CSS class name to use for styling each org unit label
+ // in the selector.
+ orgClassCallback : '='
},
templateUrl : './share/t_org_select',
$scope.hiddenTest(org.id())
);
}).map(function(org) {
- return formatName(org);
+ return {label: formatName(org), orgId: org.id()};
});
// Apply default values
var org = egCore.org.get(orgId);
if (org) {
$scope.selected = org;
- $scope.selectedName = org.shortname();
+ $scope.selectedName = {label: formatName(org), orgId: org.id()};
}
}
}
if (!$scope.selected && !$scope.nodefault && egCore.auth.user()) {
var org = egCore.org.get(egCore.auth.user().ws_ou());
$scope.selected = org;
- $scope.selectedName = org.shortname();
+ $scope.selectedName = {label: formatName(org), orgId: org.id()};
}
fire_orgsel_onchange(); // no-op if nothing is selected
$scope.compare = function(shortName, inputValue) {
return inputValue === secretEmptyKey ||
- (shortName || '').toLowerCase().trim()
+ (shortName.label || '').toLowerCase().trim()
.indexOf((inputValue || '').toLowerCase().trim()) > -1;
}
// Trim leading tree-spaces before displaying selected value
$scope.formatDisplayName = function(shortName) {
- return ($scope.selectedName || '').trim();
+ if ($scope.selectedName && $scope.selectedName.label) {
+ return $scope.selectedName.label.trim();
+ } else {
+ return '';
+ }
}
$scope.orgIsDisabled = function(shortName) {
if ($scope.alldisabled === 'true') return true;
if (shortName && $scope.disableTest) {
var org = egCore.org.list().filter(function(org) {
- return org.shortname() === shortName.trim();
+ return org.shortname() === shortName.label.trim();
})[0];
return org && $scope.disableTest(org.id());
if ($scope.selectedName &&
!$scope.orgIsDisabled($scope.selectedName)) {
$scope.selected = egCore.org.list().filter(function(org) {
- return org.shortname() === $scope.selectedName.trim()
+ return org.shortname() === $scope.selectedName.label.trim()
})[0];
} else {
$scope.selected = null;
function watch_external_changes() {
dewatcher = $scope.$watch('selected', function(newVal, oldVal) {
if (newVal) {
- $scope.selectedName = newVal.shortname();
+ $scope.selectedName = {label: formatName(newVal), orgId: newVal.id()};
} else {
- $scope.selectedName = '';
+ $scope.selectedName = {};
}
});
}