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';
|
2017-11-29 17:51:28 +01:00
|
|
|
import { Multiplicity } from '../models/Multiplicity';
|
2017-11-27 14:35:00 +01:00
|
|
|
import { FormArray } from '@angular/forms/src/model';
|
2017-12-04 16:02:52 +01:00
|
|
|
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(){
|
2017-11-29 17:51:28 +01:00
|
|
|
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
|
|
|
}
|
2017-11-29 17:51:28 +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-29 17:51:28 +01:00
|
|
|
}
|
2017-11-27 14:35:00 +01:00
|
|
|
|
|
|
|
}
|