LP1904036 Patron alerts page continued
authorBill Erickson <berickxx@gmail.com>
Thu, 25 Feb 2021 22:59:58 +0000 (17:59 -0500)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:24 +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/patron.component.ts

index b1b18cf..1105f49 100644 (file)
@@ -70,8 +70,15 @@ export class PatronComponent implements OnInit, AfterViewInit {
                 this.context.patron ? this.context.patron.id() : null;
 
             if (this.patronId) {
+
                 if (this.patronId !== prevId) { // different patron
-                    this.changePatron(this.patronId);
+                    this.changePatron(this.patronId)
+                    .then(_ => this.routeToAlertsPane());
+
+                } else {
+                    // Patron already loaded, most likely from the search tab.
+                    // See if we still need to show alerts.
+                    this.routeToAlertsPane();
                 }
             } else {
                 // Use the ID of the previously loaded patron.
@@ -130,16 +137,19 @@ export class PatronComponent implements OnInit, AfterViewInit {
         }
     }
 
-    changePatron(id: number) {
+    changePatron(id: number): Promise<any>  {
         this.patronId = id;
-        this.context.loadPatron(id)
-        .then(_ => {
-            if (this.context.patron &&
-                this.context.alerts.hasAlerts() &&
-               !this.context.patronAlertsShown()) {
-               this.router.navigate(['/staff/circ/patron', id, 'alerts'])
-            }
-        });
+        return this.context.loadPatron(id);
+    }
+
+    routeToAlertsPane() {
+        console.log('testing route change for alerts');
+        if (this.patronTab !== 'search' &&
+            this.context.patron &&
+            this.context.alerts.hasAlerts() &&
+           !this.context.patronAlertsShown()) {
+           this.router.navigate(['/staff/circ/patron', this.patronId, 'alerts'])
+        }
     }
 
     // Route to checkout tab for selected patron.