lp1739277 Holdings View Owning Libraries Bolded
authorKyle Huckins <khuckins@catalyte.io>
Mon, 17 Jun 2019 23:09:39 +0000 (23:09 +0000)
committerKyle Huckins <khuckins@catalyte.io>
Wed, 26 Jun 2019 17:05:07 +0000 (17:05 +0000)
- Create an orgstyle parameter for the orgSelector, which contains a list
of applicable org units, and an apply function to apply the desired changes
to the shortname as displayed in the selector.

Signed-off-by: Kyle Huckins <khuckins@catalyte.io>
modified:   Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2
modified:   Open-ILS/web/js/ui/default/staff/cat/catalog/app.js
modified:   Open-ILS/web/js/ui/default/staff/services/ui.js

Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js
Open-ILS/web/js/ui/default/staff/services/ui.js

index b694d6b..87f4987 100644 (file)
@@ -4,7 +4,9 @@
     <div class="col-md-3">
       <div class="input-group">
         <span class="input-group-addon">[% l('Show holdings at or below') %]</span>
-        <eg-org-selector selected="holdings_ou" onchange="holdings_ou_changed" sticky-setting="cat.holdings_view_ou"></eg-org-selector>
+        <eg-org-selector selected="holdings_ou" onchange="holdings_ou_changed"
+            sticky-setting="cat.holdings_view_ou"
+            styleorg="bold_ous"></eg-org-selector>
       </div>
     </div>
   </div>
index 2988d95..308da07 100644 (file)
@@ -1204,6 +1204,28 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
         $scope.holdings_cb_changed(item.checkbox,item.checked);
     }
 
+    $scope.ous_to_style = []
+    egCore.net.request(
+        'open-ils.search',
+        'open-ils.search.biblio.copy_counts.retrieve.staff',
+        $scope.record_id
+    ).then(function(res) {
+        var ous = [];
+        if (res) {
+            angular.forEach(res, function(copy_count) {
+                $scope.ous_to_style.push(copy_count[0]);
+            });
+        }
+        return ous;
+    });
+    $scope.bold_ous = {
+        orgArray : $scope.ous_to_style,
+        apply : function(str, org_shortname) {
+                str = str + '<b>' + org_shortname; + '</b>';
+                return str;
+        }
+    }
+
     function gatherSelectedHoldingsIds () {
         var cp_id_list = [];
         angular.forEach(
index 0fe9918..deba022 100644 (file)
@@ -1081,7 +1081,10 @@ function($uibModal , $interpolate , egCore) {
 
             // optional name of settings key for persisting
             // the last selected org unit
-            stickySetting : '@'
+            stickySetting : '@',
+
+            // optional parameters to style Org Units
+            styleorg : '='
         },
 
         templateUrl : './share/t_org_select',
@@ -1093,7 +1096,12 @@ function($uibModal , $interpolate , egCore) {
             var secretEmptyKey = '_INTERNAL_';
 
             function formatName(org) {
-                return " ".repeat(org.ou_type().depth()) + org.shortname();
+                var org_str = " ".repeat(org.ou_type().depth());
+                if ($scope.styleorg && $scope.styleorg.orgArray.includes(org.id())) {
+                    return $scope.styleorg.apply(org_str, org.shortname());
+                } else {
+                    return  org_str + org.shortname();
+                }
             }
 
             // avoid linking the full fleshed tree to the scope by 
@@ -1112,9 +1120,7 @@ function($uibModal , $interpolate , egCore) {
                 }
             ).then(
                 function() {
-
                     $scope.selecteName = '';
-
                     $scope.shortNames = egCore.org.list()
                     .filter(function(org) {
                         return !(
@@ -1191,14 +1197,14 @@ function($uibModal , $interpolate , egCore) {
 
             // Trim leading tree-spaces before displaying selected value
             $scope.formatDisplayName = function(shortName) {
-                return ($scope.selectedName || '').trim();
+                return ($scope.selectedName || '').trim().replace(/<[^>]*>?/gm, '');
             }
 
             $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.trim().replace(/<[^>]*>?/gm, '');
                     })[0];
 
                     return org && $scope.disableTest(org.id());
@@ -1215,7 +1221,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.trim().replace(/<[^>]*>?/gm, '')
                     })[0];
                 } else {
                     $scope.selected = null;