LP1903358 Staff catalog holds barcode realtime lookup
authorBill Erickson <berickxx@gmail.com>
Tue, 27 Jul 2021 19:09:45 +0000 (15:09 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Tue, 12 Oct 2021 17:55:44 +0000 (13:55 -0400)
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>
Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html
Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts

index 2b733af..df4130e 100644 (file)
@@ -62,8 +62,9 @@
             <input type='text' class="form-control" name="userBarcode"
               [disabled]="holdFor!='patron'" id='patron-barcode'
               aria-label="Patron barcode" i18n-aria-label
             <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>
             <div class="input-group-append">
               <button class="btn btn-outline-dark" (click)="userBarcodeChanged()">Submit</button>
             </div>
index b4d2443..8f86dc0 100644 (file)
@@ -74,6 +74,7 @@ export class HoldComponent implements OnInit {
 
     currentUserBarcode: string;
     smsCarriers: ComboboxEntry[];
 
     currentUserBarcode: string;
     smsCarriers: ComboboxEntry[];
+    userBarcodeTimeout: number;
 
     smsEnabled: boolean;
 
 
     smsEnabled: boolean;
 
@@ -351,6 +352,22 @@ export class HoldComponent implements OnInit {
         }
     }
 
         }
     }
 
+    // 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;
 
     userBarcodeChanged() {
         const newBc = this.userBarcode;