From 6c682e71e580cf051e7ab30ed7a89b03ca46277b Mon Sep 17 00:00:00 2001
From: aribeiro <anderson.ribeiro@est.tech>
Date: Tue, 30 Nov 2021 08:43:42 +0000
Subject: Fix generated tosca and Required fields validation

Fix Incorrect properties entry on the interface operation implementation
definition and Required fields validation.

Issue-ID: SDC-3796
Signed-off-by: aribeiro <anderson.ribeiro@est.tech>
Change-Id: Ib6624fb884181612b2d94970d3cca28af839151d
---
 .../interface-operation-handler.component.ts            | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

(limited to 'catalog-ui/src/app/ng2/pages')

diff --git a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts
index 0b0efde1bf..6e4ae45487 100644
--- a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts
@@ -67,6 +67,7 @@ export class InterfaceOperationHandlerComponent {
     toscaArtifactTypes: Array<DropdownValue> = [];
 
     enableAddArtifactImplementation: boolean;
+    propertyValueValid: boolean = true;
 
     ngOnInit() {
         this.interfaceType = this.input.selectedInterface.displayType();
@@ -166,7 +167,9 @@ export class InterfaceOperationHandlerComponent {
 
     propertyValueValidation = (propertyValue): void => {
         this.onPropertyValueChange(propertyValue);
-        this.readonly = !propertyValue.isValid;
+        this.propertyValueValid = propertyValue.isValid;
+        this.readonly = !this.propertyValueValid;
+        this.validateRequiredField();
     }
 
     onRemoveInput = (inputParam: InputOperationParameter): void => {
@@ -221,15 +224,19 @@ export class InterfaceOperationHandlerComponent {
 
     validateRequiredField = () => {
         this.readonly = true;
-        let requiredFieldSelected = this.toscaArtifactTypeSelected && this.artifactName ? true : false;
-        this.input.validityChangedCallback(requiredFieldSelected);
-        if (requiredFieldSelected) {
+        const isRequiredFieldSelected = this.isRequiredFieldsSelected();
+        this.input.validityChangedCallback(isRequiredFieldSelected);
+        if (isRequiredFieldSelected && this.propertyValueValid) {
             this.readonly = false;
         }
     }
 
+    private isRequiredFieldsSelected() {
+        return this.toscaArtifactTypeSelected && this.artifactName;
+    }
+
     private checkFormValidForSubmit = (): boolean => {
-        return this.operationToUpdate.name && this.isParamsValid();
+        return this.operationToUpdate.name && this.artifactName && this.isParamsValid();
     }
 
     private isParamsValid = (): boolean => {
-- 
cgit 1.2.3-korg