summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/models')
-rw-r--r--catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts1
-rw-r--r--catalog-ui/src/app/models/properties-inputs/property-fe-model.ts29
2 files changed, 30 insertions, 0 deletions
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 f7117e456c..2178319e0b 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
@@ -12,6 +12,7 @@ export class DerivedFEProperty extends PropertyBEModel {
isDeclared: boolean;
isSelected: boolean;
isDisabled: boolean;
+ hidden: boolean;
isChildOfListOrMap: boolean;
canBeDeclared: boolean;
mapKey: string;
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
+ }
+
+
}