LP 1907921: Add a patron search button to course admin screen
authorJane Sandberg <sandbej@linnbenton.edu>
Mon, 14 Dec 2020 16:07:16 +0000 (08:07 -0800)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 9 Feb 2021 16:36:28 +0000 (11:36 -0500)
To test:

1) Apply this patch
2) Go to Admin > Local Admin > Course Reserves List
3) Select a course and Edit it
4) Go to the Course users tab
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) Select a Role
10) Click the Add User button
11) Note that the patron appears on the Course Users grid

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/admin/local/course-reserves/course-associate-users.component.html
Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-users.component.ts
Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-reserves.module.ts

index 5959761..d323638 100644 (file)
@@ -5,6 +5,9 @@
 <eg-string #userEditSuccessString i18n-text text="Update of User succeeded"></eg-string>
 <eg-string #userEditFailedString i18n-text text="Update of User failed or was not allowed"></eg-string>
 
+<eg-patron-search-dialog #patronSearch>
+</eg-patron-search-dialog>
+
 <ng-template #dialogContent>
 <div class="modal-header bg-info"
   [ngClass]="isDialog() ? 'modal-header' : 'alert mt-3'">
               [(ngModel)]="userBarcode" (click)="$event.target.select()"
               [disabled]="currentCourse && currentCourse.is_archived() == 't'"
               (keyup.enter)="associateUser(userBarcode)" />
+            <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>
         </div>
         <div class="d-flex" [ngClass]="isDialog() ? 'col-md-6' : 'col-md-12 mt-3'">
index f281342..d9985fa 100644 (file)
@@ -10,6 +10,7 @@ import {GridComponent} from '@eg/share/grid/grid.component';
 import {IdlObject} from '@eg/core/idl.service';
 import {StringComponent} from '@eg/share/string/string.component';
 import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
+import {PatronSearchDialogComponent} from '@eg/staff/share/patron/search-dialog.component';
 import {ToastService} from '@eg/share/toast/toast.service';
 import {CourseService} from '@eg/staff/share/course.service';
 import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
@@ -25,6 +26,7 @@ export class CourseAssociateUsersComponent extends DialogComponent implements On
     @Input() displayMode: String;
     users: any[] = [];
     @ViewChild('editDialog', { static: true }) editDialog: FmRecordEditorComponent;
+    @ViewChild('patronSearch') patronSearch: PatronSearchDialogComponent;
     @ViewChild('usersGrid') usersGrid: GridComponent;
     @ViewChild('userDeleteFailedString', { static: true })
         userDeleteFailedString: StringComponent;
@@ -103,6 +105,16 @@ export class CourseAssociateUsersComponent extends DialogComponent implements On
         editOneThing(userFields.shift());
     }
 
+    searchPatrons() {
+        this.patronSearch.open({size: 'xl'}).toPromise().then(
+            patrons => {
+                if (!patrons || patrons.length === 0) { return; }
+                const user = patrons[0];
+                this.userBarcode = user.card().barcode();
+            }
+        );
+    }
+
     showEditDialog(user: IdlObject): Promise<any> {
         this.editDialog.mode = 'update';
         this.editDialog.recordId = user.id();
index 30c7651..32a44a5 100644 (file)
@@ -9,6 +9,7 @@ import {CourseAssociateUsersComponent} from './course-associate-users.component'
 import {CourseReservesRoutingModule} from './routing.module';
 import {ItemLocationSelectModule} from '@eg/share/item-location-select/item-location-select.module';
 import {MarcSimplifiedEditorModule} from '@eg/staff/share/marc-edit/simplified-editor/simplified-editor.module';
+import {PatronModule} from '@eg/staff/share/patron/patron.module';
 import {CourseTermMapComponent} from './course-term-map.component';
 
 @NgModule({
@@ -25,6 +26,7 @@ import {CourseTermMapComponent} from './course-term-map.component';
     CourseReservesRoutingModule,
     ItemLocationSelectModule,
     MarcSimplifiedEditorModule,
+    PatronModule,
     TreeModule
   ],
   exports: [