<div class="col-lg-3">
<div class="form-check">
<input class="form-check-input" type="radio"
+ (change)="holdForChanged()"
name="holdFor" value="patron" [(ngModel)]="holdFor"/>
<label class="form-check-label" i18n>
Place hold for patron by barcode:
<div class="col-lg-3">
<div class="form-check">
<input class="form-check-input" type="radio"
+ (change)="holdForChanged()"
name="holdFor" value="staff" [(ngModel)]="holdFor"/>
<label class="form-check-label" i18n>
Place hold for this staff account: {{requestor.usrname()}}
</div>
</form>
-<h4 class="p-3" i18n>Placing Hold(s) On Records...</h4>
-
+<div class="row font-weight-bold mt-2 ml-1 mr-1">
+ <div class="col-lg-10" i18n>Placing hold(s) on record(s)</div>
+ <div class="col-lg-2" i18n>Holds Status</div>
+</div>
<ng-container *ngFor="let recId of recordIds">
- <div class="row mt-2 ml-2 mr-2">
- <div class="col-lg-12">
+ <div class="row mt-2 ml-1 mr-1">
+ <div class="col-lg-10">
<eg-bib-summary [recordId]="recId" [expand]="false"></eg-bib-summary>
</div>
+ <div class="col-lg-2">
+ <div class="alert alert-info">Hold Pending</div>
+ </div>
</div>
</ng-container>
pickupLib: number;
notifyEmail: boolean;
notifyPhone: boolean;
+ notifySms: boolean;
phoneValue: string;
suspend: boolean;
activeDate: string;
recordIds: number[];
- barcodeInFlight: string;
+ currentUserBarcode: string;
constructor(
private router: Router,
}
this.holdFor = 'patron';
- this.requestor = this.user = this.auth.user();
+ this.requestor = this.auth.user();
this.pickupLib = this.auth.user().ws_ou();
this.findRecords();
console.log('placing hold for ' + this.holdFor);
if (this.holdFor === 'patron') {
- // Patron lookup occurs via onchange on the barcode
- // input or via the patron search form.
+ if (this.userBarcode) {
+ this.userBarcodeChanged();
+ }
} else {
- this.user = this.requestor;
+ this.currentUserBarcode = '_'; // just for preventing dupes
+ this.getUser(this.requestor.id());
}
}
}
userBarcodeChanged() {
- this.user = null;
+ // Avoid simultaneous or duplicate lookups
+ if (this.userBarcode === this.currentUserBarcode) {
+ return;
+ }
+
+ this.resetForm();
if (!this.userBarcode) { return; }
- // Avoid simultaneous lookups caused by firing the
- // keyup handler and change handler in quick succession.
- // keyup handler applied so barcode scanner will result
- // in immediate lookup. change handler for humans
- // copy/paste'ing then tabbing through the form or off-clicking.
- if (this.userBarcode === this.barcodeInFlight) { return; }
- this.barcodeInFlight = this.userBarcode;
+ this.user = null;
+ this.currentUserBarcode = this.userBarcode;
this.net.request(
'open-ils.actor',
});
}
+ resetForm() {
+ this.notifyEmail = true;
+ this.notifyPhone = true;
+ this.phoneValue = '';
+ this.pickupLib = this.requestor.ws_ou();
+ }
+
getUser(id: number) {
- // TODO fetch user settings for PU lib, etc.
- this.pcrud.retrieve('au', id).subscribe(user => {
+ this.pcrud.retrieve('au', id, {flesh: 1, flesh_fields: {au: ['settings']}})
+ .subscribe(user => {
this.user = user;
- this.notifyPhone = user.day_phone() || user.evening_phone();
- this.barcodeInFlight = null;
+ this.applyUserSettings();
+ });
+ }
+
+ applyUserSettings() {
+ if (!this.user || !this.user.settings()) { return; }
+
+ // Start with defaults.
+ this.phoneValue = this.user.day_phone() || this.user.evening_phone();
+
+ // Default to work org if placing holds for staff.
+ if (this.user.id() !== this.requestor.id()) {
+ this.pickupLib = this.user.home_ou();
+ }
+
+ this.user.settings().forEach(setting => {
+ const name = setting.name();
+ const value = setting.value();
+
+ if (value === '' || value === null) { return; }
+
+ switch(name) {
+ case 'opac.hold_notify':
+ this.notifyPhone = Boolean(value.match(/phone/));
+ this.notifyEmail = Boolean(value.match(/email/));
+ this.notifySms = Boolean(value.match(/sms/));
+ break;
+
+ case 'opac.default_pickup_location':
+ this.pickupLib = value;
+ break;
+ }
});
}
}