var service = {
// auto-override these events after the first override
- auto_override_circ_events : {},
- // auto-skip these events after the first skip
- auto_skip_circ_events : {},
+ auto_override_checkout_events : {},
require_initials : false,
never_auto_print : {
hold_shelf_slip : false,
});
service.reset = function() {
- service.auto_override_circ_events = {};
- service.auto_skip_circ_events = {};
+ service.auto_override_checkout_events = {};
}
- // these events cannot be overriden
- service.nonoverridable_events = [
- 'ACTION_CIRCULATION_NOT_FOUND',
- 'ACTOR_USER_NOT_FOUND',
- 'ASSET_COPY_NOT_FOUND',
- 'PATRON_INACTIVE',
- 'PATRON_CARD_INACTIVE',
- 'PATRON_ACCOUNT_EXPIRED',
- 'PERM_FAILURE' // should be handled elsewhere
+ // these events can be overridden by staff during checkout
+ service.checkout_overridable_events = [
+ 'PATRON_EXCEEDS_OVERDUE_COUNT',
+ 'PATRON_EXCEEDS_CHECKOUT_COUNT',
+ 'PATRON_EXCEEDS_FINES',
+ 'PATRON_EXCEEDS_LONGOVERDUE_COUNT',
+ 'PATRON_BARRED',
+ 'CIRC_EXCEEDS_COPY_RANGE',
+ 'ITEM_DEPOSIT_REQUIRED',
+ 'ITEM_RENTAL_FEE_REQUIRED',
+ 'PATRON_EXCEEDS_LOST_COUNT',
+ 'COPY_CIRC_NOT_ALLOWED',
+ 'COPY_NOT_AVAILABLE',
+ 'COPY_IS_REFERENCE',
+ 'COPY_ALERT_MESSAGE',
+ 'ITEM_ON_HOLDS_SHELF',
+ 'STAFF_C',
+ 'STAFF_CH',
+ 'STAFF_CHR',
+ 'STAFF_CR',
+ 'STAFF_H',
+ 'STAFF_HR',
+ 'STAFF_R'
]
- // Default to checked for "Automatically override for subsequent items?"
- service.default_auto_override = [
+ // after the first override of any of these events,
+ // auto-override them in subsequent calls.
+ service.checkout_auto_override_after_first = [
'PATRON_EXCEEDS_OVERDUE_COUNT',
'PATRON_BARRED',
'PATRON_EXCEEDS_LOST_COUNT',
'PATRON_EXCEEDS_LONGOVERDUE_COUNT'
]
+
+ // overridable during renewal
+ service.renew_overridable_events = [
+ 'PATRON_EXCEEDS_OVERDUE_COUNT',
+ 'PATRON_EXCEEDS_LOST_COUNT',
+ 'PATRON_EXCEEDS_CHECKOUT_COUNT',
+ 'PATRON_EXCEEDS_FINES',
+ 'PATRON_EXCEEDS_LONGOVERDUE_COUNT',
+ 'CIRC_EXCEEDS_COPY_RANGE',
+ 'ITEM_DEPOSIT_REQUIRED',
+ 'ITEM_RENTAL_FEE_REQUIRED',
+ 'ITEM_DEPOSIT_PAID',
+ 'COPY_CIRC_NOT_ALLOWED',
+ 'COPY_NOT_AVAILABLE',
+ 'COPY_IS_REFERENCE',
+ 'COPY_ALERT_MESSAGE',
+ 'COPY_NEEDED_FOR_HOLD',
+ 'MAX_RENEWALS_REACHED',
+ 'CIRC_CLAIMS_RETURNED',
+ 'STAFF_C',
+ 'STAFF_CH',
+ 'STAFF_CHR',
+ 'STAFF_CR',
+ 'STAFF_H',
+ 'STAFF_HR',
+ 'STAFF_R'
+ ];
+
// these checkin events do not produce alerts when
// options.suppress_alerts is in effect.
service.checkin_suppress_overrides = [
}
- if (evt.filter(function(e){return !service.auto_override_circ_events[e.textcode];}).length == 0) {
+ if (evt.filter(function(e){return !service.auto_override_checkout_events[e.textcode];}).length == 0) {
// user has already opted to override these type
// of events. Re-run the checkout w/ override.
options.override = true;
}
// renewal auto-overrides are the same as checkout
- if (evt.filter(function(e){return !service.auto_override_circ_events[e.textcode];}).length == 0) {
+ if (evt.filter(function(e){return !service.auto_override_checkout_events[e.textcode];}).length == 0) {
// user has already opted to override these type
// of events. Re-run the renew w/ override.
options.override = true;
// track the barcode regardless of whether it refers to a copy
angular.forEach(evt, function(e){ e.copy_barcode = params.copy_barcode; });
- // test for success first to simplify things
- if (evt[0].textcode == 'SUCCESS') {
- egCore.audio.play('info.renew');
- return $q.when(final_resp);
- }
-
- // handle Overridable and Non-Overridable Events, but only if no skipped non-overridable events
- if (evt.filter(function(e){return service.auto_skip_circ_events[e.textcode];}).length == 0) {
+ // Overridable Events
+ if (evt.filter(function(e){return service.renew_overridable_events.indexOf(e.textcode) > -1;}).length > 0)
return service.handle_overridable_renew_event(evt, params, options);
- }
// Other events
switch (evt[0].textcode) {
+ case 'SUCCESS':
+ egCore.audio.play('info.renew');
+ return $q.when(final_resp);
+
case 'COPY_IN_TRANSIT':
case 'PATRON_CARD_INACTIVE':
case 'PATRON_INACTIVE':
case 'PATRON_ACCOUNT_EXPIRED':
case 'CIRC_CLAIMS_RETURNED':
- case 'ITEM_NOT_CATALOGED':
- case 'ASSET_COPY_NOT_FOUND':
- // since handle_overridable_renew_event essentially advertises these events at some point,
- // we no longer need the original alerts; however, the sound effects are still nice.
egCore.audio.play('warning.renew');
- return $q.reject();
+ return service.exit_alert(
+ egCore.strings[evt[0].textcode],
+ {barcode : params.copy_barcode}
+ );
default:
egCore.audio.play('warning.renew.unknown');
// track the barcode regardless of whether it refers to a copy
angular.forEach(evt, function(e){ e.copy_barcode = params.copy_barcode; });
- // test for success first to simplify things
- if (evt[0].textcode == 'SUCCESS') {
- egCore.audio.play('success.checkout');
- return $q.when(final_resp);
- }
+ // Overridable Events
+ if (evt.filter(function(e){return service.checkout_overridable_events.indexOf(e.textcode) > -1;}).length > 0)
+ return service.handle_overridable_checkout_event(evt, params, options);
- // other events that should precede generic overridable/non-overridable handling
+ // Other events
switch (evt[0].textcode) {
+ case 'SUCCESS':
+ egCore.audio.play('success.checkout');
+ return $q.when(final_resp);
+
case 'ITEM_NOT_CATALOGED':
egCore.audio.play('error.checkout.no_cataloged');
return service.precat_dialog(params, options);
case 'COPY_IN_TRANSIT':
egCore.audio.play('warning.checkout.in_transit');
return service.copy_in_transit_dialog(evt, params, options);
- }
-
- // handle Overridable and Non-Overridable Events, but only if no skipped non-overridable events
- if (evt.filter(function(e){return service.auto_skip_circ_events[e.textcode];}).length == 0) {
- return service.handle_overridable_checkout_event(evt, params, options);
- }
- // Other events
- switch (evt[0].textcode) {
case 'PATRON_CARD_INACTIVE':
case 'PATRON_INACTIVE':
case 'PATRON_ACCOUNT_EXPIRED':
case 'CIRC_CLAIMS_RETURNED':
- case 'ITEM_NOT_CATALOGED':
- case 'ASSET_COPY_NOT_FOUND':
- // since handle_overridable_checkout_event essentially advertises these events at some point,
- // we no longer need the original alerts; however, the sound effects are still nice.
egCore.audio.play('warning.checkout');
- return $q.reject();
+ return service.exit_alert(
+ egCore.strings[evt[0].textcode],
+ {barcode : params.copy_barcode}
+ );
default:
egCore.audio.play('error.checkout.unknown');
['$scope', '$uibModalInstance',
function($scope, $uibModalInstance) {
$scope.events = evt;
- $scope.action = action;
// Find the event, if any, that is for ITEM_ON_HOLDS_SHELF
// and grab the patron name of the owner.
$scope.patronID = $scope.holdEvent.payload.patron_id;
}
+ $scope.auto_override =
+ evt.filter(function(e){
+ return service.checkout_auto_override_after_first.indexOf(evt.textcode) > -1;
+ }).length > 0;
$scope.copy_barcode = params.copy_barcode; // may be null
// Implementation note: Why not use a primitive here? It
// doesn't work. See:
// http://stackoverflow.com/questions/18642371/checkbox-not-binding-to-scope-in-angularjs
- $scope.formdata = {
- clearHold : service.clearHold,
- nonoverridable: evt.filter(function(e){
- return service.nonoverridable_events.indexOf(e.textcode) > -1;}).length > 0,
- event_ui_data : Object.fromEntries(
- evt.map( e => [ e.ilsevent, {
- // non-overridable events will be rare, but they are skippable. We use
- // the same checkbox variable to track desired skip and auto-override
- // selections.
- overridable: service.nonoverridable_events.indexOf(e.textcode) == -1,
- // for non-overridable events, we'll default the checkbox to any previous
- // choice made for the current patron, though normally the UI will be
- // suppressed unless some previously unencountered events are in the set
- checkbox: service.nonoverridable_events.indexOf(e.textcode) > -1
- ? (service.auto_skip_circ_events[e.textcode] == undefined
- ? false
- : service.auto_skip_circ_events[e.textcode]
- )
- // if a given event is overridable, said checkbox will default to any previous
- // choice made for the current patron, as long as there are no non-overridable
- // events in the set (because we'll disable the checkbox in that case and don't
- // want to imply that we're going to set an auto-override)
- : (service.auto_override_circ_events[e.textcode] == undefined
- ? (
- service.nonoverridable_events.indexOf(e.textcode) > -1
- ? false
- : service.default_auto_override.indexOf(e.textcode) > -1
- )
- : service.auto_override_circ_events[e.textcode]
- )
- }])
- )
- };
-
- function update_auto_override_and_skip_lists() {
- angular.forEach(evt, function(e){
- if ($scope.formdata.nonoverridable) {
- // the action had at least one non-overridable event, so let's only
- // record skip choices for those
- if (!$scope.formdata.event_ui_data[e.ilsevent].overridable) {
- if ($scope.formdata.event_ui_data[e.ilsevent].checkbox) {
- // grow the skip list
- service.auto_skip_circ_events[e.textcode] = true;
- } else {
- // shrink the skip list
- service.auto_skip_circ_events[e.textcode] = false;
- }
- }
- } else {
- // record all auto-override choices
- if ($scope.formdata.event_ui_data[e.ilsevent].checkbox) {
- // grow the auto-override list
- service.auto_override_circ_events[e.textcode] = true;
- } else {
- // shrink the auto-override list
- service.auto_override_circ_events[e.textcode] = false;
- }
- }
- });
- // for debugging
- window.oils_auto_skip_circ_events = service.auto_skip_circ_events;
- window.oils_auto_override_circ_events = service.auto_override_circ_events;
- }
+ $scope.formdata = {clearHold : service.clearHold};
$scope.ok = function() {
- update_auto_override_and_skip_lists();
// Handle the cancellation of the assciated hold here
if ($scope.formdata.clearHold && $scope.holdID) {
egCore.net.request(
$uibModalInstance.close();
}
- $scope.skip = function($event) {
- update_auto_override_and_skip_lists();
- $uibModalInstance.dismiss();
- $event.preventDefault();
- }
-
$scope.cancel = function ($event) {
- window.oils_cancel_batch = true;
$uibModalInstance.dismiss();
$event.preventDefault();
}
return service.checkin(params, options);
}
+ // checkout/renew support override-after-first
+ angular.forEach(evt, function(e){
+ if (service.checkout_auto_override_after_first.indexOf(e.textcode) > -1)
+ service.auto_override_checkout_events[e.textcode] = true;
+ });
+
return service[action](params, options);
}
);