LP1869898 Ang cat copy table responds to broadcasts
authorBill Erickson <berickxx@gmail.com>
Wed, 5 Aug 2020 14:43:05 +0000 (10:43 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 13 Aug 2020 15:16:35 +0000 (11:16 -0400)
Angular staff catalog copy table responds to broadcasts of modified
holdings.  When holdings for the current record have changed, the table
data is refreshed.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/staff/catalog/record/copies.component.ts

index bfc2b03..9e288ee 100644 (file)
@@ -7,6 +7,7 @@ import {Pager} from '@eg/share/util/pager';
 import {OrgService} from '@eg/core/org.service';
 import {GridDataSource, GridColumn, GridCellTextGenerator} from '@eg/share/grid/grid';
 import {GridComponent} from '@eg/share/grid/grid.component';
+import {BroadcastService} from '@eg/share/util/broadcast.service';
 
 @Component({
   selector: 'eg-catalog-copies',
@@ -35,6 +36,7 @@ export class CopiesComponent implements OnInit {
         private net: NetService,
         private org: OrgService,
         private staffCat: StaffCatalogService,
+        private broadcaster: BroadcastService
     ) {
         this.gridDataSource = new GridDataSource();
     }
@@ -61,10 +63,12 @@ export class CopiesComponent implements OnInit {
             holdable: row => this.copyContext.holdable(row),
             barcode: row => row.barcode
         };
-    }
 
-    collectData() {
-        if (!this.recId) { return; }
+        this.broadcaster.listen('eg.holdings.update').subscribe(data => {
+            if (data && data.records && data.records.includes(this.recId)) {
+                this.copyGrid.reload();
+            }
+        });
     }
 
     orgName(orgId: number): string {