Fix/unions (#2825)

* mocks for union value

* fix: properly handle values in unions

---------

Co-authored-by: Matt Hill <mattnine@protonmail.com>
This commit is contained in:
Alex Inkin
2025-02-06 21:06:04 +04:00
committed by GitHub
parent 04611b0ae2
commit 4e22f13007
3 changed files with 53 additions and 19 deletions

View File

@@ -30,6 +30,7 @@ export class FormUnionComponent implements OnChanges {
private readonly form = inject(FormGroupName)
private readonly formService = inject(FormService)
private readonly values: Record<string, any> = {}
get union(): string {
return this.form.value.selection
@@ -37,10 +38,13 @@ export class FormUnionComponent implements OnChanges {
@tuiPure
onUnion(union: string) {
this.values[this.union] = this.form.control.controls['value'].value
this.form.control.setControl(
'value',
this.formService.getFormGroup(
union ? this.spec.variants[union].spec : {},
[],
this.values[union],
),
{
emitEvent: false,