From 41da8e89cf8200e2f76693dadc7d2b66fee1ed92 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 9 Nov 2021 14:36:32 -0700 Subject: [PATCH] fixes #781 --- .../form-object/form-object.component.html | 1 + .../form-object/form-object.component.ts | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ui/src/app/components/form-object/form-object.component.html b/ui/src/app/components/form-object/form-object.component.html index db2f4e356..c0b15145b 100644 --- a/ui/src/app/components/form-object/form-object.component.html +++ b/ui/src/app/components/form-object/form-object.component.html @@ -106,6 +106,7 @@ [formGroup]="$any(entry.value)" [current]="current ? current[entry.key] : undefined" [unionSpec]="spec.type === 'union' ? spec : undefined" + (onUnionChange)="resizeUnion(entry.key)" > diff --git a/ui/src/app/components/form-object/form-object.component.ts b/ui/src/app/components/form-object/form-object.component.ts index e2721fd8a..6614ab5f7 100644 --- a/ui/src/app/components/form-object/form-object.component.ts +++ b/ui/src/app/components/form-object/form-object.component.ts @@ -20,6 +20,7 @@ export class FormObjectComponent { @Input() current: { [key: string]: any } @Input() showEdited: boolean = false @Output() onInputChange = new EventEmitter() + @Output() onUnionChange = new EventEmitter() warningAck: { [key: string]: boolean } = { } unmasked: { [key: string]: boolean } = { } objectDisplay: { [key: string]: { expanded: boolean, height: string } } = { } @@ -59,17 +60,27 @@ export class FormObjectComponent { } updateUnion (e: any): void { + const primary = this.unionSpec.tag.id + Object.keys(this.formGroup.controls).forEach(control => { - if (control === 'type') return + if (control === primary) return this.formGroup.removeControl(control) }) const unionGroup = this.formService.getUnionObject(this.unionSpec as ValueSpecUnion, e.detail.value) Object.keys(unionGroup.controls).forEach(control => { - if (control === 'type') return + if (control === primary) return this.formGroup.addControl(control, unionGroup.controls[control]) }) + + this.onUnionChange.emit() + } + + resizeUnion (key: string): void { + setTimeout(() => { + this.objectDisplay[key].height = this.getDocSize(key) + }, 100) } addListItemWrapper (key: string, spec: ValueSpec) {