From d5100e12907707beee8cd9c2170faf5a278d7b5e Mon Sep 17 00:00:00 2001 From: Kyle Huckins Date: Thu, 16 Aug 2018 21:07:19 +0000 Subject: [PATCH] lp1777675 Support Inventory Date Refactor - Properly utilize linked idl field for grid additions. - Remove excessive fetching. - Ensure checkin interface Inventory Date displays a static, non-updating timestamp. Signed-off-by: Kyle Huckins Changes to be committed: modified: Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm modified: Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm modified: Open-ILS/src/templates/staff/cat/bucket/copy/t_pending.tt2 modified: Open-ILS/src/templates/staff/cat/bucket/copy/t_view.tt2 modified: Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 modified: Open-ILS/src/templates/staff/cat/item/t_list.tt2 modified: Open-ILS/src/templates/staff/cat/item/t_summary_pane.tt2 modified: Open-ILS/src/templates/staff/circ/checkin/t_checkin_table.tt2 modified: Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js modified: Open-ILS/web/js/ui/default/staff/cat/services/holdings.js modified: Open-ILS/web/js/ui/default/staff/circ/checkin/app.js modified: Open-ILS/web/js/ui/default/staff/circ/services/item.js Signed-off-by: Kathy Lussier Conflicts: Open-ILS/web/js/ui/default/staff/circ/services/item.js --- .../src/perlmods/lib/OpenILS/Application/Circ.pm | 17 +++++--- .../lib/OpenILS/Application/Circ/Circulate.pm | 3 +- .../templates/staff/cat/bucket/copy/t_pending.tt2 | 4 +- .../src/templates/staff/cat/bucket/copy/t_view.tt2 | 4 +- .../src/templates/staff/cat/catalog/t_holdings.tt2 | 4 +- Open-ILS/src/templates/staff/cat/item/t_list.tt2 | 4 +- .../templates/staff/cat/item/t_summary_pane.tt2 | 4 +- .../staff/circ/checkin/t_checkin_table.tt2 | 4 +- .../web/js/ui/default/staff/cat/bucket/copy/app.js | 18 -------- .../js/ui/default/staff/cat/services/holdings.js | 20 ++------- .../web/js/ui/default/staff/circ/checkin/app.js | 3 ++ .../web/js/ui/default/staff/circ/services/item.js | 50 +++++----------------- 12 files changed, 41 insertions(+), 94 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm index 047feeb58b..ddddbc83ae 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm @@ -380,20 +380,23 @@ sub update_last_copy_inventory { return $e->die_event unless $e->checkauth; my $copies = $$args{copy_list}; - foreach my $copy (@$copies) { - my $existing_alci = $e->search_asset_last_copy_inventory({copy => $copy})->[0]; + foreach my $copyid (@$copies) { + my $copy = $e->retrieve_asset_copy($copyid); + my $alci = $e->search_asset_last_copy_inventory({copy => $copyid})->[0]; - if($existing_alci) { - $existing_alci->inventory_date('now'); - $existing_alci->inventory_workstation($e->requestor->wsid); - $e->update_asset_last_copy_inventory($existing_alci) or return $e->die_event; + if($alci) { + $alci->inventory_date('now'); + $alci->inventory_workstation($e->requestor->wsid); + $e->update_asset_last_copy_inventory($alci) or return $e->die_event; } else { my $alci = Fieldmapper::asset::last_copy_inventory->new; $alci->inventory_date('now'); $alci->inventory_workstation($e->requestor->wsid); - $alci->copy($copy); + $alci->copy($copy->id); $e->create_asset_last_copy_inventory($alci) or return $e->die_event; } + + $copy->last_copy_inventory($alci); } $e->commit; return 1; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm index c3de5b74ba..e25c8c266d 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -3969,7 +3969,8 @@ sub checkin_flesh_events { if($alci->[0]) { $self->last_copy_inventory->id($alci->[0]->id); } - } + } + $self->copy->last_copy_inventory($self->last_copy_inventory); for my $evt (@{$self->events}) { diff --git a/Open-ILS/src/templates/staff/cat/bucket/copy/t_pending.tt2 b/Open-ILS/src/templates/staff/cat/bucket/copy/t_pending.tt2 index 321139b701..60c1146242 100644 --- a/Open-ILS/src/templates/staff/cat/bucket/copy/t_pending.tt2 +++ b/Open-ILS/src/templates/staff/cat/bucket/copy/t_pending.tt2 @@ -58,7 +58,7 @@ {{item['call_number.record.simple_record.title']}} - - + + diff --git a/Open-ILS/src/templates/staff/cat/bucket/copy/t_view.tt2 b/Open-ILS/src/templates/staff/cat/bucket/copy/t_view.tt2 index b49bc22061..43f3ee0dea 100644 --- a/Open-ILS/src/templates/staff/cat/bucket/copy/t_view.tt2 +++ b/Open-ILS/src/templates/staff/cat/bucket/copy/t_view.tt2 @@ -43,7 +43,7 @@ {{item['call_number.record.simple_record.title']}} - - + + 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 a4b8712629..9241250a08 100644 --- a/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 +++ b/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 @@ -123,8 +123,8 @@ {{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 0cd7b1686a..e97adb896e 100644 --- a/Open-ILS/src/templates/staff/cat/item/t_list.tt2 +++ b/Open-ILS/src/templates/staff/cat/item/t_list.tt2 @@ -137,8 +137,8 @@ {{item['copy_alert_count']}} - - + + diff --git a/Open-ILS/src/templates/staff/cat/item/t_summary_pane.tt2 b/Open-ILS/src/templates/staff/cat/item/t_summary_pane.tt2 index a37271134b..e67ba11033 100644 --- a/Open-ILS/src/templates/staff/cat/item/t_summary_pane.tt2 +++ b/Open-ILS/src/templates/staff/cat/item/t_summary_pane.tt2 @@ -178,10 +178,10 @@
[% l('Inventory Date') %]
-
{{last_copy_inventory.inventory_date() | date:egDateAndTimeFormat}}
+
{{copy.last_copy_inventory().inventory_date() | date:egDateAndTimeFormat}}
[% l('Inventory Workstation') %]
-
{{last_copy_inventory.inventory_workstation().name()}}
+
{{copy.last_copy_inventory().inventory_workstation().name()}}
diff --git a/Open-ILS/src/templates/staff/circ/checkin/t_checkin_table.tt2 b/Open-ILS/src/templates/staff/circ/checkin/t_checkin_table.tt2 index ff9b23407d..aef321d4a6 100644 --- a/Open-ILS/src/templates/staff/circ/checkin/t_checkin_table.tt2 +++ b/Open-ILS/src/templates/staff/circ/checkin/t_checkin_table.tt2 @@ -121,7 +121,7 @@ - - + + diff --git a/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js b/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js index ba19f95705..f39346ef35 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js @@ -400,14 +400,6 @@ function($scope, $routeParams, bucketSvc , egGridDataProvider, egCore) { return null; }, allItemsRetrieved : function() { - angular.forEach($scope.gridControls.allItems(), function(copy) { - bucketSvc.fetchRecentInventoryData(copy).then(function(alci) { - if (alci) { - copy._last_inventory_date = alci.inventory_date(); - copy._last_inventory_workstation = alci.inventory_workstation().name(); - } - }); - }); $scope.context.selectPendingBC = true; } } @@ -535,16 +527,6 @@ function($scope, $q , $routeParams , $timeout , $window , $uibModal , bucketSvc setQuery : function(q) { if (q) query = q; return query; - }, - allItemsRetrieved : function() { - angular.forEach($scope.gridControls.allItems(), function(copy) { - bucketSvc.fetchRecentInventoryData(copy).then(function(alci) { - if (alci) { - copy._last_inventory_date = alci.inventory_date(); - copy._last_inventory_workstation = alci.inventory_workstation().name(); - } - }); - }); } }; 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 9c0f4cae28..37b8b07b48 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 @@ -13,10 +13,11 @@ function(egCore , $q) { }; service.prototype.flesh = { - flesh : 2, + flesh : 3, flesh_fields : { - acp : ['status','location','circ_lib','parts','age_protect','copy_alerts'], - acn : ['prefix','suffix','copies'] + acp : ['status','location','circ_lib','parts','age_protect','copy_alerts', 'last_copy_inventory'], + acn : ['prefix','suffix','copies'], + alci : ['inventory_workstation'] } } @@ -124,19 +125,6 @@ function(egCore , $q) { } }); - //create a virtual field for displaying most recent inventory data - angular.forEach(svc.copies, function(cp) { - egCore.pcrud.search('alci', - {copy: cp.id}, - {flesh: 2, flesh_fields: {alci: ['inventory_workstation']}} - ).then(function(alci) { - if (alci) { - cp._last_inventory_workstation = alci.inventory_workstation().name(); - cp._last_inventory_date = alci.inventory_date(); - } - }); - }); - // create virtual field for copy alert count angular.forEach(svc.copies, function (cp) { if (cp.copy_alerts) cp.copy_alert_count = cp.copy_alerts.length; diff --git a/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js b/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js index fa77290fb6..b1e0aed937 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js @@ -210,6 +210,9 @@ function($scope , $q , $window , $location , $timeout , egCore , checkinSvc , eg row_item['copy_barcode'] = row_item.acp.barcode(); + if (row_item.acp.last_copy_inventory().inventory_date() == "now") + row_item.acp.last_copy_inventory().inventory_date(Date.now()); + if (row_item.mbts) { var amt = Number(row_item.mbts.balance_owed()); if (amt != 0) { diff --git a/Open-ILS/web/js/ui/default/staff/circ/services/item.js b/Open-ILS/web/js/ui/default/staff/circ/services/item.js index e780236b2f..2532690448 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/services/item.js +++ b/Open-ILS/web/js/ui/default/staff/circ/services/item.js @@ -16,10 +16,10 @@ function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog flesh : 4, flesh_fields : { acp : ['call_number','location','status','location','floating','circ_modifier', - 'age_protect','circ_lib','copy_alerts', 'editor', 'inventory_workstation'], - 'age_protect','circ_lib','copy_alerts', 'editor'], + 'age_protect','circ_lib','copy_alerts', 'editor', 'last_copy_inventory'], acn : ['record','prefix','suffix','label_class'], - bre : ['simple_record','creator','editor'] + bre : ['simple_record','creator','editor'], + alci : ['inventory_workstation'] }, select : { // avoid fleshing MARC on the bre @@ -46,13 +46,6 @@ function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog limit : 1 } - service.inventoryFlesh = { - flesh : 2, - flesh_fields : { - alci : ['inventory_workstation'] - } - } - //Retrieve separate copy, aacs, and accs information service.getCopy = function(barcode, id) { if (barcode) { @@ -74,11 +67,6 @@ function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog service.circFlesh).then(function(circ) {return circ}); } - service.getInventory = function(id) { - return egCore.pcrud.search('alci', {copy : id }, - service.inventoryFlesh).then(function(alci) {return alci}); - } - service.getSummary = function(id) { return circ_summary = egCore.net.request( 'open-ils.circ', @@ -113,29 +101,17 @@ function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog }); } - var fetchInventory = function(copy) { - return service.getInventory(copy.id()) - .then(function(alci) { - if (alci) { - copyData.last_copy_inventory = alci; - return copyData; - } - }); - } - return fetchCopy(barcode, id).then(function(res) { if(!res.copy) { return $q.when(); } - return fetchInventory(copyData.copy).then(function(invRes) { - return fetchCirc(copyData.copy).then(function(res) { - if (copyData.circ) { - return fetchSummary(copyData.circ).then(function() { - return copyData; - }); - } else { + return fetchCirc(copyData.copy).then(function(res) { + if (copyData.circ) { + return fetchSummary(copyData.circ).then(function() { return copyData; - } - }); + }); + } else { + return copyData; + } }); }); @@ -146,7 +122,6 @@ function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog var copy; var circ; var circ_summary; - var last_copy_inventory; var lastRes = {}; return service.retrieveCopyData(barcode, id) @@ -183,10 +158,6 @@ function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog flatCopy._circ_summary.checkout_workstation : ''; } - if (copyData.last_copy_inventory) { - flatCopy._last_copy_inventory = egCore.idl.toHash(copyData.last_copy_inventory, true); - flatCopy._last_copy_inventory._inventory_workstation_name = copyData.last_copy_inventory.inventory_workstation().name(); - } flatCopy.index = service.index++; flatCopy.copy_alert_count = copyData.copy.copy_alerts().filter(function(aca) { return !aca.ack_time(); @@ -217,7 +188,6 @@ function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog return lastRes = { copy : copyData.copy, - last_copy_inventory : copyData.last_copy_inventory, index : flatCopy.index } }); -- 2.11.0