import { Field } from '../../models/DataSetProfile/Field'; import { Rule } from '../../models/DataSetProfile/Rule'; import { Component, Input } from '@angular/core'; import { FormGroup, FormControl, FormArray } from '@angular/forms'; import { ValidationTypes } from 'app/common/validationTypes'; @Component({ selector: 'field-form', templateUrl: './field-form.component.html', styleUrls: [] }) export class FieldFormComponent { @Input() form: FormGroup; @Input() dataModel: Field; @Input() showMultiplicity: boolean = true; @Input() indexPath: string; validationsOptions: Array; isFieldMultiplicityEnabled: boolean = false; constructon() { } ngOnInit() { if (this.form.get("multiplicity")) if (this.form.get("multiplicity").value.min > 1 || this.form.get("multiplicity").value.max > 1) this.isFieldMultiplicityEnabled = true; this.validationsOptions = [{ key: 0, value: ValidationTypes[0] }, { key: 1, value: ValidationTypes[1] }] // this.addNewRule(); } onIsFieldMultiplicityEnabledChange(isFieldMultiplicityEnabled: boolean) { if (!isFieldMultiplicityEnabled) { (this.form.get('multiplicity').get("min")).setValue(0); (this.form.get('multiplicity').get("max")).setValue(0); } } addNewRule() { let rule: Rule = new Rule(); this.dataModel.visible.rules.push(rule); (this.form.get("visible").get("rules")).push(rule.buildForm()); } DeleteRule(index) { this.dataModel.visible.rules.splice(index, 1); (this.form.get("visible").get("rules")).removeAt(index); } onchangeCombo() { debugger; } }