argos/dmp-admin/src/app/models/Rule.ts

29 lines
962 B
TypeScript

import { BaseModel } from './BaseModel';
import { FormGroup } from '@angular/forms';
import { FormGenerator } from './interfaces/FormGenerator';
import { Serializable } from './interfaces/Serializable';
export class Rule extends BaseModel implements Serializable<Rule>,FormGenerator<FormGroup>{
public sourceField:string;
public targetField:string;
public requiredValue;
public type: string;
fromJSONObject(item:any):Rule{
this.sourceField = item.sourceField;
this.targetField = item.targetField;
this.requiredValue = item.requiredValue;
this.type = item.type;
return this;
}
buildForm():FormGroup{
let formGroup = this.formBuilder.group({
sourceField: [this.sourceField],
targetField: [this.targetField],
requiredValue: [this.requiredValue],
type: [this.type]
});
return formGroup;
}
}