From 5ded9caa9c310793775a1fdf60310179d62ddecf Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Sun, 7 Nov 2021 16:00:34 -0500 Subject: [PATCH] LP1883171 & LP1940663: Basic staff client modifications Modify the Item Staus view to check the new return values of the update copy inventory function. Fix toast handling in the list view to properly report success and failure. Add toast handling to the single copy Item Status view to report success and failure. NOTE: More work could be done on the toasts to report number of successful updates, etc. I tried using the compileContent and trusted HTML, but this lead to new errors that I couldn't decipher. This work was sponsored by NOBLE. Signed-off-by: Jason Stephenson Signed-off-by: Michele Morgan Signed-off-by: Mike Rylander --- Open-ILS/src/templates/staff/cat/item/index.tt2 | 4 ++++ Open-ILS/web/js/ui/default/staff/cat/item/app.js | 14 +++++++++----- .../web/js/ui/default/staff/circ/services/circ.js | 11 +---------- .../web/js/ui/default/staff/circ/services/item.js | 12 +++++++----- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Open-ILS/src/templates/staff/cat/item/index.tt2 b/Open-ILS/src/templates/staff/cat/item/index.tt2 index f200f6e308..8980a65bca 100644 --- a/Open-ILS/src/templates/staff/cat/item/index.tt2 +++ b/Open-ILS/src/templates/staff/cat/item/index.tt2 @@ -36,6 +36,10 @@ "[% l('Updated most recent inventory data for selected items.') %]"; s.FAIL_UPDATE_INVENTORY = "[% l('Failed to update recent inventory data for selected items.')%]"; + s.SUCCESS_UPDATE_INVENTORY_SINGLE = + "[% l('Updated most recent inventory data for this item.') %]"; + s.FAIL_UPDATE_INVENTORY_SINGLE = + "[% l('Failed to update recent inventory data for this item.')%]"; s.ITEM_SUCCESSFULLY_MODIFIED = "[% l('Item successfully modified') %]"; s.ITEMS_SUCCESSFULLY_MODIFIED = 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 8e21e25994..1338a251a9 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 @@ -52,8 +52,8 @@ angular.module('egItemStatus', * Parent scope for list and detail views */ .controller('SearchCtrl', - ['$scope','$q','$window','$location','$timeout','egCore','egNet','egGridDataProvider','egItem', 'egCirc', -function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridDataProvider , itemSvc , egCirc) { + ['$scope','$q','$window','$location','$timeout','egCore','egNet','egGridDataProvider','egItem', 'egCirc', 'ngToast', +function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridDataProvider , itemSvc , egCirc, ngToast) { $scope.args = {}; // search args // sub-scopes (search / detail-view) apply their version @@ -156,7 +156,12 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD $scope.update_inventory = function() { itemSvc.updateInventory([$scope.args.copyId], null) .then(function(res) { - $timeout(function() { location.href = location.href; }, 1000); + if (res[0]) { + ngToast.create(egCore.strings.SUCCESS_UPDATE_INVENTORY_SINGLE); + } else { + ngToast.warning(egCore.strings.FAIL_UPDATE_INVENTORY_SINGLE); + } + $timeout(function() { location.href = location.href; }, 1500); }); } @@ -561,8 +566,7 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD $scope.update_inventory = function() { var copy_list = gatherSelectedHoldingsIds(); itemSvc.updateInventory(copy_list, $scope.gridControls.allItems()).then(function(res) { - if (res) { - $scope.gridControls.allItems(res); + if (res[0]) { ngToast.create(egCore.strings.SUCCESS_UPDATE_INVENTORY); } else { ngToast.warning(egCore.strings.FAIL_UPDATE_INVENTORY); diff --git a/Open-ILS/web/js/ui/default/staff/circ/services/circ.js b/Open-ILS/web/js/ui/default/staff/circ/services/circ.js index 32fc43d2f9..33727770f5 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/services/circ.js +++ b/Open-ILS/web/js/ui/default/staff/circ/services/circ.js @@ -289,7 +289,6 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog, egAddCopyAl data.record = payload.record; data.acp = payload.copy; data.acn = payload.volume ? payload.volume : payload.copy ? payload.copy.call_number() : null; - data.alci = egCore.idl.toHash(payload.latest_inventory, true); data.au = payload.patron; data.transit = payload.transit; data.status = payload.status; @@ -302,13 +301,6 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog, egAddCopyAl if (payload.circ) data.duration = payload.circ.duration(); if (payload.circ) data.circ_lib = payload.circ.circ_lib(); - if (payload.do_inventory_update) { - if (payload.latest_inventory.id()) { - egCore.pcrud.update(payload.latest_inventory); - } else { - egCore.pcrud.create(payload.latest_inventory); - } - } // for checkin, the mbts lives on the main circ if (payload.circ && payload.circ.billable_transaction()) @@ -1659,12 +1651,11 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog, egAddCopyAl var final_resp = {evt : evt, params : params, options : options}; - var copy, hold, transit, latest_inventory; + var copy, hold, transit; if (evt[0].payload) { copy = evt[0].payload.copy; hold = evt[0].payload.hold; transit = evt[0].payload.transit; - latest_inventory = evt[0].payload.latest_inventory; } // track the barcode regardless of whether it's valid 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 56d82bfec4..8070346f27 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 @@ -200,7 +200,7 @@ function(egCore , egOrg , egCirc , $uibModal , $q , $timeout , $window , ngToast if (copy_list.length == 0) return; return egCore.net.request( 'open-ils.circ', - 'open-ils.circ.circulation.update_latest_inventory', + 'open-ils.circ.circulation.update_copy_inventory', egCore.auth.token(), {copy_list: copy_list} ).then(function(res) { if (res) { @@ -212,14 +212,16 @@ function(egCore , egOrg , egCirc , $uibModal , $q , $timeout , $window , ngToast {alci: ['inventory_workstation']} }).then(function(alci) { //update existing grid rows - item["latest_inventory.inventory_date"] = alci.inventory_date(); - item["latest_inventory.inventory_workstation.name"] = - alci.inventory_workstation().name(); + if (alci) { + item["latest_inventory.inventory_date"] = alci.inventory_date(); + item["latest_inventory.inventory_workstation.name"] = + alci.inventory_workstation().name(); + } }); } }); }); - return all_items || res; + return res; } }); } -- 2.43.2