argos/dmp-admin/src/app/field-form/field-form.component.ts

37 lines
937 B
TypeScript
Raw Normal View History

2017-11-27 14:35:00 +01:00
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';
2017-11-27 14:35:00 +01:00
import { FormArray } from '@angular/forms/src/model';
import {ComboboxComponent} from '../combobox/combobox-component';
2017-11-27 14:35:00 +01:00
@Component({
selector: 'field-form',
templateUrl: './field-form.component.html',
styleUrls: []
})
export class FieldFormComponent {
@Input() form: FormGroup;
@Input() dataModel: Field;
constructon(){}
ngOnInit(){
console.log("init field")
// this.addNewRule();
2017-11-27 14:35:00 +01:00
}
addNewRule(){
let rule: Rule = new Rule();
2017-12-01 15:00:37 +01:00
this.dataModel.visible.rules.push(rule);
(<FormArray>this.form.get("visible").get("rules")).push(rule.buildForm());
2017-11-27 14:35:00 +01:00
}
DeleteRule(index){
2017-12-01 15:00:37 +01:00
this.dataModel.visible.rules.splice(index);
(<FormArray>this.form.get("visible").get("rules")).removeAt(index);
}
2017-11-27 14:35:00 +01:00
}