webstaff: implement Transfer Title Holds from record bucket
authorGalen Charlton <gmc@esilibrary.com>
Thu, 10 Sep 2015 01:06:01 +0000 (01:06 +0000)
committerJason Stephenson <jstephenson@mvlc.org>
Mon, 14 Sep 2015 19:44:21 +0000 (15:44 -0400)
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/templates/staff/cat/bucket/record/index.tt2
Open-ILS/src/templates/staff/cat/bucket/record/t_view.tt2
Open-ILS/src/templates/staff/circ/share/hold_strings.tt2
Open-ILS/web/js/ui/default/staff/cat/bucket/record/app.js
Open-ILS/web/js/ui/default/staff/circ/services/holds.js

index 7b399c1..145ddd3 100644 (file)
@@ -12,6 +12,8 @@
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/cat/services/record.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/cat/services/tagtable.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/cat/services/marcedit.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/circ/services/holds.js"></script>
+[% INCLUDE 'staff/circ/share/hold_strings.tt2' %]
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/cat/bucket/record/app.js"></script>
 <script>
   angular.module('egCoreMod').run(['egStrings', function(s) {
index 599dab1..c1b2085 100644 (file)
@@ -19,6 +19,9 @@
   <eg-grid-action label="[% l('Delete Selected Records from Catalog') %]" 
     handler="deleteRecordsFromCatalog"></eg-grid-action>
 
+  <eg-grid-action handler="transfer_holds_to_marked"
+    label="[% l('Transfer Title Holds') %]"></eg-grid-action>
+
   <eg-grid-action label="[% l('Merge Selected Records') %]" 
     handler="openRecordMergeDialog"></eg-grid-action>
 
index 9e67e19..647dac7 100644 (file)
@@ -19,7 +19,9 @@ s.SET_TOP_OF_QUEUE =
 s.CLEAR_TOP_OF_QUEUE = 
   "[% l('Unset the Top of Queue flag for [_1] Hold(s)?', '{{num_holds}}') %]";
 s.TRANSFER_HOLD_TO_TITLE = 
-  "[% l('Tranfer [_1] Hold(s) to bib record ID [_2]?', '{{num_holds}}', '{{bib_id}}') %]";
+  "[% l('Transfer [_1] Hold(s) to bib record ID [_2]?', '{{num_holds}}', '{{bib_id}}') %]";
+s.TRANSFER_ALL_BIB_HOLDS_TO_TITLE = 
+  "[% l('Transfer holds on [_1] bib(s) to bib record ID [_2]?', '{{num_bibs}}', '{{bib_id}}') %]";
 s.NO_HOLD_TRANSFER_TITLE_MARKED = 
   "[% l('No record is marked as a hold transfer target!') %]";
 s.RETARGET_HOLDS = 
index 98a73d6..f07bea7 100644 (file)
@@ -503,10 +503,10 @@ function($scope,  $routeParams,  bucketSvc , egGridDataProvider) {
 }])
 
 .controller('ViewCtrl',
-       ['$scope','$q','$routeParams','bucketSvc', 'egCore', '$window',
-        '$timeout', 'egConfirmDialog', '$modal',
-function($scope,  $q , $routeParams,  bucketSvc, egCore, $window,
-        $timeout, egConfirmDialog, $modal) {
+       ['$scope','$q','$routeParams','bucketSvc','egCore','$window',
+        '$timeout','egConfirmDialog','$modal','egHolds',
+function($scope,  $q , $routeParams,  bucketSvc,  egCore,  $window,
+         $timeout,  egConfirmDialog,  $modal,  egHolds) {
 
     $scope.setTab('view');
     $scope.bucketId = $routeParams.id;
@@ -534,6 +534,12 @@ function($scope,  $q , $routeParams,  bucketSvc, egCore, $window,
         );
     }
 
+    // runs the transfer title holds action
+    $scope.transfer_holds_to_marked = function(records) {
+        var bib_ids = records.map(function(val) { return val.id; })
+        egHolds.transfer_all_bib_holds_to_marked_title(bib_ids);
+    }
+
     // opens the record merge dialog
     $scope.openRecordMergeDialog = function(records) {
         $modal.open({
index 057cfa3..ea83238 100644 (file)
@@ -368,6 +368,31 @@ function($modal , $q , egCore , egConfirmDialog , egAlertDialog) {
         });
     }
 
+    service.transfer_all_bib_holds_to_marked_title = function(bib_ids) {
+        if (!bib_ids.length) return $q.when();
+
+        var target_bib_id = egCore.hatch.getLocalItem(
+            'eg.circ.hold.title_transfer_target');
+
+        if (!target_bib_id) {
+            // no target marked
+            return egAlertDialog.open(
+                egCore.strings.NO_HOLD_TRANSFER_TITLE_MARKED).result;
+        }
+
+        return egConfirmDialog.open(
+            egCore.strings.TRANSFER_ALL_BIB_HOLDS_TO_TITLE, '', {
+                num_bibs : bib_ids.length,
+                bib_id : target_bib_id
+            }
+        ).result.then(function() {
+            return egCore.net.request(
+                'open-ils.circ',
+                'open-ils.circ.hold.change_title',
+                egCore.auth.token(), target_bib_id, bib_ids);
+        });
+    }
+
     // serially retargets each hold
     service.retarget = function(hold_ids) {
         if (!hold_ids.length) return $q.when();