From 5ca11047340415ab9aebc55c2a85a4af22d4a529 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 14 Oct 2016 16:00:06 -0400 Subject: [PATCH] add alerts column to several grids The item status, holdings, and checkout grids now have an alerts column that lists the number of copy alerts associated with the item as well as a button to manage them. Signed-off-by: Galen Charlton Conflicts: Open-ILS/web/js/ui/default/staff/cat/item/app.js Open-ILS/web/js/ui/default/staff/cat/services/holdings.js --- .../src/templates/staff/cat/catalog/t_holdings.tt2 | 4 ++ Open-ILS/src/templates/staff/cat/item/t_list.tt2 | 7 ++- .../src/templates/staff/circ/patron/t_checkout.tt2 | 6 +++ .../web/js/ui/default/staff/cat/catalog/app.js | 7 +++ Open-ILS/web/js/ui/default/staff/cat/item/app.js | 60 +++++++++++++++++++++- .../js/ui/default/staff/cat/services/holdings.js | 7 ++- .../js/ui/default/staff/circ/patron/checkout.js | 18 +++++++ 7 files changed, 105 insertions(+), 4 deletions(-) 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 108267766f..52d36da17c 100644 --- a/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 +++ b/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 @@ -122,6 +122,10 @@ + + {{item['copy_alert_count']}} + + diff --git a/Open-ILS/src/templates/staff/cat/item/t_list.tt2 b/Open-ILS/src/templates/staff/cat/item/t_list.tt2 index f08dcd48a7..0a70dcbdbd 100644 --- a/Open-ILS/src/templates/staff/cat/item/t_list.tt2 +++ b/Open-ILS/src/templates/staff/cat/item/t_list.tt2 @@ -77,7 +77,6 @@ - @@ -129,7 +128,11 @@ - + + {{item['copy_alert_count']}} + + +
diff --git a/Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2 index 2bb43ea96a..a5f5cac439 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2 @@ -116,6 +116,12 @@ + + + {{item['copy_alert_count']}} + + + 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 88ef6fa596..396126f671 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 @@ -1349,6 +1349,13 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e }); } + $scope.gridCellHandlers = {}; + $scope.gridCellHandlers.copyAlertsEdit = function(id) { + egCirc.manage_copy_alerts([id]).then(function() { + // update grid items? + }); + }; + $scope.transferItems = function (){ var xfer_target = egCore.hatch.getLocalItem('eg.cat.item_transfer_target'); var copy_ids = gatherSelectedHoldingsIds(); diff --git a/Open-ILS/web/js/ui/default/staff/cat/item/app.js b/Open-ILS/web/js/ui/default/staff/cat/item/app.js index 8807bffa17..de3e52e51f 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/item/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/item/app.js @@ -60,7 +60,7 @@ function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog flesh : 3, flesh_fields : { acp : ['call_number','location','status','location','floating','circ_modifier', - 'age_protect','circ_lib'], + 'age_protect','circ_lib','copy_alerts'], acn : ['record','prefix','suffix','label_class'], bre : ['simple_record','creator','editor'] }, @@ -87,6 +87,57 @@ function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog }, order_by : {circ : 'xact_start desc'}, limit : 1 + }; + + // resolved with the last received copy + service.fetch = function(barcode, id, noListDupes) { + var promise; + + if (barcode) { + promise = egCore.pcrud.search('acp', + {barcode : barcode, deleted : 'f'}, service.flesh); + } else { + promise = egCore.pcrud.retrieve('acp', id, service.flesh); + } + + var lastRes; + return promise.then( + function() {return lastRes}, + null, // error + + // notify reads the stream of copies, one at a time. + function(copy) { + + var flatCopy; + + egCore.pcrud.search('aihu', + {item : copy.id()}, {}, {idlist : true, atomic : true}) + .then(function(uses) { + copy._inHouseUseCount = uses.length; + }); + + if (noListDupes) { + // use the existing copy if possible + flatCopy = service.copies.filter( + function(c) {return c.id == copy.id()})[0]; + } + + if (!flatCopy) { + flatCopy = egCore.idl.toHash(copy, true); + flatCopy.index = service.index++; + flatCopy.copy_alert_count = copy.copy_alerts().filter(function(aca) { + return !aca.ack_time(); + }).length; + + service.copies.unshift(flatCopy); + } + + return lastRes = { + copy : copy, + index : flatCopy.index + } + } + ); } //Retrieve separate copy, combcirc, and accs information @@ -713,6 +764,13 @@ function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog }); } + $scope.gridCellHandlers = {}; + $scope.gridCellHandlers.copyAlertsEdit = function(id) { + egCirc.manage_copy_alerts([id]).then(function() { + // update grid items? + }); + }; + $scope.showBibHolds = function () { angular.forEach(gatherSelectedRecordIds(), function (r) { var url = egCore.env.basePath + 'cat/catalog/record/' + r + '/holds'; 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 3f4ec7d3af..67c64b25d2 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 @@ -15,7 +15,7 @@ function(egCore , $q) { service.prototype.flesh = { flesh : 2, flesh_fields : { - acp : ['status','location','circ_lib','parts','age_protect'], + acp : ['status','location','circ_lib','parts','age_protect','copy_alerts'], acn : ['prefix','suffix','copies'] } } @@ -117,6 +117,11 @@ function(egCore , $q) { } }); + // create virtual field for copy alert count + angular.forEach(svc.copies, function (cp) { + cp.copy_alert_count = cp.copy_alerts.length; + }); + // create a label using just the unique part of the owner list var index = 0; var prev_owner_list; diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js b/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js index 362e0369da..d0fe14c8a1 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js @@ -202,6 +202,17 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc , // Non-cat circs don't return the full list of circs. // Refresh the list of non-cat circs from the server. patronSvc.getUserNonCats(patronSvc.current.id()); + row_item.copy_alert_count = 0; + } else { + row_item.copy_alert_count = 0; + egCore.pcrud.search( + 'aca', + { copy : co_resp.data.acp.id(), ack_time : null }, + null, + { atomic : true } + ).then(function(list) { + row_item.copy_alert_count = list.length; + }); } } @@ -225,6 +236,13 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc , }); } + $scope.gridCellHandlers = {}; + $scope.gridCellHandlers.copyAlertsEdit = function(id) { + egCirc.manage_copy_alerts([id]).then(function() { + // update grid items? + }); + }; + $scope.print_receipt = function() { var print_data = {circulations : []} -- 2.11.0