import {AudioService} from '@eg/share/util/audio.service';
import {CircEventsComponent} from './events-dialog.component';
import {CircComponentsComponent} from './components.component';
+import {StringService} from '@eg/share/string/string.service';
export interface CircDisplayInfo {
title?: string;
autoOverrideCheckoutEvents: {[textcode: string]: boolean} = {};
suppressCheckinPopups = false;
ignoreCheckinPrecats = false;
+ copyLocationCache: {[id: number]: IdlObject} = {};
constructor(
private audio: AudioService,
private org: OrgService,
private net: NetService,
private pcrud: PcrudService,
+ private strings: StringService,
private auth: AuthService,
private bib: BibRecordService,
) {}
return this.net.request(
'open-ils.circ', method,
this.auth.token(), this.apiParams(params)).toPromise()
- .then(result => this.processCheckinResult(params, result));
+ .then(result => this.unpackCheckinData(params, result))
+ .then(result => this.processCheckinResult(result));
}
- processCheckinResult(
- params: CheckinParams, response: any): Promise<CheckinResult> {
-
+ unpackCheckinData(params: CheckinParams, response: any): Promise<CheckinResult> {
const allEvents = Array.isArray(response) ?
response.map(r => this.evt.parse(r)) : [this.evt.parse(response)];
const result: CheckinResult = {
index: CircService.resultIndex++,
firstEvent: firstEvent,
- allEvents: response,
+ allEvents: allEvents,
params: params,
success: success,
circ: payload.circ,
record: payload.record
};
+ let promise = Promise.resolve();;
+ const copy = result.copy;
+
+ if (copy) {
+ if (this.copyLocationCache[copy.location()]) {
+ copy.location(this.copyLocationCache[copy.location()]);
+ } else {
+ promise = this.pcrud.retrieve('acpl', copy.location()).toPromise()
+ .then(loc => {
+ copy.location(loc);
+ this.copyLocationCache[loc.id()] = loc;
+ });
+ }
+ }
+
+ return promise.then(_ => result);
+ }
+
+ processCheckinResult(result: CheckinResult): Promise<CheckinResult> {
+ const params = result.params;
+ const allEvents = result.allEvents;
+
// Informational alerts that can be ignored if configured.
if (this.suppressCheckinPopups &&
allEvents.filter(e =>
return this.showOverrideDialog(result, allEvents, true);
}
- switch (firstEvent.textcode) {
+ switch (result.firstEvent.textcode) {
case 'SUCCESS':
case 'NO_CHANGE':
- this.audio.play('success.checkin');
return this.handleCheckinSuccess(result);
case 'ITEM_NOT_CATALOGED':
}
handleCheckinSuccess(result: CheckinResult): Promise<CheckinResult> {
+
+ switch (result.copy.status()) {
+
+ case 0: /* AVAILABLE */
+ case 4: /* MISSING */
+ case 7: /* RESHELVING */
+ this.audio.play('success.checkin');
+ return this.handleCheckinLocAlert(result);
+ }
+
return Promise.resolve(result);
}
+ handleCheckinLocAlert(result: CheckinResult): Promise<CheckinResult> {
+ const copy = result.copy;
+
+ if (this.suppressCheckinPopups
+ || copy.location().checkin_alert() === 'f') {
+ return Promise.resolve(result);
+ }
+
+ return this.strings.interpolate(
+ 'staff.circ.checkin.location.alert',
+ {barcode: copy.barcode(), location: copy.location().name()}
+ ).then(str => {
+ this.components.locationAlertDialog.dialogBody = str;
+ return this.components.locationAlertDialog.open().toPromise()
+ .then(_ => result);
+ });
+ }
+
handleOverridableCheckinEvents(
result: CheckinResult, events: EgEvent[]): Promise<CheckinResult> {
const params = result.params;
// Should never get here. Just being safe.
return Promise.reject(null);
}
-
}
<div class="row mb-1">
<div class="col-lg-5" i18n>Email</div>
<div class="col-lg-7">
- <!-- TODO: mailto link -->
- {{p().email()}}
+ <a *ngIf="p().email()" href="mailto:{{p().email()}}">{{p().email()}}</a>
</div>
</div>
+ <div class="row mb-1" *ngIf="p().name_keywords()">
+ <div class="col-lg-5" i18n>Name Keywords</div>
+ <div class="col-lg-7">{{p().name_keywords()}}</div>
+ </div>
+
+ <ng-container *ngIf="p().waiver_entries().length">
+ <hr class="m-1"/>
+ <div class="row mb-1 alert alert-info p-0">
+ <div class="col-lg-12" i18n>Allow others to use my account</div>
+ </div>
+ <div class="row mb-1" *ngFor="let waiver of p().waiver_entries()">
+ <div class="col-lg-5" i18n>{{waiver.name()}}</div>
+ <div class="col-lg-7">
+ <ul>
+ <li *ngIf="waiver.place_holds() == 't'" i18n>Place holds</li>
+ <li *ngIf="waiver.pickup_holds() == 't'" i18n>Pick up holds</li>
+ <li *ngIf="waiver.view_history() == 't'" i18n>View borrowing history</li>
+ <li *ngIf="waiver.checkout_items() == 't'" i18n>Check out items</li>
+ </ul>
+ </div>
+ </div>
+ </ng-container>
<hr class="m-1"/>