From: Kyle Huckins Date: Wed, 31 Jul 2019 16:34:05 +0000 (+0000) Subject: lp1739277 AngJS Org Select Class Callback X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ec681642cba1390648b00ca0a5bc6dfd4edc103b;p=working%2FEvergreen.git lp1739277 AngJS Org Select Class Callback - Refactor Org Selector to contain org ID information in addition to shortname. - Add OrgClassCallback support to AngJS egOrgSelector, featuring an array of ids and a function returning a CSS key/value pair. - Implement OrgClassCallback in the AngJS Catalog Holdings View UI. Signed-off-by: Kyle Huckins Changes to be committed: modified: Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 modified: Open-ILS/src/templates/staff/share/t_org_select.tt2 modified: Open-ILS/web/js/ui/default/staff/cat/catalog/app.js modified: Open-ILS/web/js/ui/default/staff/services/ui.js --- diff --git a/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 b/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 index 4e7106ed54..10aa973a92 100644 --- a/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 +++ b/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 @@ -4,7 +4,9 @@
[% l('Show holdings at or below') %] - + +
diff --git a/Open-ILS/src/templates/staff/share/t_org_select.tt2 b/Open-ILS/src/templates/staff/share/t_org_select.tt2 index 613c28d33b..26454efb08 100644 --- a/Open-ILS/src/templates/staff/share/t_org_select.tt2 +++ b/Open-ILS/src/templates/staff/share/t_org_select.tt2 @@ -1,7 +1,8 @@ diff --git a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js index 5789dba3ec..a60cad145c 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js @@ -1223,6 +1223,26 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e $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( diff --git a/Open-ILS/web/js/ui/default/staff/services/ui.js b/Open-ILS/web/js/ui/default/staff/services/ui.js index f8f7cd16a3..a9e7142f4a 100644 --- a/Open-ILS/web/js/ui/default/staff/services/ui.js +++ b/Open-ILS/web/js/ui/default/staff/services/ui.js @@ -1081,7 +1081,12 @@ function($uibModal , $interpolate , egCore) { // 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', @@ -1122,7 +1127,7 @@ function($uibModal , $interpolate , egCore) { $scope.hiddenTest(org.id()) ); }).map(function(org) { - return formatName(org); + return {label: formatName(org), orgId: org.id()}; }); // Apply default values @@ -1133,7 +1138,7 @@ function($uibModal , $interpolate , egCore) { var org = egCore.org.get(orgId); if (org) { $scope.selected = org; - $scope.selectedName = org.shortname(); + $scope.selectedName = {label: formatName(org), orgId: org.id()}; } } } @@ -1141,7 +1146,7 @@ function($uibModal , $interpolate , egCore) { 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 @@ -1185,20 +1190,24 @@ function($uibModal , $interpolate , egCore) { $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()); @@ -1215,7 +1224,7 @@ function($uibModal , $interpolate , egCore) { 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; @@ -1234,9 +1243,9 @@ function($uibModal , $interpolate , egCore) { 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 = {}; } }); }