From: Bill Erickson <berickxx@gmail.com>
Date: Thu, 7 Oct 2021 15:16:28 +0000 (-0400)
Subject: LP1904036 Register patron stores saved user in recents
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=82fcb5270a1bc705c00449d63985350a3254ead5;p=evergreen%2Ftadl.git

LP1904036 Register patron stores saved user in recents

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
---

diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.ts
index 3ef4a913a5..6823e799fc 100644
--- a/Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.ts
+++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.ts
@@ -1436,6 +1436,8 @@ export class EditComponent implements OnInit, AfterViewInit {
         ).toPromise().then(result => {
 
             if (result && result.classname) {
+                this.context.addRecentPatron(result.id());
+
                 // Successful result returns the patron IdlObject.
                 return this.modifiedPatron = result;
             }
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 d0a5118d27..d0f9a7c467 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
@@ -95,7 +95,9 @@ export class PatronContextService {
         .then(_ => this.addRecentPatron());
     }
 
-    addRecentPatron(): Promise<any> {
+    addRecentPatron(patronId?: number): Promise<any> {
+
+        if (!patronId) { patronId = this.summary.id; }
 
         return this.serverStore.getItem('ui.staff.max_recent_patrons')
         .then(num => {
@@ -104,12 +106,12 @@ export class PatronContextService {
             const patrons: number[] =
                 this.store.getLoginSessionItem('eg.circ.recent_patrons') || [];
 
-            patrons.splice(0, 0, this.summary.id);  // put this user at front
+            patrons.splice(0, 0, patronId);  // put this user at front
             patrons.splice(this.maxRecentPatrons, 1); // remove excess
 
             // remove any other occurrences of this user, which may have been
             // added before the most recent user.
-            const idx = patrons.indexOf(this.summary.id, 1);
+            const idx = patrons.indexOf(patronId, 1);
             if (idx > 0) { patrons.splice(idx, 1); }
 
             this.store.setLoginSessionItem('eg.circ.recent_patrons', patrons);