['$scope','$q','egCore','checkinSvc','egGridDataProvider','egCirc',
function($scope , $q , egCore , checkinSvc , egGridDataProvider , egCirc) {
- // run egCore.startup here since it's not handled via resolver
- egCore.startup.go().then(
- function() {
- // handle post-startup business
- }
- );
-
+ var suppress_popups = false;
var today = new Date();
var seen_barcodes = {};
$scope.focusMe = true;
$scope.using_hatch = egCore.hatch.usingHatch();
$scope.modifiers = {};
+ // run egCore.startup here since it's not handled via resolver
+ egCore.startup.go().then(
+ function() {
+ // handle post-startup business
+ egCore.org.settings([
+ 'ui.circ.suppress_checkin_popups' // more will likely follow..
+ ])
+ .then(function(set) {
+ suppress_popups = set['ui.circ.suppress_checkin_popups'];
+ });
+ }
+ );
+
// ensure the backdate is not in the future
// note: input type=date max=foo not yet supported anywhere
$scope.$watch('checkinArgs.backdate', function(newval) {
check_barcode : $scope.strict_barcode,
no_precat_alert : $scope.modifiers.no_precat_alert,
auto_print_holds_transits :
- $scope.modifiers.auto_print_holds_transits
+ $scope.modifiers.auto_print_holds_transits,
+ suppress_popups : suppress_popups
};
return {params : params, options: options};
if (!params.copy_barcode) return;
if (seen_barcodes[params.copy_barcode]) {
- // TODO: UI
$scope.already_checked_in = params.copy_barcode;
return;
}
var service = {
// auto-override these events after the first override
auto_override_checkout_events : {},
- org_addr_cache : {}
+ org_addr_cache : {} // TODO: use egEnv
};
service.reset = function() {
service.auto_override_checkout_events = {};
}
- // these events can be overridden by staff
- service.overridable_events = [
+ // these events can be overridden by staff during checkout
+ service.checkout_overridable_events = [
'PATRON_EXCEEDS_OVERDUE_COUNT',
'PATRON_EXCEEDS_CHECKOUT_COUNT',
'PATRON_EXCEEDS_FINES',
'COPY_NOT_AVAILABLE',
'COPY_IS_REFERENCE',
'COPY_ALERT_MESSAGE',
- 'ITEM_ON_HOLDS_SHELF'
+ 'ITEM_ON_HOLDS_SHELF'
]
// after the first override of any of these events,
// auto-override them in subsequent calls.
- service.auto_override_after_first = [
+ service.checkout_auto_override_after_first = [
'PATRON_EXCEEDS_OVERDUE_COUNT',
'PATRON_BARRED',
'PATRON_EXCEEDS_LOST_COUNT',
'PATRON_EXCEEDS_FINES'
]
+ // these checkin events do not produce alerts when
+ // options.suppress_alerts is in effect.
+ service.checkin_suppress_overrides = [
+ 'COPY_BAD_STATUS',
+ 'PATRON_BARRED',
+ 'PATRON_INACTIVE',
+ 'PATRON_ACCOUNT_EXPIRED',
+ 'ITEM_DEPOSIT_PAID',
+ 'CIRC_CLAIMS_RETURNED',
+ 'COPY_ALERT_MESSAGE',
+ 'COPY_STATUS_LOST',
+ 'COPY_STATUS_LONG_OVERDUE',
+ 'COPY_STATUS_MISSING',
+ 'PATRON_EXCEEDS_FINES'
+ ]
+
+ // these events can be overridden by staff during checkin
+ service.checkin_overridable_events =
+ service.checkin_suppress_overrides.concat([
+ 'TRANSIT_CHECKIN_INTERVAL_BLOCK'
+ ])
+
// Performs a checkout.
// Returns a promise resolved with the original params and options
// and the final checkout event (e.g. in the case of override).
if (angular.isArray(evt)) evt = evt[0];
- return service.flesh_response_data(
- 'checkout', evt, params, options)
+ return service.flesh_response_data('checkout', evt, params, options)
.then(function() {
return service.handle_checkout_resp(evt, params, options);
})
console.debug('override failed: ' + evt.textcode);
return $q.reject();
- } else {
- if (service.auto_override_checkout_events[evt.textcode]) {
- // user has already opted to override this type
- // of event. Re-run the checkout w/ override.
- options.override = true;
- return service.checkout(params, options);
- }
- }
+ }
+
+ if (service.auto_override_checkout_events[evt.textcode]) {
+ // user has already opted to override this type
+ // of event. Re-run the checkout w/ override.
+ options.override = true;
+ return service.checkout(params, options);
+ }
// Ask the user if they would like to override this event.
// Some events offer a stock override dialog, while others
}
}
+ service.handle_overridable_checkin_event = function(evt, params, options) {
+
+ if (options.override) {
+ // override attempt already made and failed.
+ // NOTE: I don't think we'll ever get here, since the
+ // override attempt should produce a perm failure...
+ console.debug('override failed: ' + evt.textcode);
+ return $q.reject();
+
+ }
+
+ if (options.suppress_checkin_popups
+ && service.checkin_suppress_overrides.indexOf(evt.textcode) > -1) {
+ // Event is suppressed. Re-run the checkin w/ override.
+ options.override = true;
+ return service.checkin(params, options);
+ }
+
+ // Ask the user if they would like to override this event.
+ // Some events offer a stock override dialog, while others
+ // require additional context.
+
+ switch(evt.textcode) {
+ case 'COPY_ALERT_MESSAGE':
+ return service.copy_alert_dialog(evt, params, options, 'checkin');
+ default:
+ return service.override_dialog(evt, params, options);
+ }
+ }
+
+
service.handle_checkout_resp = function(evt, params, options) {
var final_resp = {evt : evt, params : params, options : options};
evt.copy_barcode = params.copy_barcode;
// Overridable Events
- if (service.overridable_events.indexOf(evt.textcode) > -1)
+ if (service.checkout_overridable_events.indexOf(evt.textcode) > -1)
return service.handle_overridable_checkout_event(evt, params, options);
// Other events
// fetch/cache for org unit addresses
+ // TODO: use egEnv instead
service.get_org_addr = function(org_id, addr_type) {
if (service.org_addr_cache[org_id]) {
if (service.org_addr_cache[org_id][addr_type])
function($scope, $modalInstance) {
$scope.evt = evt;
$scope.auto_override =
- service.auto_override_after_first.indexOf(evt.textcode) > -1;
+ service.checkout_auto_override_after_first.indexOf(evt.textcode) > -1;
$scope.ok = function() { $modalInstance.close() }
$scope.cancel = function ($event) {
$modalInstance.dismiss();
}]
}).result.then(
function() {
- if (service.auto_override_after_first.indexOf(evt.textcode) > -1)
+ if (service.checkout_auto_override_after_first.indexOf(evt.textcode) > -1)
service.auto_override_checkout_events[evt.textcode] = true;
options.override = true;
return service.checkout(params, options);
);
}
+
+ // alert when copy location alert_message is set.
+ // This does not affect processing, it only produces a click-through
+ service.handle_checkin_loc_alert = function(evt, params, options) {
+
+ var copy = evt && evt.payload ? evt.payload.copy : null;
+
+ if (copy && !options.suppress_checkin_popups
+ && copy.location().checkin_alert() == 't') {
+
+ return egAlertDialog.open(
+ egCore.strings.LOCATION_ALERT_MSG, {copy : copy}).result;
+ }
+
+ return $q.when();
+ }
+
service.handle_checkin_resp = function(evt, params, options) {
var final_resp = {evt : evt, params : params, options : options};
transit = evt.payload.transit;
}
- // track the barcode regardless of whether it refers to a copy
+ // track the barcode regardless of whether it's valid
evt.copy_barcode = params.copy_barcode;
console.debug('checkin event ' + evt.textcode);
+ if (service.checkin_overridable_events.indexOf(evt.textcode) > -1)
+ return service.handle_overridable_checkin_event(evt, params, options);
+
switch (evt.textcode) {
case 'SUCCESS':
case 'NO_CHANGE':
).then(function() { return final_resp });
} else {
- return $q.when(final_resp);
+
+ // see if the copy location is configured to alert
+ return service.handle_checkin_loc_alert(evt, params, options)
+ .then(function() {return final_resp});
}
case 'ROUTE_ITEM':
egCore.strings.PRECAT_CHECKIN_MSG, params)
.result.then(function() {return final_resp});
- case 'COPY_ALERT_MESSAGE':
- return service.copy_alert_dialog(evt, params, options, 'checkin');
-
-
default:
console.warn('unhandled checkin response : ' + evt.textcode);
return $q.when(final_resp);