36 lines
913 B
TypeScript
36 lines
913 B
TypeScript
import { Component, Input } from '@angular/core';
|
|
import { FormGroup } from '@angular/forms';
|
|
import { Field } from '../models/Field';
|
|
import { Rule } from '../models/Rule';
|
|
import { Multiplicity } from '../models/Multiplicity';
|
|
import { FormArray } from '@angular/forms/src/model';
|
|
import {ComboboxComponent} from '../combobox/combobox-component';
|
|
|
|
@Component({
|
|
selector: 'field-form',
|
|
templateUrl: './field-form.component.html',
|
|
styleUrls: []
|
|
})
|
|
|
|
export class FieldFormComponent {
|
|
@Input() form: FormGroup;
|
|
@Input() dataModel: Field;
|
|
|
|
constructor(){}
|
|
|
|
ngOnInit(){
|
|
// this.addNewRule();
|
|
}
|
|
|
|
addNewRule(){
|
|
let rule: Rule = new Rule();
|
|
this.dataModel.visible.rules.push(rule);
|
|
(<FormArray>this.form.get("visible").get("rules")).push(rule.buildForm());
|
|
}
|
|
|
|
DeleteRule(index){
|
|
this.dataModel.visible.rules.splice(index, 1);
|
|
(<FormArray>this.form.get("visible").get("rules")).removeAt(index);
|
|
}
|
|
|
|
} |