From 13770ac8b9b1df28aa20e5d837ed9054b182b585 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 26 Jan 2016 16:13:27 -0500 Subject: [PATCH] webstaff: add a Transfer Copies to Previously Marked Library action Signed-off-by: Galen Charlton Signed-off-by: Kathy Lussier --- .../staff/cat/catalog/t_holdings.tt2 | 4 +- .../js/ui/default/staff/cat/catalog/app.js | 53 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) 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 8f3c6cc242..6f50ceb719 100644 --- a/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 +++ b/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 @@ -40,7 +40,7 @@ + label="[% l('Choose Library for Volume/Copy Transfer Destination') %]"> @@ -83,6 +83,8 @@ + 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 bb3abda481..2ab0074bba 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 @@ -1045,6 +1045,59 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e } + // this "transfers" selected copies to a new owning library, + // auto-creating volumes and deleting unused volumes as required. + $scope.changeItemOwningLib = function() { + var xfer_target = egCore.hatch.getLocalItem('eg.cat.volume_transfer_target'); + var items = $scope.holdingsGridControls.selectedItems(); + if (!xfer_target || !items.length) { + return; + } + var vols_to_move = {}; + var copies_to_move = {}; + angular.forEach(items, function(item) { + if (item.call_number.owning_lib != xfer_target) { + if (item.call_number.id in vols_to_move) { + copies_to_move[item.call_number.id].push(item.id); + } else { + vols_to_move[item.call_number.id] = item.call_number; + copies_to_move[item.call_number.id] = new Array; + copies_to_move[item.call_number.id].push(item.id); + } + } + }); + + var promises = []; + angular.forEach(vols_to_move, function(vol) { + promises.push(egCore.net.request( + 'open-ils.cat', + 'open-ils.cat.call_number.find_or_create', + egCore.auth.token(), + vol.label, + vol.record, + xfer_target, + vol.prefix.id, + vol.suffix.id, + vol.label_class + ).then(function(resp) { + var evt = egCore.evt.parse(resp); + if (evt) return; + return egCore.net.request( + 'open-ils.cat', + 'open-ils.cat.transfer_copies_to_volume', + egCore.auth.token(), + resp.acn_id, + copies_to_move[vol.id] + ); + })); + }); + $q.all(promises).then(function() { + holdingsSvcInst.fetchAgain().then(function() { + $scope.holdingsGridDataProvider.refresh(); + }); + }); + } + $scope.transferItems = function (){ var xfer_target = egCore.hatch.getLocalItem('eg.cat.item_transfer_target'); var copy_ids = gatherSelectedHoldingsIds(); -- 2.43.2