Fix Property with '::' in name produces wrong Input 34/133634/2
authorKrupaNagabhushan <krupa.nagabhushan@est.tech>
Mon, 13 Mar 2023 18:12:43 +0000 (18:12 +0000)
committerMichael Morris <michael.morris@est.tech>
Mon, 13 Mar 2023 19:26:30 +0000 (19:26 +0000)
Issue-ID: SDC-4431
Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech>
Change-Id: Ieaf9b99493511145c2d6a3d5ec31bdf0e36cd8b2

catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html
catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts

index 36d316e..1d8a01d 100644 (file)
@@ -83,7 +83,7 @@
                         [disabled]="(checkedPropertiesCount != 1 || isReadonly || hasChangedData) && !enableToscaFunction"
                         class="tlv-btn blue declare-button"
                         data-tests-id="declare-button select-tosca-function">{{'TOSCA_FUNCTION_LABEL' | translate}}</button>
-                <button class="tlv-btn blue declare-button" [disabled]="!checkedPropertiesCount || isReadonly || hasChangedData" (click)="openAddInputNameAndDeclareInputModal()" data-tests-id="declare-button declare-input">Declare Input</button>
+                <button class="tlv-btn blue declare-button" [disabled]="!checkedPropertiesCount || isReadonly || hasChangedData" (click)="declareInput()" data-tests-id="declare-button declare-input">Declare Input</button>
                 <button class="tlv-btn blue declare-button" [disabled]="!checkedPropertiesCount || isReadonly || hasChangedData || isSelf()" (click)="declarePropertiesToPolicies()" data-tests-id="declare-button declare-policy">Declare Policy</button>
                 <button class="tlv-btn blue declare-button" [disabled]="!checkedPropertiesCount || checkedChildPropertiesCount || isReadonly || hasChangedData" (click)="declareListProperties()" data-tests-id="declare-but($event)ton declare-list-input">Create List Input</button>
             </div>
index ada12ad..17bb1a6 100644 (file)
@@ -739,8 +739,16 @@ export class PropertiesAssignmentComponent {
         });
     }
 
+    declareInput = (): void => {
+        if (this.checkedPropertiesCount == 1) {
+            this.openAddInputNameAndDeclareInputModal();
+        } else if (this.checkedPropertiesCount > 1) {
+            this.declareInputFromProperties();
+        }
+    }
+
     /*** DECLARE PROPERTIES/INPUTS ***/
-    declareInputFromProperties = (inputName:string): void => {
+    declareInputFromProperties = (inputName?: string): void => {
         console.debug("==>" + this.constructor.name + ": declareProperties");
 
         let selectedComponentInstancesProperties: InstanceBePropertiesMap = new InstanceBePropertiesMap();
@@ -831,7 +839,7 @@ export class PropertiesAssignmentComponent {
         let inputName: string;
         if (propertyName) {
             if (propertyName.includes("::")) {
-                propertyName = propertyName.replace("::", "_");
+                propertyName = propertyName.replace(/::/g, "_");
             }
             if (componentName) {
                 inputName = componentName + "_" + propertyName;