From: Galen Charlton Date: Thu, 9 Jul 2020 21:15:58 +0000 (-0400) Subject: org-family-select: tweak so that mutating its ngModel now updates the control X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=324979a9018e5710194730c70450d278bcf7835a;p=working%2FEvergreen.git org-family-select: tweak so that mutating its ngModel now updates the control Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/eg2/src/app/share/org-family-select/org-family-select.component.html b/Open-ILS/src/eg2/src/app/share/org-family-select/org-family-select.component.html index 5ffaf5a03d..308199e800 100644 --- a/Open-ILS/src/eg2/src/app/share/org-family-select/org-family-select.component.html +++ b/Open-ILS/src/eg2/src/app/share/org-family-select/org-family-select.component.html @@ -6,7 +6,7 @@ + [applyOrgId]="selectedOrgId"> diff --git a/Open-ILS/src/eg2/src/app/share/org-family-select/org-family-select.component.ts b/Open-ILS/src/eg2/src/app/share/org-family-select/org-family-select.component.ts index bf10232712..9ef00c1e5b 100644 --- a/Open-ILS/src/eg2/src/app/share/org-family-select/org-family-select.component.ts +++ b/Open-ILS/src/eg2/src/app/share/org-family-select/org-family-select.component.ts @@ -1,8 +1,9 @@ -import {Component, EventEmitter, OnInit, Input, Output, ViewChild, forwardRef} from '@angular/core'; +import {Component, EventEmitter, OnInit, Input, Output, ViewChildren, QueryList, forwardRef} from '@angular/core'; import {ControlValueAccessor, FormGroup, FormControl, NG_VALUE_ACCESSOR} from '@angular/forms'; import {AuthService} from '@eg/core/auth.service'; import {IdlObject} from '@eg/core/idl.service'; import {OrgService} from '@eg/core/org.service'; +import {OrgSelectComponent} from '@eg/share/org-select/org-select.component'; export interface OrgFamily { primaryOrgId: number; @@ -51,6 +52,8 @@ export class OrgFamilySelectComponent implements ControlValueAccessor, OnInit { @Input() domId: string; + @ViewChildren(OrgSelectComponent) orgSelects: QueryList; + // this is the most up-to-date value used for ngModel and reactive form // subscriptions options: OrgFamily; @@ -128,6 +131,10 @@ export class OrgFamilySelectComponent implements ControlValueAccessor, OnInit { writeValue(value: OrgFamily) { if (value) { this.selectedOrgId = value['primaryOrgId']; + if (this.orgSelects) { + this.orgSelects.toArray()[0].applyOrgId = this.selectedOrgId; + this.options = {primaryOrgId: this.selectedOrgId}; + } this.familySelectors.patchValue({ 'includeAncestors': value['includeAncestors'] ? value['includeAncestors'] : false, 'includeDescendants': value['includeDescendants'] ? value['includeDescendants'] : false,