argos/dmp-frontend/src/app/form/dynamic-fields/field-base.ts

51 lines
1.5 KiB
TypeScript
Raw Normal View History

2017-11-27 14:40:16 +01:00
import { Rule } from '../../entities/common/rule';
import { Attribute } from '../../entities/model/attribute';
export class FieldBase<T>{
value: T;
key: string;
label: string;
required:boolean;
order:number;
rules: Rule[];
visible: boolean | string;
controlType:string;
group:string;
description:string;
attributes: Attribute;
regex:string;
url: string;
datatype: string;
constructor(options: {
value?: T,
key?: string,
label?: string,
required?:boolean,
order?: number,
rules?: Rule[],
visible?: boolean | string,
controlType?: string
group?: string
description?: string,
attributes?: Attribute,
regex?:string,
url?: string,
datatype?:string
} = {}) {
this.value = options.value;
this.key = options.key || '';
this.label = options.label || '';
this.required = !! options.required;
this.order = options.order === undefined ? 1 : options.order;
this.rules = options.rules;
this.visible = options.visible;
this.controlType = options.controlType || '';
this.group = options.group || '';
this.description = options.description || '';
this.attributes = options.attributes || new Attribute();
this.regex = options.regex || '';
this.url = options.url || "";
this.datatype = options.datatype || "";
}
}