diff options
Diffstat (limited to 'catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts')
-rw-r--r-- | catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts index c3babc1e03..767acb41a7 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts @@ -96,6 +96,8 @@ export class PropertiesAssignmentComponent { selectedInstanceData: ComponentInstance | GroupInstance | PolicyInstance = null; checkedPropertiesCount: number = 0; checkedChildPropertiesCount: number = 0; + enableToscaFunction: boolean = false; + checkedToscaCount: number = 0; hierarchyPropertiesDisplayOptions: HierarchyDisplayOptions = new HierarchyDisplayOptions('path', 'name', 'childrens'); hierarchyInstancesDisplayOptions: HierarchyDisplayOptions = new HierarchyDisplayOptions('uniqueId', 'name', 'archived', null, 'iconClass'); @@ -578,16 +580,23 @@ export class PropertiesAssignmentComponent { private clearCheckedInstancePropertyValue() { const checkedInstanceProperty: PropertyBEModel = this.buildCheckedInstanceProperty(); + let currentValue = checkedInstanceProperty.value; checkedInstanceProperty.getInputValues = null; checkedInstanceProperty.value = null; checkedInstanceProperty.toscaFunction = null; if (checkedInstanceProperty instanceof PropertyDeclareAPIModel && (<PropertyDeclareAPIModel>checkedInstanceProperty).propertiesName){ const propertiesNameArray = (<PropertyDeclareAPIModel>checkedInstanceProperty).propertiesName; const parts = propertiesNameArray.split("#"); + const currentKey = checkedInstanceProperty.type === PROPERTY_TYPES.MAP ? (<DerivedFEProperty>checkedInstanceProperty.input).mapKey : null; if (propertiesNameArray.length > 1){ - const index = checkedInstanceProperty.subPropertyToscaFunctions.findIndex(existingSubPropertyToscaFunction => this.areEqual(existingSubPropertyToscaFunction.subPropertyPath, parts.slice(1))); + const index = checkedInstanceProperty.subPropertyToscaFunctions.findIndex(existingSubPropertyToscaFunction => this.areEqual(existingSubPropertyToscaFunction.subPropertyPath, currentKey != null ? [currentKey] : parts.slice(1))); checkedInstanceProperty.subPropertyToscaFunctions.splice(index, 1); } + if(currentValue !== null && currentKey !== null){ + let valueJson = JSON.parse(currentValue); + delete valueJson[currentKey]; + checkedInstanceProperty.value = JSON.stringify(valueJson); + } } if (this.selectedInstanceData instanceof ComponentInstance) { this.updateInstanceProperty(checkedInstanceProperty); @@ -603,18 +612,18 @@ export class PropertiesAssignmentComponent { if (checkedProperty instanceof PropertyDeclareAPIModel && (<PropertyDeclareAPIModel>checkedProperty).propertiesName){ const propertiesName = (<PropertyDeclareAPIModel>checkedProperty).propertiesName; const parts = propertiesName.split("#"); - + const currentKey = checkedProperty.type === PROPERTY_TYPES.MAP ? (<DerivedFEProperty>checkedProperty.input).mapKey : null; if (checkedProperty.subPropertyToscaFunctions == null){ checkedProperty.subPropertyToscaFunctions = []; } - let subPropertyToscaFunction = checkedProperty.subPropertyToscaFunctions.find(existingSubPropertyToscaFunction => this.areEqual(existingSubPropertyToscaFunction.subPropertyPath, parts.slice(1))); + let subPropertyToscaFunction = checkedProperty.subPropertyToscaFunctions.find(existingSubPropertyToscaFunction => this.areEqual(existingSubPropertyToscaFunction.subPropertyPath, currentKey != null ? [currentKey] : parts.slice(1))); if (!subPropertyToscaFunction){ subPropertyToscaFunction = new SubPropertyToscaFunction(); checkedProperty.subPropertyToscaFunctions.push(subPropertyToscaFunction); } subPropertyToscaFunction.toscaFunction = toscaFunction; - subPropertyToscaFunction.subPropertyPath = parts.slice(1); - + subPropertyToscaFunction.subPropertyPath = currentKey != null ? [currentKey] : parts.slice(1); + } else { checkedProperty.subPropertyToscaFunctions = null; checkedProperty.toscaFunction = toscaFunction; @@ -634,6 +643,8 @@ export class PropertiesAssignmentComponent { updateInstanceProperty(instanceProperty: PropertyBEModel) { this.loadingProperties = true; + this.enableToscaFunction = false; + this.checkedToscaCount = 0; this.componentInstanceServiceNg2.updateInstanceProperties(this.component.componentType, this.component.uniqueId, this.selectedInstanceData.uniqueId, [instanceProperty]) .subscribe(() => { @@ -1154,6 +1165,15 @@ export class PropertiesAssignmentComponent { this.checkedChildPropertiesCount += (increment) ? 1 : -1; }; + togggleToscaBtn = (toscaFlag: boolean) : void => { + this.checkedToscaCount += toscaFlag ? 1 : -1; + if(this.checkedToscaCount == 1){ + this.enableToscaFunction = true; + }else{ + this.enableToscaFunction = false; + } + }; + setInputTabIndication = (numInputs: number): void => { this.propertyInputTabs.setTabIndication('Inputs', numInputs); }; |