LP#1715697 & 1738242 & 1753005: Holdings Filtering Checkboxes
authorMike Rylander <mrylander@gmail.com>
Tue, 24 Apr 2018 19:21:37 +0000 (15:21 -0400)
committerJason Stephenson <jason@sigio.com>
Thu, 9 Aug 2018 13:17:50 +0000 (09:17 -0400)
When the appropriate checkbox is selected, display subordinate libraries of
the context library that do not have any holdings or empty volumes.

Additionally, the holdings view checkboxes for limiting detail display can
cause console alerts, and should be made visually interdependent.  This commit
addresses both of those issues.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Jason Stephenson <jason@sigio.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
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/cat/services/holdings.js

index b506f3f..8e3ff44 100644 (file)
     grid-controls="holdingsGridControls"
     persist-key="cat.holdings">
 
-     <eg-grid-menu-item handler="holdings_checkbox_handler"
+    <eg-grid-menu-item handler="holdings_checkbox_handler"
       label="[% l('Show empty volumes') %]"
       checkbox="holdings_show_empty"
       checked="holdings_show_empty"/>
+
+    <eg-grid-menu-item handler="holdings_checkbox_handler"
+      label="[% l('Show empty libraries') %]"
+      checkbox="holdings_show_empty_org"
+      checked="holdings_show_empty_org"/>
+
     <eg-grid-menu-item handler="holdings_checkbox_handler"
       label="[% l('Show copy detail') %]"
       checkbox="holdings_show_copies"
index e7ef534..9109ac8 100644 (file)
@@ -1028,9 +1028,10 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
         holdingsSvcInst.fetch({
             rid : $scope.record_id,
             org : $scope.holdings_ou,
-            copy: $scope.holdings_show_copies,
+            copy: $scope.holdings_show_vols ? $scope.holdings_show_copies : false,
             vol : $scope.holdings_show_vols,
-            empty: $scope.holdings_show_empty
+            empty: $scope.holdings_show_empty,
+            empty_org: $scope.holdings_show_empty_org
         }).then(function() {
             $scope.holdingsGridDataProvider.refresh();
         });
@@ -1043,9 +1044,10 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
         holdingsSvcInst.fetch({
             rid : $scope.record_id,
             org : $scope.holdings_ou,
-            copy: $scope.holdings_show_copies,
+            copy: $scope.holdings_show_vols ? $scope.holdings_show_copies : false,
             vol : $scope.holdings_show_vols,
-            empty: $scope.holdings_show_empty
+            empty: $scope.holdings_show_empty,
+            empty_org: $scope.holdings_show_empty_org
         }).then(function() {
             $scope.holdingsGridDataProvider.refresh();
         });
@@ -1053,13 +1055,16 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
 
     $scope.holdings_cb_changed = function(cb,newVal,norefresh) {
         $scope[cb] = newVal;
+        var x = $scope.holdings_show_vols ? $scope.holdings_show_copies : false;
+        $('#holdings_show_copies').prop('checked', x);
         egCore.hatch.setItem('cat.' + cb, newVal);
         if (!norefresh) holdingsSvcInst.fetch({
             rid : $scope.record_id,
             org : $scope.holdings_ou,
-            copy: $scope.holdings_show_copies,
+            copy: $scope.holdings_show_vols ? $scope.holdings_show_copies : false,
             vol : $scope.holdings_show_vols,
-            empty: $scope.holdings_show_empty
+            empty: $scope.holdings_show_empty,
+            empty_org: $scope.holdings_show_empty_org
         }).then(function() {
             $scope.holdingsGridDataProvider.refresh();
         });
@@ -1073,12 +1078,19 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
         egCore.hatch.getItem('cat.holdings_show_copies').then(function(x){
             if (typeof x ==  'undefined') x = true;
             $scope.holdings_cb_changed('holdings_show_copies',x,true);
+            x = $scope.holdings_show_vols ? x : false;
             $('#holdings_show_copies').prop('checked', x);
         }).then(function(){
             egCore.hatch.getItem('cat.holdings_show_empty').then(function(x){
                 if (typeof x ==  'undefined') x = true;
                 $scope.holdings_cb_changed('holdings_show_empty',x);
                 $('#holdings_show_empty').prop('checked', x);
+            }).then(function(){
+                egCore.hatch.getItem('cat.holdings_show_empty_org').then(function(x){
+                    if (typeof x ==  'undefined') x = true;
+                    $scope.holdings_cb_changed('holdings_show_empty_org',x);
+                    $('#holdings_show_empty_org').prop('checked', x);
+                })
             })
         })
     });
@@ -1091,6 +1103,10 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
         return !$scope.holdings_show_copies;
     }
 
+    $scope.empty_org_not_shown = function () {
+        return !$scope.holdings_show_empty_org;
+    }
+
     $scope.holdings_checkbox_handler = function (item) {
         $scope.holdings_cb_changed(item.checkbox,item.checked);
     }
index 3f4ec7d..2fa67b4 100644 (file)
@@ -26,7 +26,8 @@ function(egCore , $q) {
             org: this.org,
             copy: this.copy,
             vol: this.vol,
-            empty: this.empty
+            empty: this.empty,
+            empty_org: this.empty_org
         })
     };
 
@@ -41,6 +42,7 @@ function(egCore , $q) {
         }
 
         var rid = opts.rid;
+        var empty_org = opts.empty_org;
         var org = opts.org;
         var copy = opts.copy;
         var vol = opts.vol;
@@ -52,6 +54,7 @@ function(egCore , $q) {
         svc.ongoing = true;
 
         svc.rid = rid;
+        svc.empty_org = opts.empty_org;
         svc.org = org;
         svc.copy = opts.copy;
         svc.vol = opts.vol;
@@ -63,6 +66,9 @@ function(egCore , $q) {
         var org_list = egCore.org.descendants(org.id(), true);
         console.log('Holdings fetch with: rid='+rid+' org='+org_list+' copy='+copy+' vol='+vol+' empty='+empty);
 
+        svc.org_use_map = {};
+        org_list.map(function(o){svc.org_use_map[''+o]=0;})
+
         var p = egCore.pcrud.search(
             'acn',
             {record : rid, owning_lib : org_list, deleted : 'f'},
@@ -70,6 +76,7 @@ function(egCore , $q) {
         ).then(
             function() { // finished
                 if (p.cancel) return;
+
                 svc.copies = svc.copies.sort(
                     function (a, b) {
                         function compare_array (x, y, i) {
@@ -204,7 +211,10 @@ function(egCore , $q) {
                                     current_blob.cn_count++;
                                     current_blob.copy_count += cp.copy_count;
                                     current_blob.id_list = current_blob.id_list.concat(cp.id_list);
-                                    if (cp.raw) current_blob.raw = current_blob.raw.concat(cp.raw);
+                                    if (cp.raw) {
+                                        if (current_blob.raw) current_blob.raw = current_blob.raw.concat(cp.raw);
+                                        else current_blob.raw = cp.raw;
+                                    }
                                 } else {
                                     current_blob.barcode = current_blob.copy_count;
                                     current_blob.call_number = { label : current_blob.cn_count };
@@ -231,6 +241,40 @@ function(egCore , $q) {
                     }
                 }
 
+                if (empty_org) {
+
+                    var empty_org_list = [];
+                    angular.forEach(svc.org_use_map,function(v,k){
+                        if (v == 0) empty_org_list.push(k);
+                    });
+
+                    angular.forEach(empty_org_list, function (oid) {
+                        var owner = egCore.org.get(oid);
+                        if (owner.ou_type().can_have_vols() != 't') return;
+
+                        var owner_list = [];
+                        while (owner.parent_ou()) { // we're going to skip the top of the tree...
+                            owner_list.unshift(owner.shortname());
+                            owner = egCore.org.get(owner.parent_ou());
+                        }
+
+                        var owner_label = owner_list.join(' ... ');
+
+                        new_list.push({
+                            index      : index++,
+                            id_list    : [],
+                            call_number: { label : '' },
+                            barcode    : '',
+                            owner_id   : oid,
+                            owner_list : owner_list,
+                            owner_label: owner_label,
+                            copy_count : 0,
+                            cn_count   : 0,
+                            copy_alert_count : 0
+                        });
+                    });
+                }
+
                 svc.copies = new_list;
                 svc.ongoing = false;
             },
@@ -250,6 +294,7 @@ function(egCore , $q) {
 
                 var owner_id = cn.owning_lib();
                 var owner = egCore.org.get(owner_id);
+                svc.org_use_map[''+owner_id] += 1;
 
                 var owner_name_list = [];
                 while (owner.parent_ou()) { // we're going to skip the top of the tree...