webstaff: add more volume transfer options
authorGalen Charlton <gmc@esilibrary.com>
Tue, 26 Jan 2016 22:01:21 +0000 (17:01 -0500)
committerKathy Lussier <klussier@masslnc.org>
Tue, 2 Feb 2016 19:58:54 +0000 (14:58 -0500)
The volume/copy editor now has the following new actions:

  * (Transfer) Volumes to Previously Marked Record
  * (Transfer) Volumes to Previously Marked Record and Library

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js

index 6f50ceb..af92ff1 100644 (file)
     <eg-grid-action handler="selectedHoldingsVolCopyDelete" group="[% l('Delete') %]" disabled="copies_not_shown"
       label="[% l('Volumes and Copies') %]"></eg-grid-action>
 
+    <eg-grid-action handler="transferVolumesToRecord" group="[% l('Transfer') %]"
+      label="[% l('Volumes to Previously Marked Record') %]"></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="transferVolumesToRecordAndLibrary" group="[% l('Transfer') %]"
+      label="[% l('Volumes to Previously Marked Record and 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') %]"
index 2ab0074..bfa8ee6 100644 (file)
@@ -1020,7 +1020,45 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
         );
     }
 
-    $scope.transferVolumes = function (){
+    $scope.transferVolumesToRecord = function (){
+        var target_record = egCore.hatch.getLocalItem('eg.cat.marked_volume_transfer_record');
+        if (!target_record) return;
+        if ($scope.record_id == target_record) return;
+        var items = $scope.holdingsGridControls.selectedItems();
+        if (!items.length) return;
+
+        var vols_to_move   = {};
+        angular.forEach(items, function(item) {
+            if (!(item.call_number.owning_lib in vols_to_move)) {
+                vols_to_move[item.call_number.owning_lib] = new Array;
+            }
+            vols_to_move[item.call_number.owning_lib].push(item.call_number.id);
+        });
+
+        var promises = [];        
+        angular.forEach(vols_to_move, function(vols, owning_lib) {
+            promises.push(egCore.net.request(
+                'open-ils.cat',
+                'open-ils.cat.asset.volume.batch.transfer.override',
+                egCore.auth.token(), {
+                    docid   : target_record,
+                    lib     : owning_lib,
+                    volumes : vols
+                }
+            ));
+        });
+        $q.all(promises).then(function(success) {
+            if (success) {
+                holdingsSvcInst.fetchAgain().then(function() {
+                    $scope.holdingsGridDataProvider.refresh();
+                });
+            } else {
+                alert('Could not transfer volumes!');
+            }
+        });
+    }
+
+    $scope.transferVolumes = function (new_record){
         var xfer_target = egCore.hatch.getLocalItem('eg.cat.volume_transfer_target');
 
         if (xfer_target) {
@@ -1028,7 +1066,7 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
                 'open-ils.cat',
                 'open-ils.cat.asset.volume.batch.transfer.override',
                 egCore.auth.token(), {
-                    docid   : $scope.record_id,
+                    docid   : (new_record ? new_record : $scope.record_id),
                     lib     : xfer_target,
                     volumes : gatherSelectedVolumeIds()
                 }
@@ -1045,6 +1083,12 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
         
     }
 
+    $scope.transferVolumesToRecordAndLibrary = function() {
+        var target_record = egCore.hatch.getLocalItem('eg.cat.marked_volume_transfer_record');
+        if (!target_record) return;
+        $scope.transferVolumes(target_record);
+    }
+
     // this "transfers" selected copies to a new owning library,
     // auto-creating volumes and deleting unused volumes as required.
     $scope.changeItemOwningLib = function() {