LP1904036 Register patron stores saved user in recents
authorBill Erickson <berickxx@gmail.com>
Thu, 7 Oct 2021 15:16:28 +0000 (11:16 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:38 +0000 (20:13 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.ts
Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts

index 3ef4a91..6823e79 100644 (file)
@@ -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;
             }
index d0a5118..d0f9a7c 100644 (file)
@@ -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);