argos/dmp-frontend/src/app/ui/admin/description-template/editor/components/field-type/radio-box/description-template-editor...

27 lines
1.1 KiB
TypeScript

import { Component, Input, OnInit } from '@angular/core';
import { UntypedFormArray, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
import { DescriptionTemplateRadioBoxDataEditorModel } from '../../../description-template-editor.model';
@Component({
selector: 'app-description-template-editor-radio-box-field-component',
styleUrls: ['./description-template-editor-radio-box-field.component.scss'],
templateUrl: './description-template-editor-radio-box-field.component.html'
})
export class DescriptionTemplateEditorRadioBoxFieldComponent implements OnInit {
@Input() form: UntypedFormGroup;
ngOnInit() {
}
addNewRow() {
const radioListOptions: DescriptionTemplateRadioBoxDataEditorModel = new DescriptionTemplateRadioBoxDataEditorModel();
if (!this.form.get('data').get('options')) { (<UntypedFormGroup>this.form.get('data')).addControl('options', new UntypedFormBuilder().array([])); }
(<UntypedFormArray>this.form.get('data').get('options')).push(radioListOptions.buildForm());
}
deleteRow(intex: number) {
if (this.form.get('data').get('options')) { (<UntypedFormArray>this.form.get('data').get('options')).removeAt(intex); }
}
}