Skip to content
Snippets Groups Projects
Commit 4949b1e8 authored by jojohoch's avatar jojohoch
Browse files

[table] Implement parentForm to table component and table child overlay

parent f5dfe497
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,8 @@ import { MatButtonModule } from '@angular/material/button'; ...@@ -7,6 +7,8 @@ import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon'; import { MatIconModule } from '@angular/material/icon';
import { TextFieldComponent } from 'common/components/input-elements/text-field.component'; import { TextFieldComponent } from 'common/components/input-elements/text-field.component';
import { CheckboxComponent } from 'common/components/input-elements/checkbox.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({ @Component({
selector: 'aspect-table-child-overlay', selector: 'aspect-table-child-overlay',
...@@ -30,6 +32,7 @@ import { CheckboxComponent } from 'common/components/input-elements/checkbox.com ...@@ -30,6 +32,7 @@ import { CheckboxComponent } from 'common/components/input-elements/checkbox.com
}) })
export class TableChildOverlay implements OnInit { export class TableChildOverlay implements OnInit {
@Input() element!: UIElement; @Input() element!: UIElement;
@Input() parentForm!: UntypedFormGroup;
@Output() elementSelected = new EventEmitter<TableChildOverlay>(); @Output() elementSelected = new EventEmitter<TableChildOverlay>();
@ViewChild('elementContainer', { read: ViewContainerRef, static: true }) private elementContainer!: ViewContainerRef; @ViewChild('elementContainer', { read: ViewContainerRef, static: true }) private elementContainer!: ViewContainerRef;
childComponent!: ComponentRef<ElementComponent>; childComponent!: ComponentRef<ElementComponent>;
...@@ -42,11 +45,12 @@ export class TableChildOverlay implements OnInit { ...@@ -42,11 +45,12 @@ export class TableChildOverlay implements OnInit {
this.childComponent = this.elementContainer.createComponent(this.element.getElementComponent()); this.childComponent = this.elementContainer.createComponent(this.element.getElementComponent());
this.childComponent.instance.elementModel = this.element; 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 || if (this.childComponent.instance instanceof TextFieldComponent ||
this.childComponent.instance instanceof CheckboxComponent) { this.childComponent.instance instanceof CheckboxComponent) {
this.childComponent.instance.tableMode = true; this.childComponent.instance.tableMode = true;
this.childComponent.instance.parentForm = this.parentForm;
} }
// this.childComponent.location.nativeElement.style.pointerEvents = 'none'; // this.childComponent.location.nativeElement.style.pointerEvents = 'none';
if (this.element.type !== 'text') { if (this.element.type !== 'text') {
...@@ -56,8 +60,9 @@ export class TableChildOverlay implements OnInit { ...@@ -56,8 +60,9 @@ export class TableChildOverlay implements OnInit {
if (this.element.type === 'text') { if (this.element.type === 'text') {
this.childComponent.location.nativeElement.style.margin = '5px'; 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.setInput('clozeContext', true);
this.childComponent.instance.parentForm = this.parentForm;
} }
} }
......
...@@ -64,6 +64,7 @@ import { MeasurePipe } from 'common/pipes/measure.pipe'; ...@@ -64,6 +64,7 @@ import { MeasurePipe } from 'common/pipes/measure.pipe';
<mat-icon>remove</mat-icon> <mat-icon>remove</mat-icon>
</button> </button>
<aspect-table-child-overlay [element]="$any(elementGrid[i][j])" <aspect-table-child-overlay [element]="$any(elementGrid[i][j])"
[parentForm]="parentForm"
(elementSelected)="childElementSelected.emit($event)"> (elementSelected)="childElementSelected.emit($event)">
</aspect-table-child-overlay> </aspect-table-child-overlay>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment