ensure that provider contact addresses component gets found before reloading its...
authorGalen Charlton <gmc@equinoxinitiative.org>
Wed, 1 Apr 2020 18:35:27 +0000 (14:35 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Wed, 1 Apr 2020 18:35:27 +0000 (14:35 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/staff/acq/provider/provider-contacts.component.ts

index 83bcd6c..d2fd645 100644 (file)
@@ -1,4 +1,4 @@
-import {Component, OnInit, AfterViewInit, Input, ViewChild} from '@angular/core';
+import {Component, OnInit, AfterViewInit, Input, ViewChild, ChangeDetectorRef} from '@angular/core';
 import {empty, throwError, Observable, from} from 'rxjs';
 import {map} from 'rxjs/operators';
 import {Router, ActivatedRoute, ParamMap} from '@angular/router';
@@ -27,7 +27,7 @@ export class ProviderContactsComponent implements OnInit, AfterViewInit {
 
     gridSource: GridDataSource;
     @ViewChild('editDialog', { static: true }) editDialog: FmRecordEditorComponent;
-    @ViewChild('providerContactAddresses', { static: true }) providerContactAddresses: ProviderContactAddressesComponent;
+    @ViewChild('providerContactAddresses', { static: false }) providerContactAddresses: ProviderContactAddressesComponent;
     @ViewChild('acqProviderContactsGrid', { static: true }) providerContactsGrid: GridComponent;
     @ViewChild('successString', { static: true }) successString: StringComponent;
     @ViewChild('createString', { static: false }) createString: StringComponent;
@@ -52,6 +52,7 @@ export class ProviderContactsComponent implements OnInit, AfterViewInit {
     constructor(
         private router: Router,
         private route: ActivatedRoute,
+        private changeDetector: ChangeDetectorRef,
         private net: NetService,
         private auth: AuthService,
         private idl: IdlService,
@@ -94,6 +95,8 @@ export class ProviderContactsComponent implements OnInit, AfterViewInit {
             (idlThing: IdlObject) => {
                 this.selectedContact = idlThing;
                 console.debug('selected contact',this.selectedContact);
+                // ensure that the contact address grid is instantiated
+                this.changeDetector.detectChanges();
                 this.providerContactAddresses.reloadGrid();
             }
         );