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-17 22:40:44 +0300
committerMichael Lando <ml636r@att.com>2017-06-18 07:20:49 +0300
commit4d97d5fac309ce0d66938e5ccd0349e2660d4e23 (patch)
tree3f921054f997d1962fa6f9db9a0119e31a851eea /catalog-ui/src/app/models/properties-inputs/property-fe-model.ts
parent89786d31f266a205857cae0177904c249ac6a512 (diff)
[sdc] update code of sdc
Change-Id: If9f37c80b659cb67b34d18e6c019defecca58b9a 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.ts29
1 files changed, 29 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
index 564611c344..cfbe6d64c7 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
@@ -78,4 +78,33 @@ export class PropertyFEModel extends PropertyBEModel {
// this.flattenedChildren.filter(prop => prop.parentName == item.parentName).map(prop => prop.propertiesName).indexOf(item.propertiesName)
// }
+ /* Updates parent valueObj when a child prop's value has changed */
+ public childPropUpdated = (childProp: DerivedFEProperty): void => {
+ let parentNames = this.getParentNamesArray(childProp.propertiesName, []);
+ if (parentNames.length) {
+ _.set(this.valueObj, parentNames.join('.'), childProp.valueObj);
+ }
+ };
+
+ /* Returns array of individual parents for given prop path, with list/map UUIDs replaced with index/mapkey */
+ private getParentNamesArray = (parentPropName: string, parentNames?: Array<string>): Array<string> => {
+ if (parentPropName.indexOf("#") == -1) { return parentNames; } //finished recursing parents. return
+
+ let parentProp: DerivedFEProperty = this.flattenedChildren.find(prop => prop.propertiesName === parentPropName);
+ let nameToInsert: string = parentProp.name;
+
+ if (parentProp.isChildOfListOrMap) {
+ if (parentProp.derivedDataType == DerivedPropertyType.MAP) {
+ nameToInsert = parentProp.mapKey;
+ } else { //LIST
+ let siblingProps = this.flattenedChildren.filter(prop => prop.parentName == parentProp.parentName).map(prop => prop.propertiesName);
+ nameToInsert = siblingProps.indexOf(parentProp.propertiesName).toString();
+ }
+ }
+
+ parentNames.splice(0, 0, nameToInsert); //add prop name to array
+ return this.getParentNamesArray(parentProp.parentName, parentNames); //continue recursing
+ }
+
+
}