Fix unchecked artifact implementation being persisted 15/127815/2
authorandre.schmid <andre.schmid@est.tech>
Tue, 15 Mar 2022 16:06:34 +0000 (16:06 +0000)
committerMichael Morris <michael.morris@est.tech>
Mon, 21 Mar 2022 11:55:23 +0000 (11:55 +0000)
Fixes the problem of an interface operation artifact implementation
being persisted even if it is not selected.
After checking that the interface operation has an artifact
implementation and filling up the artifact information, the values
were being persisted if the option is unchecked afterwards.
There was no way to remove the artifact implementation information
once it was persisted for the first time.

Change-Id: I4fdf4027919fdc04d688805bcf0b37fa6869b2e8
Issue-ID: SDC-3918
Signed-off-by: andre.schmid <andre.schmid@est.tech>
catalog-ui/src/app/ng2/pages/composition/interface-operatons/interface-operations.component.ts

index b14d0dd..17f697e 100644 (file)
@@ -238,15 +238,23 @@ export class InterfaceOperationsComponent {
 
   private updateInterfaceOperation() {
     this.isLoading = true;
-    const operationUpdated: InterfaceOperationModel = this.modalInstance.instance.dynamicContent.instance.operationToUpdate;
+    const interfaceOperationHandlerComponentInstance: InterfaceOperationHandlerComponent = this.modalInstance.instance.dynamicContent.instance;
+    const operationUpdated: InterfaceOperationModel = interfaceOperationHandlerComponentInstance.operationToUpdate;
+    const isArtifactChecked = interfaceOperationHandlerComponentInstance.enableAddArtifactImplementation;
+    if (!isArtifactChecked) {
+      let artifactName = interfaceOperationHandlerComponentInstance.artifactName;
+      artifactName = artifactName === undefined ? '' : artifactName;
+      operationUpdated.implementation = new ArtifactModel({'artifactName': artifactName} as ArtifactModel);
+    }
     this.topologyTemplateService.updateComponentInstanceInterfaceOperation(
         this.componentMetaData.uniqueId,
         this.componentMetaData.componentType,
         this.componentInstanceSelected.uniqueId,
-        operationUpdated).subscribe((updatedComponentInstance: ComponentInstance) => {
-          this.componentInstanceSelected = new ComponentInstance(updatedComponentInstance);
-          this.initComponentInstanceInterfaceOperations();
-    });
+        operationUpdated)
+        .subscribe((updatedComponentInstance: ComponentInstance) => {
+            this.componentInstanceSelected = new ComponentInstance(updatedComponentInstance);
+            this.initComponentInstanceInterfaceOperations();
+        });
     this.modalServiceNg2.closeCurrentModal();
     this.isLoading = false;
   }