Wire up the JS wrapper functions for discard.
authorJason Stephenson <jason@sigio.com>
Sat, 7 Jul 2018 15:04:06 +0000 (11:04 -0400)
committerJason Stephenson <jason@sigio.com>
Fri, 26 Oct 2018 23:04:55 +0000 (19:04 -0400)
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js
Open-ILS/web/js/ui/default/staff/cat/item/app.js
Open-ILS/web/js/ui/default/staff/circ/checkin/app.js
Open-ILS/web/js/ui/default/staff/circ/renew/app.js
Open-ILS/web/js/ui/default/staff/circ/services/holds.js
Open-ILS/web/js/ui/default/staff/circ/services/item.js

index 43af4d5..07c2592 100644 (file)
@@ -1634,6 +1634,23 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
         });
     }
 
+    $scope.selectedHoldingsDiscard = function () {
+        var copy_list = gatherSelectedRawCopies();
+        if (copy_list.length == 0) return;
+
+        angular.forEach(copy_list, function(cp) {
+            egCirc.mark_discard({
+                id: cp.id(),
+                barcode: cp.barcode(),
+                circ_lib: cp.circ_lib().id()
+            }).then(function() {
+                holdingsSvcInst.fetchAgain().then(function() {
+                    $scope.holdingsGridDataProvider.refresh();
+                });
+            });
+        });
+    }
+
     $scope.selectedHoldingsMissing = function () {
         egCirc.mark_missing(gatherSelectedHoldingsIds()).then(function() {
             holdingsSvcInst.fetchAgain().then(function() {
index 19e45f9..1c82253 100644 (file)
@@ -154,6 +154,14 @@ function($scope , $location , $timeout , egCore , egGridDataProvider , itemSvc)
         }]);
     }
 
+    $scope.selectedHoldingsDiscard = function () {
+        itemSvc.selectedHoldingsDiscard([{
+            id : $scope.args.copyId,
+            barcode : $scope.args.copyBarcode,
+            refresh : true
+        }]);
+    }
+
     $scope.selectedHoldingsMissing = function () {
         itemSvc.selectedHoldingsMissing([{
             id : $scope.args.copyId,
@@ -455,6 +463,10 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore ,
         itemSvc.selectedHoldingsDamaged(copyGrid.selectedItems());
     }
 
+    $scope.selectedHoldingsDiscard = function () {
+        itemSvc.selectedHoldingsDiscard(copyGrid.selectedItems());
+    }
+
     $scope.selectedHoldingsMissing = function () {
         itemSvc.selectedHoldingsMissing(copyGrid.selectedItems());
     }
index 6d71f6c..bf6d978 100644 (file)
@@ -335,6 +335,20 @@ function($scope , $q , $window , $location , $timeout , egCore , checkinSvc , eg
 
     }
 
+    $scope.showMarkDiscard = function(items) {
+        var copy_ids = [];
+        angular.forEach(items, function(item) {
+            if (item.acp) {
+                egCirc.mark_discard({
+                    id: item.acp.id(),
+                    barcode: item.acp.barcode()
+                })
+
+            }
+        });
+
+    }
+
     $scope.abortTransit = function(items) {
         var transit_ids = [];
         angular.forEach(items, function(item) {
index 2c6ba63..7c0e0e8 100644 (file)
@@ -182,6 +182,19 @@ function($scope , $window , $location , egCore , egGridDataProvider , egCirc) {
         }
     }
 
+    $scope.showMarkDiscard = function(items) {
+        var copy_ids = [];
+        angular.forEach(items, function(item) {
+            if (item.acp) copy_ids.push(item.acp.id());
+        });
+
+        if (copy_ids.length) {
+            egCirc.mark_discard(copy_ids).then(function() {
+                // update grid items?
+            });
+        }
+    }
+
     $scope.showLastFewCircs = function(items) {
         if (items.length && (copy = items[0].acp)) {
             var url = $location.path(
index f76d92b..3654d19 100644 (file)
@@ -711,6 +711,17 @@ function($window , $location , $timeout , egCore , egHolds , egCirc) {
         });
     }
 
+    service.mark_discard = function(items) {
+        angular.forEach(items, function(item) {
+            if (item.copy) {
+                egCirc.mark_discard({
+                    id: item.copy.id(),
+                    barcode: item.copy.barcode()
+                }).then(service.refresh);
+            }
+        });
+    }
+
     service.mark_missing = function(items) {
         var copy_ids = items
             .filter(function(item) { return Boolean(item.copy) })
index c39f038..858a91c 100644 (file)
@@ -644,6 +644,18 @@ function(egCore , egCirc , $uibModal , $q , $timeout , $window , egConfirmDialog
         });
     }
 
+    service.selectedHoldingsDiscard = function (items) {
+        angular.forEach(items, function(cp) {
+            if (cp) {
+                egCirc.mark_discard({
+                    id: cp.id,
+                    barcode: cp.barcode,
+                    refresh: cp.refresh
+                });
+            }
+        });
+    }
+
     service.selectedHoldingsMissing = function (items) {
         egCirc.mark_missing(items.map(function(el){return el.id;})).then(function(){
             angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)});