From a110b6658d4d3708ac19439b1b090272cd19c52b Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 16 Nov 2018 14:33:55 -0500 Subject: [PATCH] place holds cont. Signed-off-by: Bill Erickson --- .../src/app/staff/catalog/hold/hold.component.html | 38 +++++++++---- .../src/app/staff/catalog/hold/hold.component.ts | 66 ++++++++++++++++++++-- .../share/bib-summary/bib-summary.component.ts | 3 + 3 files changed, 90 insertions(+), 17 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html index a71008f0f4..f0677be137 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html @@ -1,6 +1,7 @@ -

Place Hold

+

Place Hold

-
+
@@ -12,23 +13,26 @@
- +
+ +
+ +
+
-
-
-
- {{requestor.usrname()}} -
@@ -42,7 +46,7 @@
+ [disabled]="!user || !user.email()" [(ngModel)]="notifyEmail"/>
@@ -52,7 +56,7 @@ Email Address
+ [disabled]="true" value="{{user ? user.email() : ''}}"/>
@@ -90,4 +94,14 @@
+

Placing Hold(s) On Records...

+ + +
+
+ +
+
+
+ diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts index 9b2acc4ab4..4d86428336 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts @@ -1,13 +1,13 @@ import {Component, OnInit, Input, ViewChild, Renderer2} from '@angular/core'; import {Router, ActivatedRoute, ParamMap} from '@angular/router'; +import {EventService} from '@eg/core/event.service'; +import {NetService} from '@eg/core/net.service'; import {AuthService} from '@eg/core/auth.service'; import {PcrudService} from '@eg/core/pcrud.service'; import {IdlObject} from '@eg/core/idl.service'; import {CatalogSearchContext, CatalogSearchState} from '@eg/share/catalog/search-context'; import {CatalogService} from '@eg/share/catalog/catalog.service'; -import {BibRecordService, BibRecordSummary} from '@eg/share/catalog/bib-record.service'; import {StaffCatalogService} from '../catalog.service'; -import {BibSummaryComponent} from '@eg/staff/share/bib-summary/bib-summary.component'; @Component({ templateUrl: 'hold.component.html' @@ -17,6 +17,7 @@ export class HoldComponent implements OnInit { holdType: string; holdTargets: number[]; user: IdlObject; // + userBarcode: string; requestor: IdlObject; holdFor: string; pickupLib: number; @@ -25,14 +26,18 @@ export class HoldComponent implements OnInit { phoneValue: string; suspend: boolean; activeDate: string; + recordIds: number[]; + + barcodeInFlight: string; constructor( private router: Router, private route: ActivatedRoute, private renderer: Renderer2, + private evt: EventService, + private net: NetService, private auth: AuthService, private pcrud: PcrudService, - private bib: BibRecordService, private cat: CatalogService, private staffCat: StaffCatalogService ) {} @@ -49,12 +54,20 @@ export class HoldComponent implements OnInit { this.holdFor = 'patron'; this.requestor = this.user = this.auth.user(); this.pickupLib = this.auth.user().ws_ou(); + this.findRecords(); - // Focus barcode input - setTimeout(() => + setTimeout(() => // Focus barcode input this.renderer.selectRootElement('#patron-barcode').focus()); } + findRecords() { + if (this.holdType === 'T') { + this.recordIds = this.holdTargets; + } else { + // TODO OTHER HOLD TYPES + } + } + holdForChanged() { console.log('placing hold for ' + this.holdFor); @@ -69,6 +82,49 @@ export class HoldComponent implements OnInit { activeDateSelected(dateStr: string) { this.activeDate = dateStr; } + + userBarcodeChanged() { + this.user = null; + + 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.net.request( + 'open-ils.actor', + 'open-ils.actor.get_barcodes', + this.auth.token(), this.auth.user().ws_ou(), + 'actor', this.userBarcode + ).subscribe(barcodes => { + + // Use the first successful barcode response. + // TODO: What happens when there are multiple responses? + // Use for-loop for early exit since we have async + // action within the loop. + for (let i = 0; i < barcodes.length; i++) { + const bc = barcodes[i]; + if (!this.evt.parse(bc)) { + this.getUser(bc.id); + break; + } + } + }); + } + + getUser(id: number) { + // TODO fetch user settings for PU lib, etc. + this.pcrud.retrieve('au', id).subscribe(user => { + this.user = user; + this.notifyPhone = user.day_phone() || user.evening_phone(); + this.barcodeInFlight = null; + }); + } } diff --git a/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts index 78d2653c47..645b56cd78 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts @@ -14,6 +14,9 @@ export class BibSummaryComponent implements OnInit { initDone = false; expandDisplay = true; + @Input() set expand(e: boolean) { + this.expandDisplay = e; + } // If provided, the record will be fetched by the component. @Input() recordId: number; -- 2.11.0