From: Bill Erickson Date: Fri, 15 Jul 2022 14:57:20 +0000 (-0400) Subject: LP1840773 SCKO Renewals continued; login failed message X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d72c67ff0e3db422da4268491dd7f423efe62a50;p=working%2FEvergreen.git LP1840773 SCKO Renewals continued; login failed message Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/share/string/string.service.ts b/Open-ILS/src/eg2/src/app/share/string/string.service.ts index 88d0c8ae2d..e51874cb35 100644 --- a/Open-ILS/src/eg2/src/app/share/string/string.service.ts +++ b/Open-ILS/src/eg2/src/app/share/string/string.service.ts @@ -56,6 +56,9 @@ export class StringService { processPending() { const pstring = this.pending[0]; + + console.debug('STRING', pstring.key, pstring.ctx); + this.strings[pstring.key].resolver(pstring.ctx).then( txt => { pstring.resolve(txt); diff --git a/Open-ILS/src/eg2/src/app/staff/scko/banner.component.ts b/Open-ILS/src/eg2/src/app/staff/scko/banner.component.ts index 4041c88c2b..9327379064 100644 --- a/Open-ILS/src/eg2/src/app/staff/scko/banner.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/scko/banner.component.ts @@ -4,7 +4,7 @@ import {Router, ActivatedRoute, NavigationEnd} from '@angular/router'; import {AuthService, AuthWsState} from '@eg/core/auth.service'; import {NetService} from '@eg/core/net.service'; import {StoreService} from '@eg/core/store.service'; -import {SckoService} from './scko.service'; +import {SckoService, ActionContext} from './scko.service'; import {OrgService} from '@eg/core/org.service'; import {EventService, EgEvent} from '@eg/core/event.service'; import {HatchService} from '@eg/core/hatch.service'; @@ -21,7 +21,6 @@ export class SckoBannerComponent implements OnInit, AfterViewInit { patronUsername: string; patronPassword: string; - patronLoginFailed = false; staffUsername: string; staffPassword: string; @@ -127,15 +126,26 @@ export class SckoBannerComponent implements OnInit, AfterViewInit { submitPatronLogin() { this.patronUsername = (this.patronUsername || '').trim(); - this.patronLoginFailed = false; - this.scko.loadPatron(this.patronUsername, this.patronPassword).finally(() => { - this.patronUsername = ''; - this.patronPassword = ''; + this.scko.loadPatron(this.patronUsername, this.patronPassword) + .finally(() => { + if (this.scko.patronSummary === null) { - this.patronLoginFailed = true; + + const ctx: ActionContext = { + username: this.patronUsername, + shouldPopup: true, + alertSound: 'error.scko.login_failed', + displayText: 'scko.error.login_failed' + }; + + this.scko.notifyPatron(ctx); + } else { this.focusNode('item-barcode'); } + + this.patronUsername = ''; + this.patronPassword = ''; }); } diff --git a/Open-ILS/src/eg2/src/app/staff/scko/items.component.ts b/Open-ILS/src/eg2/src/app/staff/scko/items.component.ts index 94ac3aa819..83bd419bb8 100644 --- a/Open-ILS/src/eg2/src/app/staff/scko/items.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/scko/items.component.ts @@ -6,7 +6,7 @@ import {AuthService} from '@eg/core/auth.service'; import {PcrudService} from '@eg/core/pcrud.service'; import {NetService} from '@eg/core/net.service'; import {IdlObject} from '@eg/core/idl.service'; -import {SckoService} from './scko.service'; +import {SckoService, ActionContext} from './scko.service'; import {ServerStoreService} from '@eg/core/server-store.service'; import {PrintService} from '@eg/share/print/print.service'; @@ -84,17 +84,21 @@ export class SckoItemsComponent implements OnInit { const renewList = this.circs.filter(c => this.selected[c.id()]); if (renewList.length === 0) { return; } + const contexts: ActionContext[] = []; + from(renewList).pipe(switchMap(circ => { return of( this.scko.renew(circ.target_copy().barcode()) - .then(res => { - if (!res.newCirc) { return; } + .then(ctx => { + contexts.push(ctx); + + if (!ctx.newCirc) { return; } // Replace the renewed circ with the new circ. const circs = []; this.circs.forEach(c => { if (c.id() === circ.id()) { - circs.push(res.newCirc); + circs.push(ctx.newCirc); } else { circs.push(c); } @@ -102,7 +106,20 @@ export class SckoItemsComponent implements OnInit { this.circs = circs; }) ); - })).toPromise(); // run it + })).toPromise().then(_ => { + + // Create one ActionContext to represent the batch for + // notification purposes. Avoid popups and audio on batch + // renewals. + + const notifyCtx: ActionContext = { + displayText: 'scko.batch_renew.result', + renewSuccessCount: contexts.filter(c => c.newCirc).length, + renewFailCount: contexts.filter(c => !c.newCirc).length + }; + + this.scko.notifyPatron(notifyCtx); + }); } } diff --git a/Open-ILS/src/eg2/src/app/staff/scko/scko.component.html b/Open-ILS/src/eg2/src/app/staff/scko/scko.component.html index 1ae367dffe..f7fd5d8e47 100644 --- a/Open-ILS/src/eg2/src/app/staff/scko/scko.component.html +++ b/Open-ILS/src/eg2/src/app/staff/scko/scko.component.html @@ -46,23 +46,41 @@ -No more renewals allowed for item {{barcode}} + + Login for "{{ctx ? ctx.username : ''}}" failed. + + + + + No more renewals allowed for item {{ctx ? ctx.barcode : ''}} + - - Item {{barcode}} was not found in the system. Try re-scanning the item. + + Item {{ctx ? ctx.barcode : ctx}} was not found in the system. Try re-scanning the item. - - Item {{barcode}} is not allowed to circulate + + Item {{ctx ? ctx.barcode : ''}} is not allowed to circulate + + + {{ctx.renewSuccessCount}} item(s) successfully renewed. + + + {{ctx.renewFailCount}} item(s) failed to renew. + + + + + { + override?: boolean, external?: boolean): Promise { let method = 'open-ils.circ.renew'; if (override) { method += '.override'; } @@ -353,7 +356,7 @@ export class SckoService { }); } - notifyPatron(ctx: CheckoutContext) { + notifyPatron(ctx: ActionContext) { console.debug('notifyPatron(): ', ctx); this.statusDisplayText = ''; @@ -368,9 +371,10 @@ export class SckoService { if (!ctx.displayText) { return; } - this.strings.interpolate(ctx.displayText, {barcode: ctx.barcode}) + this.strings.interpolate(ctx.displayText, {ctx: ctx}) .then(str => { this.statusDisplayText = str; + console.debug('Displaying text to user:', str); if (this.alertPopup && ctx.shouldPopup && str) { this.alertDialog.dialogBody = str; @@ -380,7 +384,7 @@ export class SckoService { } handleCheckoutResult(result: any, barcode: string, - action: string, external?: boolean): Promise { + action: string, external?: boolean): Promise { if (Array.isArray(result)) { result = result[0]; @@ -394,7 +398,7 @@ export class SckoService { return; } - const ctx: CheckoutContext = { + const ctx: ActionContext = { result: result, firstEvent: evt, payload: payload, @@ -428,7 +432,7 @@ export class SckoService { return this.handleEvents(ctx); } - handleOpenCirc(ctx: CheckoutContext): Promise { + handleOpenCirc(ctx: ActionContext): Promise { if (ctx.payload.old_circ) { const age = this.orgSettings['circ.checkout_auto_renew_age']; @@ -472,7 +476,7 @@ export class SckoService { return Promise.resolve(ctx); } - handleEvents(ctx: CheckoutContext): Promise { + handleEvents(ctx: ActionContext): Promise { let override = true; let abortTransit = false; let lastErrorText = '';