2017-09-14 12:37:36 +02:00
|
|
|
import { Rule } from '../../entities/common/rule';
|
2017-09-22 13:38:53 +02:00
|
|
|
import { Attribute } from '../../entities/model/attribute';
|
|
|
|
|
2017-09-14 12:37:36 +02:00
|
|
|
export class FieldBase<T>{
|
|
|
|
value: T;
|
|
|
|
key: string;
|
|
|
|
label: string;
|
|
|
|
required:boolean;
|
|
|
|
order:number;
|
|
|
|
rules: Rule[];
|
|
|
|
visible: boolean;
|
|
|
|
controlType:string;
|
|
|
|
group:string;
|
2017-09-19 17:24:31 +02:00
|
|
|
description:string;
|
2017-09-22 13:38:53 +02:00
|
|
|
attributes: Attribute;
|
2017-09-14 12:37:36 +02:00
|
|
|
|
|
|
|
constructor(options: {
|
|
|
|
value?: T,
|
|
|
|
key?: string,
|
|
|
|
label?: string,
|
|
|
|
required?:boolean,
|
|
|
|
order?: number,
|
|
|
|
rules?: Rule[],
|
|
|
|
visible?: boolean,
|
|
|
|
controlType?: string
|
|
|
|
group?: string
|
2017-09-19 17:24:31 +02:00
|
|
|
description?: string,
|
2017-09-22 13:38:53 +02:00
|
|
|
attributes?: Attribute
|
2017-09-14 12:37:36 +02:00
|
|
|
} = {}) {
|
|
|
|
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 || '';
|
2017-09-19 17:24:31 +02:00
|
|
|
this.description = options.description || '';
|
2017-09-22 13:38:53 +02:00
|
|
|
this.attributes = options.attributes || new Attribute();
|
2017-09-14 12:37:36 +02:00
|
|
|
}
|
|
|
|
}
|