2017-12-20 17:46:52 +01:00
|
|
|
|
import { BaseModel } from '../BaseModel';
|
2017-11-27 14:35:00 +01:00
|
|
|
|
import { FormGroup } from '@angular/forms';
|
2017-12-20 17:46:52 +01:00
|
|
|
|
import { FormGenerator } from '../interfaces/FormGenerator';
|
|
|
|
|
import { Serializable } from '../interfaces/Serializable';
|
2017-11-27 14:35:00 +01:00
|
|
|
|
export class Rule extends BaseModel implements Serializable<Rule>,FormGenerator<FormGroup>{
|
|
|
|
|
public sourceField:string;
|
2017-12-01 15:00:37 +01:00
|
|
|
|
public target:string;
|
|
|
|
|
public value: string;
|
|
|
|
|
public ruleType: string;
|
|
|
|
|
public ruleStyle: string;
|
|
|
|
|
public valueType: string;
|
2017-11-27 14:35:00 +01:00
|
|
|
|
|
|
|
|
|
fromJSONObject(item:any):Rule{
|
|
|
|
|
this.sourceField = item.sourceField;
|
2017-12-01 15:00:37 +01:00
|
|
|
|
this.target = item.target;
|
|
|
|
|
this.value = item.value;
|
|
|
|
|
this.ruleType = item.ruleType;
|
|
|
|
|
this.ruleStyle = item.ruleStyle;
|
|
|
|
|
this.valueType = item.valueType;
|
2017-11-27 14:35:00 +01:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buildForm():FormGroup{
|
|
|
|
|
let formGroup = this.formBuilder.group({
|
|
|
|
|
sourceField: [this.sourceField],
|
2017-12-01 15:00:37 +01:00
|
|
|
|
target: [this.target],
|
|
|
|
|
ruleStyle: [this.ruleStyle],
|
|
|
|
|
value: [this.value],
|
|
|
|
|
ruleType: [this.ruleType],
|
|
|
|
|
valueType: [this.valueType]
|
2017-11-27 14:35:00 +01:00
|
|
|
|
});
|
|
|
|
|
return formGroup;
|
|
|
|
|
}
|
|
|
|
|
}
|