From 3b789b13a73a93f851834617bad6c69bdca6586d Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 9 Jul 2020 17:15:58 -0400 Subject: [PATCH] LP#1857150: org-family-select: have ngModel changes update the control Sponsored-by: Evergreen Community Development Initiative Signed-off-by: Galen Charlton Signed-off-by: Ruth Frasur Signed-off-by: Bill Erickson Signed-off-by: Jason Etheridge --- .../app/share/org-family-select/org-family-select.component.html | 2 +- .../share/org-family-select/org-family-select.component.spec.ts | 2 +- .../app/share/org-family-select/org-family-select.component.ts | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) 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.spec.ts b/Open-ILS/src/eg2/src/app/share/org-family-select/org-family-select.component.spec.ts index f389e7ad5e..c5bd4ab570 100644 --- a/Open-ILS/src/eg2/src/app/share/org-family-select/org-family-select.component.spec.ts +++ b/Open-ILS/src/eg2/src/app/share/org-family-select/org-family-select.component.spec.ts @@ -13,7 +13,7 @@ import {OrgService} from '@eg/core/org.service'; class MockOrgSelectComponent { @Input() domId: string; @Input() limitPerms: string; - @Input() initialOrgId: number; + @Input() applyOrgId(id: number) {} } describe('Component: OrgFamilySelect', () => { 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, -- 2.11.0