summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-06-09 03:19:04 +0300
committerMichael Lando <ml636r@att.com>2017-06-09 03:19:04 +0300
commited64b5edff15e702493df21aa3230b81593e6133 (patch)
treea4cb01fdaccc34930a8db403a3097c0d1e40914b /catalog-ui/src/app/models/properties-inputs/property-fe-model.ts
parent280f8015d06af1f41a3ef12e8300801c7a5e0d54 (diff)
[SDC-29] catalog 1707 rebase commit.
Change-Id: I43c3dc5cf44abf5da817649bc738938a3e8388c1 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-ui/src/app/models/properties-inputs/property-fe-model.ts')
-rw-r--r--catalog-ui/src/app/models/properties-inputs/property-fe-model.ts132
1 files changed, 132 insertions, 0 deletions
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
new file mode 100644
index 0000000000..29f2c79225
--- /dev/null
+++ b/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts
@@ -0,0 +1,132 @@
+import {SchemaPropertyGroupModel, SchemaProperty} from '../aschema-property';
+import { PROPERTY_DATA } from 'app/utils';
+import { PropertyBEModel, DerivedFEPropertyMap, DerivedFEProperty } from '../../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));
+ }
+ }
+
+ this.isSimpleType = PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) > -1;
+ this.isDataType = PROPERTY_DATA.TYPES.indexOf(this.type) == -1;
+ this.setNonDeclared();
+ }
+
+ 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);
+ }
+ });
+ }
+
+ return "{" + this.flattenedChildren[child].name + this.flattenedChildren[child].value.toString() + "}";
+*/
+
+ };
+
+ public setNonDeclared = (childPath?: string): void => {
+ if (!childPath) { //declaring a child prop
+ this.isDeclared = false;
+ } else {
+ let childProp: DerivedFEProperty = this.flattenedChildren.find(child => child.propertiesName == childPath);
+ childProp.isDeclared = false;
+ }
+ }
+
+ public setAsDeclared = (childNameToDeclare?:string): void => {
+ if (!childNameToDeclare) { //declaring a child prop
+ this.isSelected = false;
+ this.isDeclared = true;
+ } else {
+ let childProp: DerivedFEProperty = this.flattenedChildren.find(child => child.propertiesName == childNameToDeclare);
+ childProp.isSelected = false;
+ childProp.isDeclared = true;
+ }
+ }
+
+
+
+ //For expand-collapse functionality
+ 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;
+
+ //return JSON.stringify(serverObject);
+ };
+}