From: k.kedron Date: Mon, 2 Mar 2020 12:51:08 +0000 (+0100) Subject: Fix update the policy in SDC UI X-Git-Tag: 1.6.3~10 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=9b0f5789fade52e551917018c5fb82b6e5ee7845;p=sdc.git Fix update the policy in SDC UI Refresh the property.value which is sent to the backend to properly update the policy property. Issue-ID: SDC-2797 Signed-off-by: Krystian Kedron Change-Id: If87c7acb5324cf933e9c8a4ebd5616a11d8b4c71 --- diff --git a/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts b/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts index cc382a3df0..af6ed9d4b0 100644 --- a/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts +++ b/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts @@ -93,7 +93,7 @@ export class ComponentInstanceServiceNg2 { .map((res) => { return res.map((resProperty) => { let newProp = new PropertyModel(resProperty); - newProp.resourceInstanceUniqueId = componentInstanceId + newProp.resourceInstanceUniqueId = componentInstanceId; return newProp; }); }); diff --git a/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts index 37b1ce75a8..3d1ac3d591 100644 --- a/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts +++ b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts @@ -272,12 +272,17 @@ export class PropertyFormViewModel { }; //Not clean, but doing this as a temporary fix until we update the property right panel modals - if(this.propertyOwnerType == "group"){ + if (this.propertyOwnerType === "group"){ this.ComponentInstanceServiceNg2.updateComponentGroupInstanceProperties(this.workspaceService.metadata.componentType, this.workspaceService.metadata.uniqueId, this.propertyOwnerId, [property]) - .subscribe((propertiesFromBE) => { onPropertySuccess(propertiesFromBE[0])}, error => onPropertyFaild); - } else if(this.propertyOwnerType == "policy"){ + .subscribe((propertiesFromBE) => { onPropertySuccess(propertiesFromBE[0])}, error => onPropertyFaild(error)); + } else if (this.propertyOwnerType === "policy"){ + if (!this.$scope.editPropertyModel.property.simpleType && + !this.$scope.isSimpleType(this.$scope.editPropertyModel.property.type) && + !_.isNil(this.$scope.myValue)) { + property.value = JSON.stringify(this.$scope.myValue); + } this.ComponentInstanceServiceNg2.updateComponentPolicyInstanceProperties(this.workspaceService.metadata.componentType, this.workspaceService.metadata.uniqueId, this.propertyOwnerId, [property]) - .subscribe((propertiesFromBE) => { onPropertySuccess(propertiesFromBE[0])}, error => onPropertyFaild); + .subscribe((propertiesFromBE) => { onPropertySuccess(propertiesFromBE[0])}, error => onPropertyFaild(error)); } else { //in case we have uniqueId we call update method if (this.$scope.isPropertyValueOwner) {