Avoid requiring staff to send an Enter event (keyword / scanner) when
entering a patron barcode into the place holds form. Instead, look the
barcode up after a sufficient amount of time has passed.
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Ruth Frasur <rfrasur@library.in.gov>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
<input type='text' class="form-control" name="userBarcode"
[disabled]="holdFor!='patron'" id='patron-barcode'
aria-label="Patron barcode" i18n-aria-label
- (keyup.enter)="userBarcodeChanged()"
- [(ngModel)]="userBarcode" (change)="userBarcodeChanged()"/>
+ (ngModelChange)="debounceUserBarcodeLookup($event)"
+ (paste)="debounceUserBarcodeLookup($event)"
+ [(ngModel)]="userBarcode"/>
<div class="input-group-append">
<button class="btn btn-outline-dark" (click)="userBarcodeChanged()">Submit</button>
</div>
currentUserBarcode: string;
smsCarriers: ComboboxEntry[];
+ userBarcodeTimeout: number;
smsEnabled: boolean;
}
}
+ // Note this is called before this.userBarcode has its latest value.
+ debounceUserBarcodeLookup(barcode: string | ClipboardEvent) {
+ clearTimeout(this.userBarcodeTimeout);
+
+ if (!barcode) {
+ this.badBarcode = null;
+ return;
+ }
+
+ const timeout =
+ (barcode && (barcode as ClipboardEvent).target) ? 0 : 500;
+
+ this.userBarcodeTimeout =
+ setTimeout(() => this.userBarcodeChanged(), timeout);
+ }
+
userBarcodeChanged() {
const newBc = this.userBarcode;