From: Mike Rylander <mrylander@gmail.com> Date: Tue, 24 Apr 2018 19:21:37 +0000 (-0400) Subject: LP#1715697 & 1738242 & 1753005: Holdings Filtering Checkboxes X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=5a1d701bcc1b5b25697b03aae3bf837f6e6921f4;p=contrib%2FConifer.git LP#1715697 & 1738242 & 1753005: Holdings Filtering Checkboxes 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> --- 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 c6bf4e07ae..222ea20365 100644 --- a/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 +++ b/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 @@ -18,11 +18,16 @@ 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" 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 4b3d186975..5debd68417 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 @@ -1036,9 +1036,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(); }); @@ -1051,9 +1052,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(); }); @@ -1061,13 +1063,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(); }); @@ -1081,12 +1086,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); + }) }) }) }); @@ -1099,6 +1111,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); } diff --git a/Open-ILS/web/js/ui/default/staff/cat/services/holdings.js b/Open-ILS/web/js/ui/default/staff/cat/services/holdings.js index eb835f5a80..b4fb738524 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/services/holdings.js +++ b/Open-ILS/web/js/ui/default/staff/cat/services/holdings.js @@ -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) { @@ -210,7 +217,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 }; @@ -237,6 +247,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; }, @@ -256,6 +300,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...