From 1afbf5aba860e2ab29884d58b680eb5b77581b67 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 Signed-off-by: Jane Sandberg --- .../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 f0ae758a75..c079a1678c 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 @@ -202,9 +202,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; @@ -318,17 +318,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, flesh); + 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 @@ -343,7 +346,7 @@ export class HoldComponent implements OnInit { }); } - resetForm(keepBarcode?: boolean) { + resetForm(keepBarcode?: boolean): Promise { this.user = null; this.notifyEmail = true; this.notifyPhone = true; @@ -361,7 +364,7 @@ export class HoldComponent implements OnInit { }); // Required after rebuilding the contexts - this.getTargetMeta(); + return this.getTargetMeta(); } applyUserSettings() { -- 2.43.2