webstaff: teach serials items grid about certain status changes
authorGalen Charlton <gmc@equinoxinitiative.org>
Tue, 20 Jun 2017 20:28:45 +0000 (16:28 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 20 Jun 2017 20:28:45 +0000 (16:28 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/serials/index.tt2
Open-ILS/src/templates/staff/serials/t_view_items_grid.tt2
Open-ILS/web/js/ui/default/staff/serials/directives/view-items-grid.js
Open-ILS/web/js/ui/default/staff/serials/services/core.js

index 928584b..16e35a1 100644 (file)
@@ -59,6 +59,8 @@ angular.module('egCoreMod').run(['egStrings', function(s) {
     s.CONFIRM_CHANGE_ITEMS_MESSAGE.reset = "[% l('Will reset {{items}} item(s) to Expected and remove unit(s).') %]";
     s.CONFIRM_CHANGE_ITEMS.receive = "[% l('Receive selected items?') %]"
     s.CONFIRM_CHANGE_ITEMS_MESSAGE.receive = "[% l('Will receive {{items}} item(s) without barcoding.') %]";
+    s.CONFIRM_CHANGE_ITEMS.status = "[% l('Change status selected items?') %]"
+    s.CONFIRM_CHANGE_ITEMS_MESSAGE.status = "[% l('Will change status of {{items}} item(s).') %]";
 
     s.CONFIRM_DELETE_MFHDS = "[% l('Delete selected MFHD(s)?') %]";
     s.CONFIRM_DELETE_MFHDS_MESSAGE = "[% l('Will delete {{items}} MFHD(s).') %]";
index acbb8e0..9ae5b98 100644 (file)
     <eg-grid-action handler="edit_issuance_holding_code"
       label="[% l('Edit issue holding codes') %]"></eg-grid-action>
 
+    <eg-grid-action handler="set_selected_as_claimed"
+      label="[% l('Mark as claimed') %]"></eg-grid-action>
+    <eg-grid-action handler="set_selected_as_discarded"
+      label="[% l('Mark as discarded') %]"></eg-grid-action>
+    <eg-grid-action handler="set_selected_as_not_published"
+      label="[% l('Mark as not published') %]"></eg-grid-action>
+    <eg-grid-action handler="set_selected_as_not_held"
+      label="[% l('Mark as not held') %]"></eg-grid-action>
+
     <eg-grid-action handler="reset_selected"
       label="[% l('Reset items') %]"></eg-grid-action>
 
index a9f8d68..1c2c3c8 100644 (file)
@@ -351,6 +351,27 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , orderByF
         }), true, true, $scope.do_print_routing_lists, function(){reload($scope.ssubId,_paging_filter)});
     }
 
+    $scope.set_selected_as_claimed = function(list) {
+        return egSerialsCoreSvc.set_item_status('Claimed', $scope.bibId, list.map(function(item) {
+            return egCore.idl.Clone(egSerialsCoreSvc.itemMap[item.id]);
+        }), function(){reload($scope.ssubId,_paging_filter)});
+    }
+    $scope.set_selected_as_discarded = function(list) {
+        return egSerialsCoreSvc.set_item_status('Discarded', $scope.bibId, list.map(function(item) {
+            return egCore.idl.Clone(egSerialsCoreSvc.itemMap[item.id]);
+        }), function(){reload($scope.ssubId,_paging_filter)});
+    }
+    $scope.set_selected_as_not_published = function(list) {
+        return egSerialsCoreSvc.set_item_status('Not Published', $scope.bibId, list.map(function(item) {
+            return egCore.idl.Clone(egSerialsCoreSvc.itemMap[item.id]);
+        }), function(){reload($scope.ssubId,_paging_filter)});
+    }
+    $scope.set_selected_as_not_held = function(list) {
+        return egSerialsCoreSvc.set_item_status('Not Held', $scope.bibId, list.map(function(item) {
+            return egCore.idl.Clone(egSerialsCoreSvc.itemMap[item.id]);
+        }), function(){reload($scope.ssubId,_paging_filter)});
+    }
+
     $scope.menu_print_routing_lists = function (items) {
         items = items.map(function(item) {
             return egCore.idl.Clone(egSerialsCoreSvc.itemMap[item.id]);
index 8ace6ab..ffe5bc7 100644 (file)
@@ -768,6 +768,35 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm
 
     }
 
+    service.set_item_status = function(newStatus, bibId, list, callback) {
+        if (!callback) callback = function () { return $q.when() }
+        if (!list.length) return $q.reject();
+
+        return egConfirmDialog.open(
+            egCore.strings.CONFIRM_CHANGE_ITEMS.status,
+            egCore.strings.CONFIRM_CHANGE_ITEMS_MESSAGE.status,
+            {items : list.length}
+        ).result.then(function () {
+            var promises = [$q.when()];
+            angular.forEach(list, function(item) {
+                item.status(newStatus);
+                promises.push(
+                    egCore.net.request(
+                        'open-ils.serial',
+                        'open-ils.serial.item.update',
+                        egCore.auth.token(),
+                        item
+                    ).then(function(res) {
+                        return $q.when();
+                    })
+                );
+            });
+            $q.all(promises).then(function() {
+                callback();
+            });
+        });
+    }
+    
     service.process_items = function (mode, bibId, list, do_barcode, bind, print_rl, callback) {
         if (!callback) callback = function () { return $q.when() }
         if (!list.length) return $q.reject();