aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/models
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-06-11 14:22:02 +0300
committerMichael Lando <ml636r@att.com>2017-06-11 17:48:32 +0300
commitb3d4898d9e8452ea0b8d848c048e712d43b8d9a3 (patch)
tree0609319203be13f6c29ccbe24cb39c9d64f90095 /catalog-ui/src/app/models
parentaf9929df75604ce407d0ca542b200630164e0ae6 (diff)
[SDC-29] rebase continue work to align source
Change-Id: I218f1c5ee23fb2c8314f1c70921d3ad8682c10f4 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-ui/src/app/models')
-rw-r--r--catalog-ui/src/app/models/components/component.ts16
-rw-r--r--catalog-ui/src/app/models/graph/graph-links/links-factory.ts27
-rw-r--r--catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts75
-rw-r--r--catalog-ui/src/app/models/properties-inputs/input-be-model.ts49
-rw-r--r--catalog-ui/src/app/models/properties-inputs/input-fe-model.ts24
-rw-r--r--catalog-ui/src/app/models/properties-inputs/property-be-model.ts25
-rw-r--r--catalog-ui/src/app/models/properties-inputs/property-fe-model.ts115
-rw-r--r--catalog-ui/src/app/models/properties-inputs/simple-flat-property.ts15
-rw-r--r--catalog-ui/src/app/models/property-fe-model.ts78
9 files changed, 193 insertions, 231 deletions
diff --git a/catalog-ui/src/app/models/components/component.ts b/catalog-ui/src/app/models/components/component.ts
index 898285f032..c7cc81fae7 100644
--- a/catalog-ui/src/app/models/components/component.ts
+++ b/catalog-ui/src/app/models/components/component.ts
@@ -205,7 +205,19 @@ export abstract class Component implements IComponent {
//------------------------------------------ API Calls ----------------------------------------------------------------//
public changeLifecycleState = (state:string, commentObj:AsdcComment):ng.IPromise<Component> => {
- return this.componentService.changeLifecycleState(this, state, JSON.stringify(commentObj));
+ let deferred = this.$q.defer();
+ let onSuccess = (componentMetadata:ComponentMetadata):void => {
+ this.setComponentMetadata(componentMetadata);
+ // this.version = componentMetadata.version;
+ this.lifecycleState = componentMetadata.lifecycleState;
+
+ deferred.resolve(this);
+ };
+ let onError = (error:any):void => {
+ deferred.reject(error);
+ };
+ this.componentService.changeLifecycleState(this, state, JSON.stringify(commentObj)).then(onSuccess, onError);
+ return deferred.promise;
};
public getComponent = ():ng.IPromise<Component> => {
@@ -892,7 +904,7 @@ export abstract class Component implements IComponent {
this.systemName = componentMetadata.systemName;
this.projectCode = componentMetadata.projectCode;
this.categories = componentMetadata.categories;
-
+
}
public toJSON = ():any => {
diff --git a/catalog-ui/src/app/models/graph/graph-links/links-factory.ts b/catalog-ui/src/app/models/graph/graph-links/links-factory.ts
index 7fdc0838ed..1744aa0ff3 100644
--- a/catalog-ui/src/app/models/graph/graph-links/links-factory.ts
+++ b/catalog-ui/src/app/models/graph/graph-links/links-factory.ts
@@ -33,19 +33,20 @@ export class LinksFactory {
let newRelation:CompositionCiLinkBase;
- let fromNode:CompositionCiNodeBase = cy.getElementById(relation.fromNode).data();
- let toNode:CompositionCiNodeBase = cy.getElementById(relation.toNode).data();
-
- if ((relation.fromNode && fromNode.isUcpePart) || (relation.toNode && toNode.isUcpePart )) { //Link from or to node inside ucpe
-
- if (singleRelation && singleRelation.relationship.type && singleRelation.relationship.type == 'tosca.relationships.HostedOn') {
- newRelation = new LinkUcpeHost(relation, singleRelation);
- } else if (singleRelation.relationship.type && _.includes(singleRelation.relationship.type.toLowerCase(), 'link')) {
- newRelation = new CompositionCiVlUcpeLink(relation, fromNode.isUcpePart, singleRelation);
- } else {
- newRelation = new CompositionCiUcpeLink(relation, fromNode.isUcpePart, singleRelation);
- }
- } else if (singleRelation.relationship.type && _.includes(singleRelation.relationship.type.toLowerCase(), 'link')) {
+ // let fromNode:CompositionCiNodeBase = cy.getElementById(relation.fromNode).data();
+ // let toNode:CompositionCiNodeBase = cy.getElementById(relation.toNode).data();
+ //
+ // if ((relation.fromNode && fromNode.isUcpePart) || (relation.toNode && toNode.isUcpePart )) { //Link from or to node inside ucpe
+ //
+ // if (singleRelation && singleRelation.relationship.type && singleRelation.relationship.type == 'tosca.relationships.HostedOn') {
+ // newRelation = new LinkUcpeHost(relation, singleRelation);
+ // } else if (singleRelation.relationship.type && _.includes(singleRelation.relationship.type.toLowerCase(), 'link')) {
+ // newRelation = new CompositionCiVlUcpeLink(relation, fromNode.isUcpePart, singleRelation);
+ // } else {
+ // newRelation = new CompositionCiUcpeLink(relation, fromNode.isUcpePart, singleRelation);
+ // }
+ // } else
+ if (singleRelation.relationship.type && _.includes(singleRelation.relationship.type.toLowerCase(), 'link')) {
newRelation = new CompositionCiVLink(relation, singleRelation);
} else {
newRelation = new CompositionCiSimpleLink(relation, singleRelation);
diff --git a/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts b/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts
index 1d79353453..f7117e456c 100644
--- a/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts
+++ b/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts
@@ -1,15 +1,11 @@
import { SchemaPropertyGroupModel, SchemaProperty } from '../aschema-property';
-import { PROPERTY_DATA, PROPERTY_TYPES} from 'app/utils';
-import { PropertyBEModel } from '../../models';
+import { DerivedPropertyType, PropertyBEModel } from '../../models';
+import { PROPERTY_TYPES } from 'app/utils';
+import { UUID } from "angular2-uuid";
-export enum DerivedPropertyType {
- SIMPLE,
- LIST,
- MAP,
- COMPLEX //other datatype, list of non-simple, or map of non-simple
-}
export class DerivedFEProperty extends PropertyBEModel {
+ valueObj: any;
parentName: string;
propertiesName: string; //"network_assignments#ipv4_subnet#use_ipv4 = parentPath + name
derivedDataType: DerivedPropertyType;
@@ -17,56 +13,39 @@ export class DerivedFEProperty extends PropertyBEModel {
isSelected: boolean;
isDisabled: boolean;
isChildOfListOrMap: boolean;
+ canBeDeclared: boolean;
+ mapKey: string;
- constructor(property: PropertyBEModel, parentName?: string)
- constructor(name: string, parentName: string, type: string, value: string, isChildOfListOrMap?:boolean, schema?: SchemaPropertyGroupModel);
- constructor(nameOrPropertyObj?: string | PropertyBEModel, parentName?: string, type?: string, value?: string, isChildOfListOrMap?: boolean, schema?: SchemaPropertyGroupModel) {
-
- super(typeof nameOrPropertyObj === 'string' ? null : nameOrPropertyObj);
-
- if (typeof nameOrPropertyObj !== 'string') { //constructor #1
+ constructor(property: PropertyBEModel, parentName?: string, createChildOfListOrMap?: boolean, key?:string, value?:any) {
+ if (!createChildOfListOrMap) { //creating a standard derived prop
+ super(property);
this.parentName = parentName ? parentName : null;
- this.propertiesName = (parentName) ? parentName + '#' + nameOrPropertyObj.name : nameOrPropertyObj.name;
- } else { //constructor #2
- this.name = nameOrPropertyObj;
- this.type = type;
+ this.propertiesName = (parentName) ? parentName + '#' + property.name : property.name;
+ this.canBeDeclared = true; //defaults to true
+ } else { //creating a direct child of list or map (ie. Item that can be deleted, with UUID instead of name)
+ super(null);
+ this.isChildOfListOrMap = true;
+ this.canBeDeclared = false;
+ this.name = UUID.UUID();
this.parentName = parentName;
- this.propertiesName = parentName + '#' + nameOrPropertyObj;
- this.value = value;
- if (schema) {
- this.schema = new SchemaPropertyGroupModel(new SchemaProperty(schema.property));
+ this.propertiesName = parentName + '#' + this.name;
+
+
+ if (property.type == PROPERTY_TYPES.LIST) {
+ this.mapKey = property.schema.property.type.split('.').pop();
+ this.type = property.schema.property.type;
+ } else { //map
+ this.mapKey = key || "";
+ this.type = property.type;
}
+ this.valueObj = (this.type == PROPERTY_TYPES.JSON && typeof value == 'object') ? JSON.stringify(value) : value;
+ this.schema = new SchemaPropertyGroupModel(new SchemaProperty(property.schema.property));
}
this.derivedDataType = this.getDerivedPropertyType();
- this.isChildOfListOrMap = (isChildOfListOrMap) ? isChildOfListOrMap : false;
}
-
- public getDerivedPropertyType = () => {
- if (PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) > -1) {
- return DerivedPropertyType.SIMPLE;
- } else if (this.type == PROPERTY_TYPES.LIST) {
- return DerivedPropertyType.LIST;
- } else if (this.type == PROPERTY_TYPES.MAP) {
- return DerivedPropertyType.MAP;
- } else {
- return DerivedPropertyType.COMPLEX;
- }
- }
}
export class DerivedFEPropertyMap {
[parentPath: string]: Array<DerivedFEProperty>;
}
-
-
-// isDataType: boolean;
-
-
-// canAdd: boolean;
-// canCollapse: boolean;
-// canBeDeclared: boolean;
-
-// derivedValue: string;
-// derivedValueType: string;
-// propertiesName: string; \ No newline at end of file
diff --git a/catalog-ui/src/app/models/properties-inputs/input-be-model.ts b/catalog-ui/src/app/models/properties-inputs/input-be-model.ts
new file mode 100644
index 0000000000..6d7854a6bf
--- /dev/null
+++ b/catalog-ui/src/app/models/properties-inputs/input-be-model.ts
@@ -0,0 +1,49 @@
+import {PropertyBEModel} from 'app/models';
+/**
+ * Created by rc2122 on 6/1/2017.
+ */
+export class InputBEModel extends PropertyBEModel {
+ properties:Array<ComponentInstanceProperty>;
+ inputs:Array<ComponentInstanceInput>;
+
+ constructor(input?: PropertyBEModel) {
+ super(input);
+ }
+
+
+
+ public toJSON = (): any => {
+ };
+
+}
+
+export class ComponentInstanceProperty extends PropertyBEModel {
+ componentInstanceId:string;
+ componentInstanceName:string;
+
+ constructor(property?: PropertyBEModel) {
+ super(property);
+ }
+
+
+
+ public toJSON = (): any => {
+ };
+
+}
+
+export class ComponentInstanceInput extends InputBEModel {
+ componentInstanceId:string;
+ componentInstanceName:string;
+
+ constructor(property?: PropertyBEModel) {
+ super(property);
+ }
+
+
+
+ public toJSON = (): any => {
+ };
+
+}
+
diff --git a/catalog-ui/src/app/models/properties-inputs/input-fe-model.ts b/catalog-ui/src/app/models/properties-inputs/input-fe-model.ts
index 1261df3d6d..03c923c228 100644
--- a/catalog-ui/src/app/models/properties-inputs/input-fe-model.ts
+++ b/catalog-ui/src/app/models/properties-inputs/input-fe-model.ts
@@ -1,25 +1,37 @@
import { SchemaPropertyGroupModel, SchemaProperty } from "../aschema-property";
import { PropertyBEModel } from "../../models";
import {PROPERTY_DATA} from "../../utils/constants";
+import {InputBEModel} from "./input-be-model";
-export class InputFEModel extends PropertyBEModel {
+export class InputFEModel extends InputBEModel {
isSimpleType: boolean;
isDataType: boolean;
instanceName: string;
+ instanceId: string;
propertyName: string;
- constructor(input?: PropertyBEModel) {
+ constructor(input?: InputBEModel) {
super(input);
if (input) {
this.isSimpleType = PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) > -1;
this.isDataType = PROPERTY_DATA.TYPES.indexOf(this.type) == -1;
+
let propNameIndex:number = this.name.indexOf('_');
this.instanceName = this.name.substring(0, propNameIndex);
- if (input.inputPath) {
- this.propertyName = input.inputPath.substring(0, input.inputPath.indexOf('#'))
- } else {
- this.propertyName = this.name.substring(propNameIndex + 1);
+
+ if(input.properties && input.properties.length){
+ this.instanceId = input.properties[0].componentInstanceId;
+ this.propertyName = input.properties[0].name;
+ }else if(input.inputs && input.inputs.length){
+ this.instanceId = input.inputs[0].componentInstanceId;
+ this.propertyName = input.inputs[0].name;
+ }else{
+ if (input.inputPath) {
+ this.propertyName = input.inputPath.substring(0, input.inputPath.indexOf('#'))
+ } else {
+ this.propertyName = this.name.substring(propNameIndex + 1);
+ }
}
}
}
diff --git a/catalog-ui/src/app/models/properties-inputs/property-be-model.ts b/catalog-ui/src/app/models/properties-inputs/property-be-model.ts
index a5279d0668..f5cd4094f5 100644
--- a/catalog-ui/src/app/models/properties-inputs/property-be-model.ts
+++ b/catalog-ui/src/app/models/properties-inputs/property-be-model.ts
@@ -1,4 +1,11 @@
import { SchemaPropertyGroupModel, SchemaProperty } from "../aschema-property";
+import { PROPERTY_DATA, PROPERTY_TYPES } from 'app/utils';
+export enum DerivedPropertyType {
+ SIMPLE,
+ LIST,
+ MAP,
+ COMPLEX
+}
export class PropertyBEModel {
@@ -16,6 +23,7 @@ export class PropertyBEModel {
definition: boolean;
inputPath: string;
propertiesName: string;
+ ownerId: string;
input: PropertyBEModel;
constructor(property?: PropertyBEModel, childProperty?:PropertyBEModel) {
@@ -32,6 +40,7 @@ export class PropertyBEModel {
this.uniqueId = property.uniqueId;
this.value = property.value ? property.value : property.defaultValue;
this.definition = property.definition;
+ this.ownerId = property.ownerId;
if (property.inputPath) {
this.inputPath = property.inputPath;
}
@@ -39,6 +48,8 @@ export class PropertyBEModel {
if (childProperty) {
this.input = childProperty;
this.propertiesName = childProperty.propertiesName;
+ } else {
+ this.propertiesName = this.name;
}
if (!this.schema || !this.schema.property) {
@@ -48,7 +59,7 @@ export class PropertyBEModel {
}
}
-
+
public toJSON = (): any => {
let temp = angular.copy(this);
@@ -57,6 +68,18 @@ export class PropertyBEModel {
return temp;
};
+ public getDerivedPropertyType = () => {
+ if (PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) > -1) {
+ return DerivedPropertyType.SIMPLE;
+ } else if (this.type == PROPERTY_TYPES.LIST) {
+ return DerivedPropertyType.LIST;
+ } else if (this.type == PROPERTY_TYPES.MAP) {
+ return DerivedPropertyType.MAP;
+ } else {
+ return DerivedPropertyType.COMPLEX;
+ }
+ }
+
}
diff --git a/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts b/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts
index 29f2c79225..564611c344 100644
--- a/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts
+++ b/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts
@@ -1,86 +1,40 @@
import {SchemaPropertyGroupModel, SchemaProperty} from '../aschema-property';
-import { PROPERTY_DATA } from 'app/utils';
-import { PropertyBEModel, DerivedFEPropertyMap, DerivedFEProperty } from '../../models';
+import { PROPERTY_DATA, PROPERTY_TYPES } from 'app/utils';
+import { FilterPropertiesAssignmentData, PropertyBEModel, DerivedPropertyType, DerivedFEPropertyMap, DerivedFEProperty } from 'app/models';
export class PropertyFEModel extends PropertyBEModel {
- //START - TO REMOVE:
- treeNodeId: string;
- parent: PropertyFEModel;
-
- childrenProperties: Array<PropertyFEModel>;
- isAllChildrenLevelsCalculated: boolean;
- uniqueId: string;
- valueObjectRef: any;
- //END - TO REMOVE:
-
expandedChildPropertyId: string;
flattenedChildren: Array<DerivedFEProperty>; //[parentPath] : Array<DerivedFEProp>
- isDataType: boolean; //aka- isComplexType. (Type is NOT: simple, list, or map)
isDeclared: boolean;
isDisabled: boolean;
isSelected: boolean;
- isSimpleType: boolean;
-
- private _derivedFromSimpleTypeName:string;
- get derivedFromSimpleTypeName():string {
- return this._derivedFromSimpleTypeName;
- }
- set derivedFromSimpleTypeName(derivedFromSimpleTypeName:string) {
- this._derivedFromSimpleTypeName = derivedFromSimpleTypeName;
- }
-
- constructor(property?: PropertyBEModel);
- constructor(name: string, type: string, treeNodeId: string, parent: PropertyFEModel, valueObjectRef: any, schema?: SchemaPropertyGroupModel);
- constructor(nameOrPropertyObj?: string | PropertyBEModel, type?: string, treeNodeId?: string, parent?: PropertyFEModel, valueObjectRef?: any, schema?: SchemaPropertyGroupModel) {
-
- super(typeof nameOrPropertyObj === 'string' ? null : nameOrPropertyObj);
-
- if (typeof nameOrPropertyObj === 'string') {
- this.name = nameOrPropertyObj;
- this.type = type;
- this.treeNodeId = treeNodeId;
- this.parent = parent;
- this.valueObjectRef = valueObjectRef;
- this.value = this.value || this.defaultValue;
- if(schema){
- this.schema = new SchemaPropertyGroupModel(new SchemaProperty(schema.property));
- }
- }
+ isSimpleType: boolean; //for convenience only - we can really just check if derivedDataType == derivedPropertyTypes.SIMPLE to know if the prop is simple
+ uniqueId: string;
+ valueObj: any; //this is the only value we relate to in the html templates
+ derivedDataType: DerivedPropertyType;
+ constructor(property: PropertyBEModel){
+ super(property);
this.isSimpleType = PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) > -1;
- this.isDataType = PROPERTY_DATA.TYPES.indexOf(this.type) == -1;
this.setNonDeclared();
+ this.derivedDataType = this.getDerivedPropertyType();
+ this.flattenedChildren = [];
}
- public convertChildToInput = (childName: string): void => {
- //childName: "mac_count_required"
- let childJson = this.flattenedChildren[childName].map((child) => {
- });
- };
-
- public getChildJsonRecursive = (child: string, value?: string): void => {
- //TODO: use array.map for the below
- /* value += "{" + this.flattenedChildren[child].name + ":";
- if (this.flattenedChildren[child].valueType == 'simple') {
- value += this.flattenedChildren[child].value + '}';
- return value;
- } else {
- this.flattenedChildren[child].forEach(grandChild => {
- if (this.flattenedChildren[grandChild].valueType == 'simple') {
- return "{" + this.flattenedChildren[grandChild].name + ':' + this.flattenedChildren[child].value.toString() + "}";
- } else {
- return this.getChildJsonRecursive(grandChild + '#' + this.flattenedChildren[child].name);
- }
- });
+ public getJSONValue = (): string => {
+ //If type is JSON, need to try parsing it before we stringify it so that it appears property in TOSCA - change per Bracha due to AMDOCS
+ //TODO: handle this.derivedDataType == DerivedPropertyType.MAP
+ if (this.derivedDataType == DerivedPropertyType.LIST && this.schema.property.type == PROPERTY_TYPES.JSON) {
+ try {
+ return JSON.stringify(this.valueObj.map(item => JSON.parse(item)));
+ } catch (e){}
}
- return "{" + this.flattenedChildren[child].name + this.flattenedChildren[child].value.toString() + "}";
-*/
-
- };
+ return (this.derivedDataType == DerivedPropertyType.SIMPLE) ? this.valueObj : JSON.stringify(this.valueObj);
+ }
public setNonDeclared = (childPath?: string): void => {
if (!childPath) { //declaring a child prop
@@ -102,31 +56,26 @@ export class PropertyFEModel extends PropertyBEModel {
}
}
-
-
- //For expand-collapse functionality
+ //For expand-collapse functionality - used within HTML template
public updateExpandedChildPropertyId = (childPropertyId: string): void => {
if (childPropertyId.lastIndexOf('#') > -1) {
this.expandedChildPropertyId = (this.expandedChildPropertyId == childPropertyId) ? (childPropertyId.substring(0, childPropertyId.lastIndexOf('#'))) : childPropertyId;
} else {
this.expandedChildPropertyId = this.name;
}
- //console.log("expandedChild is now " + this.expandedChildPropertyId);
}
- public convertToServerObject: Function = (): any => { //TODO: Idan, Rachel, Nechama: Decide what we need to do here
- // let serverObject = {};
- // let mapData = {
- // 'type': this.type,
- // 'required': this.required || false,
- // 'defaultValue': this.defaultValue != '' && this.defaultValue != '[]' && this.defaultValue != '{}' ? this.defaultValue : null,
- // 'description': this.description,
- // 'isPassword': this.password || false,
- // 'schema': this.schema,
- // 'name': this.name
- // };
- // serverObject[this.name] = mapData;
+ public getIndexOfChild = (childPropName: string): number => {
+ return this.flattenedChildren.findIndex(prop => prop.propertiesName.indexOf(childPropName) === 0);
+ }
+
+ public getCountOfChildren = (childPropName: string):number => {
+ let matchingChildren:Array<DerivedFEProperty> = this.flattenedChildren.filter(prop => prop.propertiesName.indexOf(childPropName) === 0) || [];
+ return matchingChildren.length;
+ }
+
+ // public getListIndexOfChild = (childPropName: string): number => { //gets list of siblings and then the index within that list
+ // this.flattenedChildren.filter(prop => prop.parentName == item.parentName).map(prop => prop.propertiesName).indexOf(item.propertiesName)
+ // }
- //return JSON.stringify(serverObject);
- };
}
diff --git a/catalog-ui/src/app/models/properties-inputs/simple-flat-property.ts b/catalog-ui/src/app/models/properties-inputs/simple-flat-property.ts
new file mode 100644
index 0000000000..d67a7d4d14
--- /dev/null
+++ b/catalog-ui/src/app/models/properties-inputs/simple-flat-property.ts
@@ -0,0 +1,15 @@
+export class SimpleFlatProperty {
+ uniqueId: string;
+ path: string;
+ name: string;
+ parentName: string;
+ instanceName: string;
+
+ constructor(uniqueId?: string, path?: string, name?: string, parentName?: string, instanceName?: string) {
+ this.uniqueId = uniqueId;
+ this.path = path;
+ this.name = name;
+ this.parentName = parentName;
+ this.instanceName = instanceName;
+ }
+} \ No newline at end of file
diff --git a/catalog-ui/src/app/models/property-fe-model.ts b/catalog-ui/src/app/models/property-fe-model.ts
deleted file mode 100644
index f83d6d6b51..0000000000
--- a/catalog-ui/src/app/models/property-fe-model.ts
+++ /dev/null
@@ -1,78 +0,0 @@
-import {SchemaPropertyGroupModel, SchemaProperty} from './aschema-property';
-import { PROPERTY_DATA } from 'app/utils';
-import { FilterPropertiesAssignmentData, PropertyBEModel } from 'app/models';
-
-export class PropertyFEModel extends PropertyBEModel {
- public static filterData:FilterPropertiesAssignmentData;
- childrenProperties: Array<PropertyFEModel>;
- expandedChildPropertyId: string;
- isAllChildrenLevelsCalculated: boolean;
- isDataType: boolean;
- isDisabled: boolean;
- isSelected: boolean;
- isSimpleType: boolean;
- parent: PropertyFEModel;
- treeNodeId: string;
- valueObjectRef: any;
- private _derivedFromSimpleTypeName:string;
- get derivedFromSimpleTypeName():string {
- return this._derivedFromSimpleTypeName;
- }
- set derivedFromSimpleTypeName(derivedFromSimpleTypeName:string) {
- this._derivedFromSimpleTypeName = derivedFromSimpleTypeName;
- }
-
- constructor(property?: PropertyBEModel);
- constructor(name: string, type: string, treeNodeId: string, parent: PropertyFEModel, valueObjectRef: any, schema?: SchemaPropertyGroupModel);
- constructor(nameOrPropertyObj?: string | PropertyBEModel, type?: string, treeNodeId?: string, parent?: PropertyFEModel, valueObjectRef?: any, schema?: SchemaPropertyGroupModel) {
-
- super(typeof nameOrPropertyObj === 'string' ? null : nameOrPropertyObj);
-
- if (typeof nameOrPropertyObj === 'string') {
- this.name = nameOrPropertyObj;
- this.type = type;
- this.treeNodeId = treeNodeId;
- this.parent = parent;
- this.valueObjectRef = valueObjectRef;
- this.value = this.value || this.defaultValue;
- if(schema){
- this.schema = new SchemaPropertyGroupModel(new SchemaProperty(schema.property));
- }
- }
- this.isSimpleType = PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) > -1;
- this.isDataType = PROPERTY_DATA.TYPES.indexOf(this.type) == -1;
- this.setNonDeclared();
- }
-
-
- public setNonDeclared = (): void => {
- this.isSelected = false;
- this.isDisabled = false;
- }
-
- public setAsDeclared = (): void => {
- this.isSelected = true;
- this.isDisabled = true;
- }
-
- //For expand-collapse functionality
- public updateExpandedChildPropertyId = (childPropertyId: string): void => {
- this.expandedChildPropertyId = (this.expandedChildPropertyId == childPropertyId) ? '' : childPropertyId;
- }
-
- public convertToServerObject: Function = (): any => { //TODO: Idan, Rachel, Nechama: Decide what we need to do here
- // let serverObject = {};
- // let mapData = {
- // 'type': this.type,
- // 'required': this.required || false,
- // 'defaultValue': this.defaultValue != '' && this.defaultValue != '[]' && this.defaultValue != '{}' ? this.defaultValue : null,
- // 'description': this.description,
- // 'isPassword': this.password || false,
- // 'schema': this.schema,
- // 'name': this.name
- // };
- // serverObject[this.name] = mapData;
-
- //return JSON.stringify(serverObject);
- };
-}