From 6faef2eb948faae4ebbde17369e14b9766e91c66 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 24 Feb 2022 10:47:40 -0500 Subject: [PATCH] LP1904036 Clear patron context data on navigation Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../eg2/src/app/staff/circ/patron/patron.component.ts | 18 +++++------------- .../eg2/src/app/staff/circ/patron/patron.service.ts | 10 +++++++++- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.ts index 96f64d84e6..d476cbf0a1 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.ts @@ -36,7 +36,6 @@ export class PatronComponent implements OnInit, AfterViewInit { showSummary = true; loading = true; showRecentPatrons = false; - refreshing = false; /* eg-patron-edit is unable to find #editorToolbar directly * within the template. Adding a ref here allows it to @@ -120,21 +119,14 @@ export class PatronComponent implements OnInit, AfterViewInit { watchForTabChange() { - // When routing to a patron UI from a non-patron UI, refresh the - // patron's data so we pick up an external changes (e.g. holds - // placement). This is needed because the last active patron, - // if one exists, will still be cached in the patron service, - // which survives route changes. Route events occur in series - // and often repeat, though, so avoid refreshing the patron if - // we are already mid-refresh. + // When routing to a patron UI from a non-patron UI, clear all + // patron info that may have persisted via the context service. this.router.events .pipe(filter((evt: any) => evt instanceof RoutesRecognized), pairwise()) .subscribe((events: RoutesRecognized[]) => { - const prevUrl = events[0].urlAfterRedirects; - - if (!prevUrl.startsWith('/staff/circ/patron') && !this.refreshing) { - this.refreshing = true; - this.context.refreshPatron().then(_ => this.refreshing = false); + const prevUrl = events[0].urlAfterRedirects || ''; + if (!prevUrl.startsWith('/staff/circ/patron')) { + this.context.reset(); } }); diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts index 3c677cd266..e696cbabf1 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts @@ -72,6 +72,14 @@ export class PatronContextService { public patrons: PatronService ) {} + reset() { + this.summary = null; + this.loaded = false; + this.lastPatronSearch = null; + this.searchBarcode = null; + this.checkouts = []; + } + loadPatron(id: number): Promise { this.loaded = false; this.checkouts = []; @@ -83,7 +91,7 @@ export class PatronContextService { if (!id) { if (!this.summary) { - return Promise.reject('no can do'); + return Promise.resolve(); } else { id = this.summary.id; } -- 2.11.0