From 5f4f3ae1726b9fd0eb59146f77da106207cef958 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 12 Jan 2022 11:27:02 -0500 Subject: [PATCH] LP1904036 Checkin grid shows circ user; routeTo updates Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../app/staff/circ/checkin/checkin.component.html | 10 ++- .../eg2/src/app/staff/share/circ/circ.service.ts | 72 +++++++++++++++----- .../app/staff/share/circ/route-dialog.component.ts | 15 +++-- 3 files changed, 71 insertions(+), 26 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/circ/checkin/checkin.component.html b/Open-ILS/src/eg2/src/app/staff/circ/checkin/checkin.component.html index 7489dbc..b756aeb 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/checkin/checkin.component.html +++ b/Open-ILS/src/eg2/src/app/staff/circ/checkin/checkin.component.html @@ -187,13 +187,15 @@ - - - + + + + + - + diff --git a/Open-ILS/src/eg2/src/app/staff/share/circ/circ.service.ts b/Open-ILS/src/eg2/src/app/staff/share/circ/circ.service.ts index d3de2f9..38c1762 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/circ/circ.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/circ/circ.service.ts @@ -146,11 +146,22 @@ export interface CircResultCommon { circ?: IdlObject; parent_circ?: IdlObject; hold?: IdlObject; + + // Set to one of circ_patron or hold_patron depending on the context. patron?: IdlObject; + + // Set to the patron linked to the relevant circulation. + circ_patron?: IdlObject; + + // Set to the patron linked to the relevant hold. + hold_patron?: IdlObject; + transit?: IdlObject; copyAlerts?: IdlObject[]; mbts?: IdlObject; + routeTo?: string; // org name or in-branch destination + // Calculated values title?: string; author?: string; @@ -190,7 +201,6 @@ export interface CheckinParams { export interface CheckinResult extends CircResultCommon { params: CheckinParams; - routeTo?: string; // org name or in-branch destination destOrg?: IdlObject; destAddress?: IdlObject; destCourierCode?: string; @@ -746,35 +756,55 @@ export class CircService { }); } + fetchPatron(userId: number): Promise { + return this.pcrud.retrieve('au', userId, { + flesh: 1, + flesh_fields : {'au' : ['card', 'stat_cat_entries']} + }) + .toPromise(); + } + fleshCommonData(result: CircResultCommon): Promise { + console.warn('fleshCommonData()'); + const copy = result.copy; const volume = result.volume; const circ = result.circ; const hold = result.hold; const nonCatCirc = (result as CheckoutResult).nonCatCirc; - let promise = Promise.resolve(); + let promise: Promise = Promise.resolve(); - if (!result.patron) { - let patronId; - if (hold) { - patronId = hold.usr(); - } else if (circ) { - patronId = circ.usr(); - } else if (nonCatCirc) { - patronId = nonCatCirc.patron(); - } + if (hold) { + console.debug('fleshCommonData() hold ', hold.usr()); + promise = promise.then(_ => { + return this.fetchPatron(hold.usr()) + .then(usr => { + result.hold_patron = usr; + console.debug('Setting hold patron to ' + usr.id()); + }); + }); + } + + const circPatronId = circ ? circ.usr() : + (nonCatCirc ? nonCatCirc.patron() : null); - if (patronId) { - promise = promise.then(_ => { - return this.pcrud.retrieve('au', patronId, - {flesh: 1, flesh_fields : {'au' : ['card']}}) - .toPromise().then(p => result.patron = p); + if (circPatronId) { + console.debug('fleshCommonData() circ ', circPatronId); + promise = promise.then(_ => { + return this.fetchPatron(circPatronId) + .then(usr => { + result.circ_patron = usr; + console.debug('Setting circ patron to ' + usr.id()); }); - } + }); } + // Set a default patron value which is used in most cases. + promise = promise.then(_ => { + result.patron = result.hold_patron || result.circ_patron; + }); if (result.record) { result.title = result.record.title(); @@ -808,6 +838,14 @@ export class CircService { } } + promise = promise.then(_ => { + // By default, all items route-to their location. + // Value replaced later on as needed. + if (copy && typeof copy.location() === 'object') { + result.routeTo = copy.location().name(); + } + }); + if (volume) { // Flesh volume prefixes and suffixes diff --git a/Open-ILS/src/eg2/src/app/staff/share/circ/route-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/share/circ/route-dialog.component.ts index 490e065..c39ced3 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/circ/route-dialog.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/circ/route-dialog.component.ts @@ -44,11 +44,13 @@ export class RouteDialogComponent extends DialogComponent { return from(this.applySettings()) .pipe(concatMap(exit => { - if (exit) { - return of(exit); - } else { - return from(this.collectData()); - } + return from( + this.collectData().then(exit2 => { + // If either applySettings or collectData() tell us + // to exit, make it so. + return exit || exit2; + }) + ); })) .pipe(concatMap(exit => { @@ -64,6 +66,8 @@ export class RouteDialogComponent extends DialogComponent { let promise = Promise.resolve(null); const hold = this.checkin.hold; + console.debug('Route Dialog collecting data'); + if (this.slip !== 'hold_shelf_slip') { // Always fetch the most recent transit for the copy, @@ -102,6 +106,7 @@ export class RouteDialogComponent extends DialogComponent { } applySettings(): Promise { + console.debug('Route Dialog applying print settings'); if (this.checkin.transit) { if (this.checkin.patron && this.checkin.hold && -- 1.7.2.5