webstaff: Allow optional override of TITLE_LAST_COPY event
authorMike Rylander <mrylander@gmail.com>
Thu, 10 Sep 2015 00:15:33 +0000 (20:15 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Mon, 14 Sep 2015 19:44:21 +0000 (15:44 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/templates/staff/cat/catalog/index.tt2
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js

index f5db2fe..5abae22 100644 (file)
       "[% l('Unlink selected conjoined copies?') %]";
     s.CONFIRM_DELETE_PEERS_MESSAGE =
       "[% l('Will unlink {{peers}} copies') %]";
+    s.CONFIRM_TRANSFER_COPIES_TO_MARKED_VOLUME =                                                                                                                  
+      "[% l('Are you sure you want to transfer selected items to the marked volume?') %]";                                                                                   
+    s.OVERRIDE_TRANSFER_COPIES_TO_MARKED_VOLUME_TITLE =                                                                                                           
+      "[% l('One or more items could not be transferred. Override?') %]";                                                                                                    
+    s.OVERRIDE_TRANSFER_COPIES_TO_MARKED_VOLUME_BODY =                                                                                                            
+      "[% l('Reason(s) include: [_1]', '{{evt_desc}}') %]";                
   }])
 </script>
 
index 9639157..f60abf3 100644 (file)
@@ -945,26 +945,46 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
 
     $scope.transferItems = function (){
         var xfer_target = egCore.hatch.getLocalItem('eg.cat.item_transfer_target');
-        if (xfer_target) {
-            var copy_list = gatherSelectedRawCopies();
-
-            angular.forEach(copy_list, function (cp) {
-                cp.call_number(xfer_target);
-            });
-
-            egCore.pcrud.update(
-                copy_list
-            ).then(function(success) {
-                if (success) {
-                    holdingsSvc.fetchAgain().then(function() {
-                        $scope.holdingsGridDataProvider.refresh();
-                    });
-                } else {
-                    alert('Could not transfer items!');
-                }
-            });
+        var copy_ids = gatherSelectedHoldingsIds();
+        if (xfer_target && copy_ids.length > 0) {
+            egCore.net.request(
+                'open-ils.cat',
+                'open-ils.cat.transfer_copies_to_volume',
+                egCore.auth.token(),
+                xfer_target,
+                copy_ids
+            ).then(
+                function(resp) { // oncomplete
+                    var evt = egCore.evt.parse(resp);
+                    if (evt) {
+                        egConfirmDialog.open(
+                            egCore.strings.OVERRIDE_TRANSFER_COPIES_TO_MARKED_VOLUME_TITLE,
+                            egCore.strings.OVERRIDE_TRANSFER_COPIES_TO_MARKED_VOLUME_BODY,
+                            {'evt_desc': evt.desc}
+                        ).result.then(function() {
+                            egCore.net.request(
+                                'open-ils.cat',
+                                'open-ils.cat.transfer_copies_to_volume.override',
+                                egCore.auth.token(),
+                                xfer_target,
+                                copy_ids,
+                                { events: ['TITLE_LAST_COPY', 'COPY_DELETE_WARNING'] }
+                            ).then(function(resp) {
+                                holdingsSvc.fetchAgain().then(function() {
+                                    $scope.holdingsGridDataProvider.refresh();
+                                });
+                            });
+                        });
+                    } else {
+                        holdingsSvc.fetchAgain().then(function() {
+                            $scope.holdingsGridDataProvider.refresh();
+                        });
+                    }
+                },
+                null, // onerror
+                null // onprogress
+            )
         }
-        
     }
 
     $scope.selectedHoldingsItemStatusTgrEvt = function (){