LP#1845706: Missing/Damaged from Items Out user/miker/lp-1845706-damaged-missing-items_out
authorMike Rylander <mrylander@gmail.com>
Wed, 21 Aug 2019 15:41:29 +0000 (11:41 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 30 Sep 2019 13:44:26 +0000 (09:44 -0400)
Marking items Missing or Damaged from the patron Items Out interface
is sometimes necessary.  This commit adds that ability.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/templates/staff/circ/patron/t_items_out.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js

index 6c10e6f..a215294 100644 (file)
     label="[% l('Print Item Receipt') %]"></eg-grid-action>
   <eg-grid-action handler="edit_due_date"
     label="[% l('Edit Due Date') %]"></eg-grid-action>
+  <eg-grid-action handler="mark_damaged"
+    label="[% l('Mark Damaged') %]"></eg-grid-action>
+  <eg-grid-action handler="mark_missing"
+    label="[% l('Mark Missing') %]"></eg-grid-action>
   <eg-grid-action handler="mark_lost"
     label="[% l('Mark Lost (By Patron)') %]"></eg-grid-action>
   <eg-grid-action handler="mark_claims_returned"
index 327eeb5..1bc86fe 100644 (file)
@@ -398,12 +398,32 @@ function($scope , $q , $routeParams , $timeout , egCore , egUser , patronSvc ,
         });
     }
 
+    function batch_action_with_flat_copies(items, action) {
+        if (!items.length) return;
+        var copies = items.map(function(circ) 
+            { return egCore.idl.toHash(circ.target_copy()) });
+        action(copies).then(reset_page);
+    }
     function batch_action_with_barcodes(items, action) {
         if (!items.length) return;
         var barcodes = items.map(function(circ) 
             { return circ.target_copy().barcode() });
         action(barcodes).then(reset_page);
     }
+    $scope.mark_damaged = function(items) {
+        if (items.length == 0) return;
+
+        angular.forEach(items, function(circ) {
+            egCirc.mark_damaged({
+                id: circ.target_copy().id(),
+                barcode: circ.target_copy().barcode(),
+                circ_lib: circ.target_copy().circ_lib().id()
+            }).then($timeout(reset_page,1000)) // reset after each, because rejecting one stops the $q.all() chain
+        });
+    }
+    $scope.mark_missing = function(items) {
+        batch_action_with_flat_copies(items, egCirc.mark_missing);
+    }
     $scope.mark_lost = function(items) {
         batch_action_with_barcodes(items, egCirc.mark_lost);
     }