handler="showBackdateDialog"
label="[% l('Backdate Post-Checkin') %]">
</eg-grid-action>
+ <eg-grid-action
+ handler="showMarkDamaged"
+ label="[% l('Mark Items Damaged') %]">
+ </eg-grid-action>
+ <eg-grid-action
+ handler="abortTransit"
+ label="[% l('Abort Transits') %]">
+ </eg-grid-action>
<eg-grid-field label="[% l('Alert Msg') %]"
path="acp.alert_message"></eg-grid-field>
}
}
+ $scope.showMarkDamaged = 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_damaged(copy_ids).then(function() {
+ // update grid items?
+ });
+ }
+ }
+
+ $scope.abortTransit = function(items) {
+ var transit_ids = [];
+ angular.forEach(items, function(item) {
+ if (item.transit) transit_ids.push(item.transit.id());
+ });
+
+ egCirc.abort_transits(transit_ids).then(function() {
+ // update grid items?
+ });
+ }
+
}])
}).result;
}
+ service.mark_damaged = function(copy_ids) {
+ return egConfirmDialog.open(
+ egCore.strings.MARK_DAMAGED_CONFIRM, '',
+ { num_items : copy_ids.length,
+ ok : function() {},
+ cancel : function() {}
+ }
+
+ ).result.then(function() {
+ var promises = [];
+ angular.forEach(copy_ids, function(copy_id) {
+ promises.push(
+ egCore.net.request(
+ 'open-ils.circ',
+ 'open-ils.circ.mark_item_damaged',
+ egCore.auth.token(), copy_id
+ ).then(function(resp) {
+ if (evt = egCore.evt.parse(resp)) {
+ console.error('mark damaged failed: ' + evt);
+ }
+ })
+ );
+ });
+
+ return $q.all(promises);
+ });
+ }
+
+ service.abort_transits = function(transit_ids) {
+ return egConfirmDialog.open(
+ egCore.strings.ABORT_TRANSIT_CONFIRM, '',
+ { num_transits : transit_ids.length,
+ ok : function() {},
+ cancel : function() {}
+ }
+
+ ).result.then(function() {
+ var promises = [];
+ angular.forEach(transit_ids, function(transit_id) {
+ promises.push(
+ egCore.net.request(
+ 'open-ils.circ',
+ 'open-ils.circ.transit.abort',
+ egCore.auth.token(), {transitid : transit_id}
+ ).then(function(resp) {
+ if (evt = egCore.evt.parse(resp)) {
+ console.error('abort transit failed: ' + evt);
+ }
+ })
+ );
+ });
+
+ return $q.all(promises);
+ });
+ }
+
+
// alert when copy location alert_message is set.
// This does not affect processing, it only produces a click-through