summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authork.kedron <k.kedron@partner.samsung.com>2020-03-03 10:59:51 +0100
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-03-24 09:21:24 +0000
commit97930ffc459281aa11c8e3fb1ffacafdc3d161be (patch)
tree4d140b901360940f740a60fdd0b1b746a88cbe14
parent91ac6b9f294828bec7e8e9200f5dabaf64f2a4f3 (diff)
Fixed updating VFC
Added checking that newProperty.path isn't null. Also added refreshing the returned property from the backend. Issue-ID: SDC-2800 Signed-off-by: Krystian Kedron <k.kedron@partner.samsung.com> Change-Id: I82449d04f3151b5233cd99fb919b47f6d05a83fa
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java13
-rw-r--r--catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts25
2 files changed, 22 insertions, 16 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index 51eb22d527..93e31e2ea2 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -1697,15 +1697,18 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
Optional<CapabilityDefinition>
capPropDefinition = getPropertyCapabilityOfChildInstance(propertyParentUniqueId, foundResourceInstance.getCapabilities());
- if(capPropDefinition.isPresent()) {
+ if (capPropDefinition.isPresent()) {
updatedPropertyValue
.bimap(updatedValue -> updateCapabilityPropFromUpdateInstProp(property, updatedValue,
containerComponent, foundResourceInstance, capPropDefinition.get().getType(),
capPropDefinition.get().getName()), Either::right);
- }
- else {
- updatedPropertyValue.bimap(updatedValue -> updatePropertyOnContainerComponent(property, updatedValue,
- containerComponent, foundResourceInstance), Either::right);
+ } else {
+ updatedPropertyValue.bimap(
+ updatedValue -> {
+ componentInstanceProperty.setValue(updatedValue);
+ return updatePropertyOnContainerComponent(property, updatedValue,
+ containerComponent, foundResourceInstance);
+ }, Either::right);
updatedProperties.add(componentInstanceProperty);
}
}
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 3d1ac3d591..609997ca19 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
@@ -290,7 +290,8 @@ export class PropertyFormViewModel {
let myValueString:string = JSON.stringify(this.$scope.myValue);
property.value = myValueString;
}
- this.updateInstanceProperties(property.resourceInstanceUniqueId, [property]).subscribe((propertiesFromBE) => onPropertySuccess(propertiesFromBE[0]), onPropertyFaild);
+ this.updateInstanceProperties(property.resourceInstanceUniqueId, [property]).subscribe((propertiesFromBE) => onPropertySuccess(propertiesFromBE[0]),
+ error => onPropertyFaild(error));
} else {
if (!this.$scope.editPropertyModel.property.simpleType && !this.$scope.isSimpleType(property.type)) {
let myValueString:string = JSON.stringify(this.$scope.myValue);
@@ -298,7 +299,7 @@ export class PropertyFormViewModel {
} else {
this.$scope.editPropertyModel.property.defaultValue = this.$scope.editPropertyModel.property.value;
}
- this.addOrUpdateProperty(property).subscribe(onPropertySuccess, onPropertyFaild);
+ this.addOrUpdateProperty(property).subscribe(onPropertySuccess, error => onPropertyFaild(error));
}
}
};
@@ -387,21 +388,23 @@ export class PropertyFormViewModel {
const okButton = {testId: "OK", text: "OK", type: SdcUiCommon.ButtonType.info, callback: onOk, closeModal: true} as SdcUiComponents.ModalButtonComponent;
this.modalService.openInfoModal(title, message, 'delete-modal', [okButton]);
};
- }
+ };
private updateInstanceProperties = (componentInstanceId:string, properties:PropertyModel[]):Observable<PropertyModel[]> => {
return this.ComponentInstanceServiceNg2.updateInstanceProperties(this.workspaceService.metadata.componentType, this.workspaceService.metadata.uniqueId, componentInstanceId, properties)
.map(newProperties => {
newProperties.forEach((newProperty) => {
- if(newProperty.path[0] === newProperty.resourceInstanceUniqueId) newProperty.path.shift();
- // find exist instance property in parent component for update the new value ( find bu uniqueId & path)
- let existProperty: PropertyModel = <PropertyModel>_.find(this.compositionService.componentInstancesProperties[newProperty.resourceInstanceUniqueId], {
- uniqueId: newProperty.uniqueId,
- path: newProperty.path
- });
- let index = this.compositionService.componentInstancesProperties[newProperty.resourceInstanceUniqueId].indexOf(existProperty);
- this.compositionService.componentInstancesProperties[newProperty.resourceInstanceUniqueId][index] = newProperty;
+ if (!_.isNil(newProperty.path)) {
+ if (newProperty.path[0] === newProperty.resourceInstanceUniqueId) newProperty.path.shift();
+ // find exist instance property in parent component for update the new value ( find bu uniqueId & path)
+ let existProperty: PropertyModel = <PropertyModel>_.find(this.compositionService.componentInstancesProperties[newProperty.resourceInstanceUniqueId], {
+ uniqueId: newProperty.uniqueId,
+ path: newProperty.path
+ });
+ let index = this.compositionService.componentInstancesProperties[newProperty.resourceInstanceUniqueId].indexOf(existProperty);
+ this.compositionService.componentInstancesProperties[newProperty.resourceInstanceUniqueId][index] = newProperty;
+ }
});
return newProperties;
});