refresh interface on tab change
authorJason Etheridge <jason@EquinoxOLI.org>
Tue, 22 Nov 2022 20:31:16 +0000 (15:31 -0500)
committerJason Etheridge <jason@EquinoxOLI.org>
Wed, 4 Jan 2023 13:45:13 +0000 (08:45 -0500)
Signed-off-by: Jason Etheridge <jason@EquinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html
Open-ILS/src/eg2/src/app/staff/share/bib-staff-view/bib-staff-view.component.ts

index c4384a0..114ebca 100644 (file)
@@ -41,7 +41,7 @@
       <li role="presentation" [ngbNavItem]="'staff_view'">
         <a i18n ngbNavLink role="tab">Staff View</a>
         <ng-template ngbNavContent>
-          <eg-bib-staff-view [bibSummary]="summaryForDisplay()">
+          <eg-bib-staff-view [recordId]="recordId" [bibSummary]="summaryForDisplay()">
           </eg-bib-staff-view>
         </ng-template>
       </li>
index 2165705..f0418d1 100644 (file)
@@ -12,6 +12,7 @@ import {CatalogService} from '@eg/share/catalog/catalog.service';
 })
 export class BibStaffViewComponent implements OnInit {
 
+    recId: number;
     initDone = false;
 
     // True / false if the display is vertically expanded
@@ -24,8 +25,14 @@ export class BibStaffViewComponent implements OnInit {
     }
     get expand(): boolean { return this._exp; }
 
-    // If provided, the record will be fetched by the component.
-    @Input() recordId: number;
+    @Input() set recordId(id: number) {
+        this.recId = id;
+        // Only force new data collection when recordId()
+        // is invoked after ngInit() has already run.
+        if (this.initDone) {
+            this.loadSummary();
+        }
+    }
 
     // Otherwise, we'll use the provided bib summary object.
     summary: BibRecordSummary;
@@ -49,12 +56,9 @@ export class BibStaffViewComponent implements OnInit {
         .then(value => this.expand = !value)
         .then(_ => this.cat.fetchCcvms())
         .then(_ => {
-            if (this.summary) {
-                return this.summary.getBibCallNumber();
-            } else {
-                if (this.recordId) {
-                    return this.loadSummary();
-                }
+            if (this.recId) {
+                // ignore any existing this.summary, always refetch
+                return this.loadSummary();
             }
         }).then(_ => this.initDone = true);
     }
@@ -65,7 +69,7 @@ export class BibStaffViewComponent implements OnInit {
 
     loadSummary(): Promise<any> {
         return this.bib.getBibSummary(
-            this.recordId,
+            this.recId,
             this.org.root().id(),
             true // isStaff
         ).toPromise()