From 56c303275f5534bb093d7ae7d16e8224ce473899 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 29 Sep 2020 14:26:56 -0400 Subject: [PATCH] LP1889128 Confirm data loaded before Place Hold activated When changing users in the place hold form of the staff catalog, the form resets itself and refreshes all of the user and bib, etc. data. This patch ensures all data has been retrieved before the place hold button is reactivated after changing the user. Signed-off-by: Bill Erickson Signed-off-by: Michele Morgan --- .../src/app/staff/catalog/hold/hold.component.ts | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) 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 aba662d1c3..2f6b62f45b 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 @@ -195,9 +195,9 @@ export class HoldComponent implements OnInit { } // Load the bib, call number, copy, etc. data associated with each target. - getTargetMeta() { - this.holds.getHoldTargetMeta(this.holdType, this.holdTargets) - .subscribe(meta => { + getTargetMeta(): Promise { + return this.holds.getHoldTargetMeta(this.holdType, this.holdTargets) + .toPromise().then(meta => { this.holdContexts.filter(ctx => ctx.holdTarget === meta.target) .forEach(ctx => { ctx.holdMeta = meta; @@ -311,17 +311,20 @@ export class HoldComponent implements OnInit { this.getUser(); } - getUser(id?: number) { + getUser(id?: number): Promise { - this.resetForm(true); + let promise = this.resetForm(true); const flesh = {flesh: 1, flesh_fields: {au: ['settings']}}; - const promise = id ? this.patron.getById(id, flesh) : - this.patron.getByBarcode(this.userBarcode); + promise = promise.then(_ => { + return id ? + this.patron.getById(id, flesh) : + this.patron.getByBarcode(this.userBarcode, flesh); + }); this.badBarcode = null; - promise.then(user => { + return promise.then(user => { if (!user) { // IDs are assumed to valid @@ -336,7 +339,7 @@ export class HoldComponent implements OnInit { }); } - resetForm(keepBarcode?: boolean) { + resetForm(keepBarcode?: boolean): Promise { this.user = null; this.notifyEmail = true; this.notifyPhone = true; @@ -354,7 +357,7 @@ export class HoldComponent implements OnInit { }); // Required after rebuilding the contexts - this.getTargetMeta(); + return this.getTargetMeta(); } applyUserSettings() { -- 2.11.0