<eg-grid-action handler="attach_to_peer_bib"
label="[% l('Link as Conjoined to Previously Marked Bib Record') %]"></eg-grid-action>
<eg-grid-action handler="markLibAsVolTarget"
- label="[% l('Choose Library for Volume Transfer Destination') %]"></eg-grid-action>
+ label="[% l('Choose Library for Volume/Copy Transfer Destination') %]"></eg-grid-action>
<eg-grid-action handler="selectedHoldingsItemStatus" group="[% l('Show') %]"
label="[% l('Item Status (list)') %]"></eg-grid-action>
<eg-grid-action handler="transferVolumes" group="[% l('Transfer') %]"
label="[% l('Volumes to Previously Marked Library') %]"></eg-grid-action>
+ <eg-grid-action handler="changeItemOwningLib" group="[% l('Transfer') %]"
+ label="[% l('Copies to Previously Marked Library') %]"></eg-grid-action>
<eg-grid-action handler="transferItems" group="[% l('Transfer') %]"
label="[% l('Items to Previously Marked Volume') %]"></eg-grid-action>
}
+ // 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();