patron holds ; retarget
authorBill Erickson <berick@esilibrary.com>
Mon, 7 Jul 2014 13:00:50 +0000 (09:00 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 7 Jul 2014 13:00:50 +0000 (09:00 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/circ/patron/t_holds.tt2
Open-ILS/src/templates/staff/circ/share/hold_strings.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/holds.js
Open-ILS/web/js/ui/default/staff/circ/services/holds.js

index e30fd4d..a14d6ff 100644 (file)
@@ -41,6 +41,8 @@
     label="[% l('Mark Item Damaged') %]"></eg-grid-action>
   <eg-grid-action handler="mark_missing"
     label="[% l('Mark Item Missing') %]"></eg-grid-action>
+  <eg-grid-action handler="retarget"
+    label="[% l('Find Another Target') %]"></eg-grid-action>
   <eg-grid-action handler="cancel_hold"
     label="[% l('Cancel Hold') %]"></eg-grid-action>
 
index 1cf5111..aaee92c 100644 (file)
@@ -21,6 +21,8 @@ s.TRANSFER_HOLD_TO_TITLE =
   "[% l('Tranfer [_1] Hold(s) to bib record ID [_2]?', '{{num_holds}}', '{{bib_id}}') %]";
 s.NO_HOLD_TRANSFER_TITLE_MARKED = 
   "[% l('No record is marked as a hold transfer target!') %]";
+s.RETARGET_HOLDS = 
+  "[% l('Reset hold(s) [_1]?', '{{hold_ids}}') %]";
 }]);
 </script>
 
index 2bc4434..086a7cf 100644 (file)
@@ -168,6 +168,12 @@ function($scope,  $q,  $routeParams,  egCore,  egUser,  patronSvc,
             egCirc.mark_missing(copy_ids).then(refresh_all);
     }
 
+    $scope.retarget = function(items) {
+        var hold_ids = items.map(function(item) { return item.hold.id() });
+        egHolds.retarget(hold_ids).then(refresh_all);
+    }
+
+
 }])
 
 
index 94ef30b..a2fc75a 100644 (file)
@@ -278,6 +278,36 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog , egAlertDialog)
         });
     }
 
+    // serially retargets each hold
+    service.retarget = function(hold_ids) {
+        if (!hold_ids.length) return $q.when();
+        var deferred = $q.defer();
+
+        egConfirmDialog.open(
+            egCore.strings.RETARGET_HOLDS, '', 
+            {hold_ids : hold_ids.join(',')}
+
+        ).result.then(function() {
+
+            function do_one() {
+                var hold_id = hold_ids.pop();
+                if (!hold_id) {
+                    deferred.resolve();
+                    return;
+                }
+
+                egCore.net.request(
+                    'open-ils.circ',
+                    'open-ils.circ.hold.reset',
+                    egCore.auth.token(), hold_id).finally(do_one);
+            }
+
+            do_one(); // kick it off
+        });
+
+        return deferred.promise;
+    }
+
     return service;
 }])