Newer
Older
import {
Component, EventEmitter, Input, Output, ViewChild
} from '@angular/core';
import { FormGroup } from '@angular/forms';
import { ElementComponent } from '../directives/element-component.directive';
ToggleButtonElement,
ValueChangeElement
} from '../interfaces/elements';
selector: 'aspect-compound-child-overlay',
<div [style.border]="isSelected ? 'purple solid 1px' : ''"
[style.border-radius.px]="3"
(click)="elementSelected.emit(this); $event.stopPropagation();">
<aspect-toggle-button *ngIf="element.type === 'toggle-button'" #childComponent
[style.pointer-events]="editorMode ? 'none' : 'auto'"
[parentForm]="parentForm"
[style.display]="'inline-block'"
[elementModel]="$any(element)">
</aspect-toggle-button>
<aspect-text-field *ngIf="element.type === 'text-field'" #childComponent
[isClozeChild]="true"
[style.pointer-events]="editorMode ? 'none' : 'auto'"
[parentForm]="parentForm"
[style.display]="'inline-block'"
[elementModel]="$any(element)">
</aspect-text-field>
<aspect-drop-list-simple *ngIf="element.type === 'drop-list'" #childComponent
[style.pointer-events]="editorMode ? 'none' : 'auto'"
[parentForm]="parentForm"
[style.display]="'inline-block'"
[style.vertical-align]="'middle'"
[elementModel]="$any(element)">
</div>
`
})
export class CompoundChildOverlayComponent {
@Input() element!: ToggleButtonElement | TextFieldElement | DropListSimpleElement;
@Input() editorMode: boolean = false;
@Output() elementValueChanged = new EventEmitter<ValueChangeElement>();
@Output() elementSelected = new EventEmitter<CompoundChildOverlayComponent>();
@ViewChild('childComponent') childComponent!: ElementComponent;
isSelected: boolean = false;
setSelected(newValue: boolean): void {
this.isSelected = newValue;
}
}