diff --git a/projects/common/components/compound-elements/table/table-child-overlay.component.ts b/projects/common/components/compound-elements/table/table-child-overlay.component.ts index 4e0a488d133f8ec92003330bc35cdfb28b93a071..b6623105c6e249685167685742a9a26c00dddf24 100644 --- a/projects/common/components/compound-elements/table/table-child-overlay.component.ts +++ b/projects/common/components/compound-elements/table/table-child-overlay.component.ts @@ -7,6 +7,8 @@ import { MatButtonModule } from '@angular/material/button'; import { MatIconModule } from '@angular/material/icon'; import { TextFieldComponent } from 'common/components/input-elements/text-field.component'; import { CheckboxComponent } from 'common/components/input-elements/checkbox.component'; +import { UntypedFormGroup } from '@angular/forms'; +import { DropListComponent } from 'common/components/input-elements/drop-list/drop-list.component'; @Component({ selector: 'aspect-table-child-overlay', @@ -30,6 +32,7 @@ import { CheckboxComponent } from 'common/components/input-elements/checkbox.com }) export class TableChildOverlay implements OnInit { @Input() element!: UIElement; + @Input() parentForm!: UntypedFormGroup; @Output() elementSelected = new EventEmitter<TableChildOverlay>(); @ViewChild('elementContainer', { read: ViewContainerRef, static: true }) private elementContainer!: ViewContainerRef; childComponent!: ComponentRef<ElementComponent>; @@ -42,11 +45,12 @@ export class TableChildOverlay implements OnInit { this.childComponent = this.elementContainer.createComponent(this.element.getElementComponent()); this.childComponent.instance.elementModel = this.element; - this.childComponent.changeDetectorRef.detectChanges(); // this fires onInit, which initializes the FormControl + // this.childComponent.changeDetectorRef.detectChanges(); // this fires onInit, which initializes the FormControl if (this.childComponent.instance instanceof TextFieldComponent || this.childComponent.instance instanceof CheckboxComponent) { this.childComponent.instance.tableMode = true; + this.childComponent.instance.parentForm = this.parentForm; } // this.childComponent.location.nativeElement.style.pointerEvents = 'none'; if (this.element.type !== 'text') { @@ -56,8 +60,9 @@ export class TableChildOverlay implements OnInit { if (this.element.type === 'text') { this.childComponent.location.nativeElement.style.margin = '5px'; } - if (this.element.type === 'drop-list') { + if (this.childComponent.instance instanceof DropListComponent) { this.childComponent.setInput('clozeContext', true); + this.childComponent.instance.parentForm = this.parentForm; } } diff --git a/projects/common/components/compound-elements/table/table.component.ts b/projects/common/components/compound-elements/table/table.component.ts index 42d0e54c1d9590874452c46de80352c2bbae7ac5..61e99e655271e454a73d06a99551a44b1d217335 100644 --- a/projects/common/components/compound-elements/table/table.component.ts +++ b/projects/common/components/compound-elements/table/table.component.ts @@ -64,6 +64,7 @@ import { MeasurePipe } from 'common/pipes/measure.pipe'; <mat-icon>remove</mat-icon> </button> <aspect-table-child-overlay [element]="$any(elementGrid[i][j])" + [parentForm]="parentForm" (elementSelected)="childElementSelected.emit($event)"> </aspect-table-child-overlay> </div>