LP 1816655: Add a patron search button to create booking screen
authorJane Sandberg <sandbej@linnbenton.edu>
Mon, 14 Dec 2020 16:45:04 +0000 (08:45 -0800)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 9 Feb 2021 16:29:15 +0000 (11:29 -0500)
1) Apply this patch
2) Go to Booking > Create Reservation
3) Choose a resource type
4) Choose a time and double click (or press the Create Reservation
   button)
5) Note that there is now a Search for Patrons button
6) Use this button to search for a patron.
7) Click the select button.
8) Note that the patron's barcode appears in the
Patron Barcode field
9) Click Confirm Reservation
10) Note that the reservation was made.

Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Signed-off-by: Garry Collum <gcollum@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/staff/booking/create-reservation-dialog.component.html
Open-ILS/src/eg2/src/app/staff/booking/create-reservation-dialog.component.ts

index af68e76..d4a7fa8 100644 (file)
@@ -1,3 +1,5 @@
+<eg-patron-search-dialog #patronSearch>
+</eg-patron-search-dialog>
 <ng-template #dialogContent>
   <div class="modal-header bg-info">
     <h3 class="modal-title" i18n>Confirm Reservation Details</h3>
     <div class="form-group row">
       <label class="col-lg-4 text-right font-weight-bold"
         i18n for="create-patron-barcode">Patron barcode</label>
-      <input type="text" id="create-patron-barcode"
-        class="form-control col-lg-7" formControlName="patronBarcode" [disabled]="patronId">
+      <div class="col-lg-7">
+        <input type="text" id="create-patron-barcode"
+        class="form-control " formControlName="patronBarcode" [disabled]="patronId">
+        <button class="btn btn-outline-dark btn-sm" (click)="searchPatrons()">
+          <span class="material-icons mat-icon-in-button align-middle"
+            i18n-title title="Search for Patron">search</span>
+          <span class="align-middle" i18n>Search for Patron</span>
+        </button>
+      </div>
       <span class="col-lg-7 offset-lg-4" i18n>
         {{ (patron$ | async)?.first_given_name}}
         {{ (patron$ | async)?.second_given_name}}
index b40a1f3..2a15631 100644 (file)
@@ -13,6 +13,7 @@ import {PcrudService} from '@eg/core/pcrud.service';
 import {DialogComponent} from '@eg/share/dialog/dialog.component';
 import {notBeforeMomentValidator} from '@eg/share/validators/not_before_moment_validator.directive';
 import {PatronBarcodeValidator} from '@eg/share/validators/patron_barcode_validator.directive';
+import {PatronSearchDialogComponent} from '@eg/staff/share/patron/search-dialog.component';
 import {ToastService} from '@eg/share/toast/toast.service';
 import {AlertDialogComponent} from '@eg/share/dialog/alert.component';
 import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
@@ -52,6 +53,7 @@ export class CreateReservationDialogComponent
     public disableOrgs: () => number[];
     addBresv$: () => Observable<any>;
     @ViewChild('fail', { static: true }) private fail: AlertDialogComponent;
+    @ViewChild('patronSearch') patronSearch: PatronSearchDialogComponent;
 
     handlePickupLibChange: ($event: IdlObject) => void;
 
@@ -73,8 +75,6 @@ export class CreateReservationDialogComponent
     ngOnInit() {
 
         this.create = new FormGroup({
-            // TODO: replace this control with a patron search form
-            // when available in the Angular client
             'patronBarcode': new FormControl('',
                 [Validators.required],
                 [this.pbv.validate]
@@ -195,6 +195,16 @@ export class CreateReservationDialogComponent
         .subscribe(() => this.openPatronReservations());
     }
 
+    searchPatrons() {
+        this.patronSearch.open({size: 'xl'}).toPromise().then(
+            patrons => {
+                if (!patrons || patrons.length === 0) { return; }
+                const user = patrons[0];
+                this.create.patchValue({patronBarcode: user.card().barcode()});
+            }
+        );
+    }
+
     get emailNotify() {
         return this.create.get('emailNotify').value;
     }