1 import {SchemaPropertyGroupModel, SchemaProperty} from './aschema-property';
2 import { PROPERTY_DATA } from 'app/utils';
3 import { FilterPropertiesAssignmentData, PropertyBEModel } from 'app/models';
5 export class PropertyFEModel extends PropertyBEModel {
6 public static filterData:FilterPropertiesAssignmentData;
7 childrenProperties: Array<PropertyFEModel>;
8 expandedChildPropertyId: string;
9 isAllChildrenLevelsCalculated: boolean;
13 isSimpleType: boolean;
14 parent: PropertyFEModel;
17 private _derivedFromSimpleTypeName:string;
18 get derivedFromSimpleTypeName():string {
19 return this._derivedFromSimpleTypeName;
21 set derivedFromSimpleTypeName(derivedFromSimpleTypeName:string) {
22 this._derivedFromSimpleTypeName = derivedFromSimpleTypeName;
25 constructor(property?: PropertyBEModel);
26 constructor(name: string, type: string, treeNodeId: string, parent: PropertyFEModel, valueObjectRef: any, schema?: SchemaPropertyGroupModel);
27 constructor(nameOrPropertyObj?: string | PropertyBEModel, type?: string, treeNodeId?: string, parent?: PropertyFEModel, valueObjectRef?: any, schema?: SchemaPropertyGroupModel) {
29 super(typeof nameOrPropertyObj === 'string' ? null : nameOrPropertyObj);
31 if (typeof nameOrPropertyObj === 'string') {
32 this.name = nameOrPropertyObj;
34 this.treeNodeId = treeNodeId;
36 this.valueObjectRef = valueObjectRef;
37 this.value = this.value || this.defaultValue;
39 this.schema = new SchemaPropertyGroupModel(new SchemaProperty(schema.property));
42 this.isSimpleType = PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) > -1;
43 this.isDataType = PROPERTY_DATA.TYPES.indexOf(this.type) == -1;
44 this.setNonDeclared();
48 public setNonDeclared = (): void => {
49 this.isSelected = false;
50 this.isDisabled = false;
53 public setAsDeclared = (): void => {
54 this.isSelected = true;
55 this.isDisabled = true;
58 //For expand-collapse functionality
59 public updateExpandedChildPropertyId = (childPropertyId: string): void => {
60 this.expandedChildPropertyId = (this.expandedChildPropertyId == childPropertyId) ? '' : childPropertyId;
63 public convertToServerObject: Function = (): any => { //TODO: Idan, Rachel, Nechama: Decide what we need to do here
64 // let serverObject = {};
67 // 'required': this.required || false,
68 // 'defaultValue': this.defaultValue != '' && this.defaultValue != '[]' && this.defaultValue != '{}' ? this.defaultValue : null,
69 // 'description': this.description,
70 // 'isPassword': this.password || false,
71 // 'schema': this.schema,
74 // serverObject[this.name] = mapData;
76 //return JSON.stringify(serverObject);