aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/components
diff options
context:
space:
mode:
authorimamSidero <imam.hussain@est.tech>2023-03-23 11:25:23 +0000
committerImam hussain <imam.hussain@est.tech>2023-04-03 11:13:18 +0000
commit7565f810f9fa50c8140843b2f81e8fb428815154 (patch)
tree5ff3ef43bd7434db7c0bd462db295a2726052c61 /catalog-ui/src/app/ng2/components
parent3dff1c221e58de6a81cf6bbdfb84fdf97665e484 (diff)
Provide tosca function capability to all nested levels
Tosca function capability is provided to all nested levels of list, map and custom types Issue-ID: SDC-4445 Signed-off-by: Imam hussain <imam.hussain@est.tech> Change-Id: I29907bdac83d3cadf90aa0a2ed538002132b4789
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.html4
-rw-r--r--catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts76
2 files changed, 48 insertions, 32 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 956bb05356..038f5f5317 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
@@ -25,7 +25,7 @@
<div class="inner-cell-div" tooltip="{{property.name}}"><span>{{property.name}}</span></div>
</div>
<div class="table-cell" *ngIf="!canBeDeclared && !property.isChildOfListOrMap">
- <checkbox *ngIf="nestedLevel == 2" [(checked)]="property.isSelected" [disabled]="property.isDisabled || readonly || property.mapKey == '' || checkboxDisabled" (checkedChange)="toggleTosca.emit(property)" ></checkbox>
+ <checkbox *ngIf="nestedLevel >= 2" [(checked)]="property.isSelected" [disabled]="property.isDisabled || readonly || checkboxDisabled" (checkedChange)="toggleTosca.emit(property)" ></checkbox>
<div class="inner-cell-div" tooltip="{{property.name}}"><span>{{property.name}}</span></div>
</div> <!-- simple children of complex type within map or list -->
<div class="table-cell map-entry" *ngIf="property.isChildOfListOrMap && propType == derivedPropertyTypes.MAP && !property.mapInlist"><!-- map left cell -->
@@ -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 || nestedLevel == 2) && property.isChildOfListOrMap && property.schema.property.isSimpleType)" [(checked)]="property.isSelected" [disabled]="property.isDisabled || readonly || property.mapKey == '' || checkboxDisabled" (checkedChange)="toggleTosca.emit(property)" ></checkbox>
+ <checkbox class="{{propType == derivedPropertyTypes.MAP ? 'inline-checkBox' : 'inline-checkBox-List'}}" *ngIf="(property.isChildOfListOrMap && property.schema.property.isSimpleType)" [(checked)]="property.isSelected" [disabled]="property.isDisabled || readonly || property.mapKey == '' || checkboxDisabled" (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 e53cf01848..7be44c3075 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
@@ -160,26 +160,12 @@ 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.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);
+ let newProps: Array<DerivedFEProperty> = this.propertiesUtils.createListOrMapChildren(this.property, '', null);
this.propertiesUtils.assignFlattenedChildrenValues(this.property.valueObj, [newProps[0]], this.property.propertiesName);
if (this.property instanceof PropertyFEModel) {
@@ -257,21 +243,45 @@ export class DynamicPropertyComponent {
return;
}
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 deletedIndex = item.toscaPath.length > 0 ? Number(item.toscaPath[item.toscaPath.length - 1]) : null;
+ let parentIndex = item.toscaPath.length > 1 ? item.toscaPath.splice(0,item.toscaPath.length - 2) : null;
let tempSubToscaFunction: SubPropertyToscaFunction[] = [];
+ let toscaPathMap = new Map();
this.property.subPropertyToscaFunctions.forEach((subToscaItem : SubPropertyToscaFunction) => {
- if(subToscaItem.subPropertyPath[keyIndex] != oldKey){
+ if ((subToscaItem.subPropertyPath.toString()).indexOf(item.toscaPath.toString()) == -1) {
tempSubToscaFunction.push(subToscaItem);
+ } else {
+ if (item.derivedDataType == DerivedPropertyType.LIST ) {
+ if (parentIndex != null) {
+ if ((subToscaItem.subPropertyPath.toString()).indexOf(parentIndex.toString()) != -1
+ && subToscaItem.subPropertyPath.length > parentIndex.length) {
+ let nextIndex = Number(subToscaItem.subPropertyPath[parentIndex.length]);
+ if(!isNaN(nextIndex) && !isNaN(deletedIndex) && nextIndex > deletedIndex) {
+ let revisedPAth = subToscaItem.subPropertyPath;
+ revisedPAth[parentIndex.length] = (nextIndex - 1).toString();
+ toscaPathMap.set(subToscaItem.subPropertyPath.toString(),revisedPAth.toString());
+ }
+ }
+ } else {
+ if (subToscaItem.subPropertyPath.length == 1 && !isNaN(deletedIndex)) {
+ let nextElementIndex = Number(subToscaItem.subPropertyPath[0]);
+ if (!isNaN(nextElementIndex) && nextElementIndex > deletedIndex) {
+ subToscaItem.subPropertyPath[0] = (nextElementIndex - 1).toString();
+ }
+ }
+ }
+ }
}
});
this.property.subPropertyToscaFunctions = tempSubToscaFunction;
+ if (item.derivedDataType == DerivedPropertyType.LIST && parentIndex != null && toscaPathMap.size > 0) {
+ this.property.flattenedChildren.forEach((childProperties : DerivedFEProperty) => {
+ if (toscaPathMap.has(childProperties.toscaPath.toString())) {
+ childProperties.toscaPath = toscaPathMap.get(childProperties.toscaPath.toString());
+ }
+ });
+ }
}
if (item.derivedDataType == DerivedPropertyType.MAP && !item.mapInlist) {
delete itemParent.valueObj[oldKey];
@@ -299,16 +309,13 @@ export class DynamicPropertyComponent {
updateChildKeyInParent(childProp: DerivedFEProperty, newMapKey: string) {
if (this.property instanceof PropertyFEModel) {
let oldKey = childProp.getActualMapKey();
+ let oldToscaPath = childProp.toscaPath;
this.property.childPropMapKeyUpdated(childProp, newMapKey);
- this.property.flattenedChildren.forEach(tempDervObj => {
- if (childProp.propertiesName === tempDervObj.parentName) {
- tempDervObj.mapKey = newMapKey;
- }
- });
+ this.updateChildMapKey(this.property.flattenedChildren, childProp.propertiesName, newMapKey);
if (this.property.subPropertyToscaFunctions != null) {
this.property.subPropertyToscaFunctions.forEach((item : SubPropertyToscaFunction) => {
- if(item.subPropertyPath[0] === oldKey){
- item.subPropertyPath = [newMapKey];
+ if(item.subPropertyPath === oldToscaPath){
+ item.subPropertyPath = childProp.toscaPath;
}
});
}
@@ -316,6 +323,15 @@ export class DynamicPropertyComponent {
}
}
+ updateChildMapKey(childProps: Array<DerivedFEProperty>, parentName: string, newMapKey: string) {
+ childProps.forEach(tempDervObj => {
+ if (parentName === tempDervObj.parentName) {
+ tempDervObj.mapKey = newMapKey;
+ tempDervObj.toscaPath[tempDervObj.toscaPath.length - 2] = newMapKey;
+ }
+ });
+ }
+
preventInsertItem = (property:DerivedFEProperty):boolean => {
if(property.type == PROPERTY_TYPES.MAP && property.valueObj != null && Object.keys(property.valueObj).indexOf('') > -1 ){
return true;