aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/components
diff options
context:
space:
mode:
authorimamSidero <imam.hussain@est.tech>2023-02-08 14:40:35 +0000
committerMichael Morris <michael.morris@est.tech>2023-02-16 09:30:47 +0000
commit2c30bf8b461108e687d874acad3b444fc732ef4c (patch)
treec829bbff40a176edb9b5afac82e256738bc8ba9a /catalog-ui/src/app/ng2/components
parent59148be1a5a9beea5a157ace746eea3c969f5ed4 (diff)
Provide tosca function to list of map values
Providing the capability to add tosca function for list of map values Issue-ID: SDC-4379 Signed-off-by: Imam hussain <imam.hussain@est.tech> Change-Id: Iec404ec27431eb2b5e085d3f9474e61fadab8d45
Diffstat (limited to 'catalog-ui/src/app/ng2/components')
-rw-r--r--catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html2
-rw-r--r--catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts52
2 files changed, 38 insertions, 16 deletions
diff --git a/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html b/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html
index a5c2b60ee3..e19986416f 100644
--- a/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html
+++ b/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html
@@ -44,7 +44,7 @@
<!-- RIGHT CELL OR FULL WIDTH CELL-->
<ng-container *ngIf="propType == derivedPropertyTypes.SIMPLE || property.isDeclared || (property.isToscaFunction() && !property.isChildOfListOrMap) || (property.isChildOfListOrMap && propType == derivedPropertyTypes.MAP && property.schema.property.isSimpleType)">
<div class="table-cell">
- <checkbox class="{{propType == derivedPropertyTypes.MAP ? 'inline-checkBox' : 'inline-checkBox-List'}}" *ngIf="(nestedLevel == 1 && property.isChildOfListOrMap && property.schema.property.isSimpleType)" [(checked)]="property.isSelected" [disabled]="property.isDisabled || readonly || property.mapKey == ''" (checkedChange)="toggleTosca.emit(property)" ></checkbox>
+ <checkbox class="{{propType == derivedPropertyTypes.MAP ? 'inline-checkBox' : 'inline-checkBox-List'}}" *ngIf="((nestedLevel == 1 || nestedLevel == 2) && property.isChildOfListOrMap && property.schema.property.isSimpleType)" [(checked)]="property.isSelected" [disabled]="property.isDisabled || readonly || property.mapKey == ''" (checkedChange)="toggleTosca.emit(property)" ></checkbox>
<dynamic-element class="value-input"
pattern="validationUtils.getValidationPattern(property.type)"
[value]="(property.isDeclared || property.isToscaFunction()) ? property.value : property.valueObj"
diff --git a/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts b/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts
index 548c676285..c5e9c43176 100644
--- a/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts
+++ b/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts
@@ -154,21 +154,24 @@ export class DynamicPropertyComponent {
createNewChildProperty = (): void => {
let mapKeyValue = this.property instanceof DerivedFEProperty ? this.property.mapKey : "";
+ let parentToscaFunction = null;
if (this.property.type == PROPERTY_TYPES.LIST && mapKeyValue === "") {
- if (this.property.schemaType != PROPERTY_TYPES.MAP) {
- if (this.property.value != null) {
- const valueJson = JSON.parse(this.property.value);
- if (this.property instanceof PropertyFEModel && this.property.expandedChildPropertyId != null) {
- let indexNumber = Number(Object.keys(valueJson).sort().reverse()[0]) + 1;
- mapKeyValue = indexNumber.toString();
- }else{
- mapKeyValue = Object.keys(valueJson).sort().reverse()[0];
- }
- }else {
- mapKeyValue = "0";
+ if (this.property.value != null) {
+ const valueJson = JSON.parse(this.property.value);
+ if (this.property instanceof PropertyFEModel && this.property.expandedChildPropertyId != null) {
+ let indexNumber = Number(Object.keys(valueJson).sort().reverse()[0]) + 1;
+ mapKeyValue = indexNumber.toString();
+ }else{
+ mapKeyValue = Object.keys(valueJson).sort().reverse()[0];
}
+ }else {
+ mapKeyValue = "0";
}
}
+ if (this.property.type == PROPERTY_TYPES.MAP && this.property instanceof DerivedFEProperty && this.property.mapInlist) {
+ parentToscaFunction = this.property.toscaFunction;
+ this.property.toscaFunction = null;
+ }
let newProps: Array<DerivedFEProperty> = this.propertiesUtils.createListOrMapChildren(this.property, mapKeyValue, null);
this.propertiesUtils.assignFlattenedChildrenValues(this.property.valueObj, [newProps[0]], this.property.propertiesName);
@@ -177,6 +180,7 @@ export class DynamicPropertyComponent {
} else {
this.addChildPropsToParent.emit(newProps);
}
+ this.property.toscaFunction = parentToscaFunction;
}
addChildProps = (newProps: Array<DerivedFEProperty>, childPropName: string) => {
@@ -221,9 +225,20 @@ export class DynamicPropertyComponent {
deleteListOrMapItem = (item: DerivedFEProperty) => {
if (this.property instanceof PropertyFEModel) {
+ const childMapKey = item.mapKey;
this.removeValueFromParent(item);
this.property.flattenedChildren.splice(this.property.getIndexOfChild(item.propertiesName), this.property.getCountOfChildren(item.propertiesName));
this.expandChildById(item.propertiesName);
+ if (this.property.type == PROPERTY_TYPES.LIST && this.property.schemaType == PROPERTY_TYPES.MAP && childMapKey != null) {
+ let valueObject = JSON.parse(this.property.value);
+ let innerObject = valueObject[item.parentMapKey];
+ delete innerObject[childMapKey];
+ this.property.valueObj = valueObject;
+ this.property.value = JSON.stringify(valueObject);
+ this.property.flattenedChildren[0].valueObj = valueObject;
+ this.property.flattenedChildren[0].value = JSON.stringify(valueObject);
+ this.property.flattenedChildren[0].valueObjIsChanged = true;
+ }
}
}
@@ -234,12 +249,19 @@ export class DynamicPropertyComponent {
if (!itemParent) {
return;
}
- const oldKey = item.getActualMapKey();
+ let oldKey = item.getActualMapKey();
+ let keyIndex : number = 0;
+ if(item.parentMapKey != null && oldKey != null) {
+ keyIndex = 1;
+ }
+ if(item.parentMapKey != null && oldKey == null) {
+ oldKey = item.parentMapKey;
+ }
if (this.property.subPropertyToscaFunctions !== null) {
let tempSubToscaFunction: SubPropertyToscaFunction[] = [];
- this.property.subPropertyToscaFunctions.forEach((item : SubPropertyToscaFunction, index) => {
- if(item.subPropertyPath[0] != oldKey){
- tempSubToscaFunction.push(item);
+ this.property.subPropertyToscaFunctions.forEach((subToscaItem : SubPropertyToscaFunction) => {
+ if(subToscaItem.subPropertyPath[keyIndex] != oldKey){
+ tempSubToscaFunction.push(subToscaItem);
}
});
this.property.subPropertyToscaFunctions = tempSubToscaFunction;