From: Bill Erickson Date: Fri, 24 Jun 2022 20:17:40 +0000 (-0400) Subject: LP1840773 SCKO Angular X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=762a6d91559fd124ba0977e308638758c7b0774a;p=working%2FEvergreen.git LP1840773 SCKO Angular Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/scko/scko.component.html b/Open-ILS/src/eg2/src/app/scko/scko.component.html index 1b8360ac60..f81726132a 100644 --- a/Open-ILS/src/eg2/src/app/scko/scko.component.html +++ b/Open-ILS/src/eg2/src/app/scko/scko.component.html @@ -1,7 +1,7 @@ - + diff --git a/Open-ILS/src/eg2/src/app/scko/scko.service.ts b/Open-ILS/src/eg2/src/app/scko/scko.service.ts index c5a215fe05..e0109f0526 100644 --- a/Open-ILS/src/eg2/src/app/scko/scko.service.ts +++ b/Open-ILS/src/eg2/src/app/scko/scko.service.ts @@ -14,9 +14,13 @@ import {AudioService} from '@eg/share/util/audio.service'; import {StringService} from '@eg/share/string/string.service'; interface CheckoutStat { - override?: boolean; - redo?: boolean; - renew?: boolean; + override: boolean; + redo: boolean; + renew: boolean; + displayText: string; + displayTextArgs: any; + alertSound: string; + shouldPopup: boolean; } @Injectable({providedIn: 'root'}) @@ -248,9 +252,12 @@ export class SckoService { } else if (stat.renew) { return this.renew(barcode); } - }); - // return this.router.navigate(['/scko']); + // Checkout actions always takes us back to the main page + // so we can see our items out in progress. + }) + .then(stat => this.notifyPatron(stat)) + .finally(() => this.router.navigate(['/scko'])); } renew(barcode: string, override?: boolean): Promise { @@ -278,27 +285,28 @@ export class SckoService { }); } - notifyPatron(text: string, sound: string, popup?: boolean, stringArgs?: any) { + notifyPatron(stat: CheckoutStat) { this.statusDisplayText = ''; - if (this.alertAudio && sound) { - this.audio.play(sound); + if (this.alertAudio && stat.alertSound) { + this.audio.play(stat.alertSound); } - if (!text) { return; } + if (!stat.displayText) { return; } - this.strings.interpolate(text, stringArgs).then(str => { + this.strings.interpolate(stat.displayText, stat.displayTextArgs) + .then(str => { this.statusDisplayText = str; - if (this.alertPopup && popup && str) { + if (this.alertPopup && stat.shouldPopup && str) { this.alertDialog.dialogBody = str; this.alertDialog.open().toPromise(); } }); } - handleCheckoutResult(result: any, - barcode: string, action: string): Promise { + handleCheckoutResult( + result: any, barcode: string, action: string): Promise { if (Array.isArray(result)) { result = result[0]; @@ -312,17 +320,22 @@ export class SckoService { return; } - let alertText = ''; - let alertSound = ''; + const checkoutStat: CheckoutStat = { + displayText: 'scko.unknown', + alertSound: '', + shouldPopup: false, + redo: false, + override: false, + renew: false, + displayTextArgs: {} + }; if (evt.textcode === 'SUCCESS') { - alertText = `scko.${action}.success`; - alertSound = `success.scko.${action}`; - this.notifyPatron; - return Promise.resolve({}); + checkoutStat.displayText = `scko.${action}.success`; + checkoutStat.alertSound = `success.scko.${action}`; } - return Promise.resolve({}); + return Promise.resolve(checkoutStat); } }