fixing input and output action

Issue-ID: CCSDK-2779
Issue-ID: CCSDK-3025

Signed-off-by: Eltanany Shaaban <shaaban.eltanany.ext@orange.com>
Change-Id: Ie9a89b5312a173925d44b9868d796775912304a8
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.html
index 178f8f0..3b946de 100644
--- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.html
+++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.html
@@ -57,9 +57,9 @@
                                         type="button" aria-hidden="true"></i>
                                 </label>
                                 <div class="attributeOptions">
-                                    <a data-toggle="modal" data-target="#exampleModalScrollable2"
+                                    <!--<a data-toggle="modal" data-target="#exampleModalScrollable2"
                                         class="accordion-delete editAttribute" tooltip="Edit Attribute"
-                                        placement="bottom" (click)="editAttribute(input)"><i class="icon-edit"></i></a>
+                                        placement="bottom" (click)="editAttribute(input)"><i class="icon-edit"></i></a>-->
                                     <a class="accordion-delete deleteAttribute" tooltip="Delete Attribute"
                                         (click)="markDeletedInput(input)" data-toggle="modal"
                                         data-target="#exampleModalScrollable1" placement="bottom"><i
@@ -702,4 +702,4 @@
             </div>
         </div>
     </div>
-</div>
\ No newline at end of file
+</div>
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.ts
index 6873f89..f339650 100644
--- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.ts
+++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.ts
@@ -120,7 +120,7 @@
         console.log(input);
         if (input && input.type && input.name) {
             const insertedInputActionAttribute = Object.assign({}, input);
-            if (!this.newInputs.includes(insertedInputActionAttribute)) {
+            if (!this.newInputs.some(obj => obj.name === input.name)) {
                 this.newInputs.push(insertedInputActionAttribute);
             }
         }
@@ -178,6 +178,8 @@
                 this.outputs.push(output);
             }
         });
+        this.newInputs = [];
+        this.newOutputs = [];
     }
 
     private getValue() {
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.ts
index 1784346..0c1d0cf 100644
--- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.ts
+++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.ts
@@ -1,8 +1,10 @@
-import {Component, OnInit} from '@angular/core';
+import {Component, OnDestroy, OnInit} from '@angular/core';
 import {PackageCreationService} from '../package-creation.service';
 import {MetaDataTabModel} from '../mapping-models/metadata/MetaDataTab.model';
 import {PackageCreationStore} from '../package-creation.store';
 import {ActivatedRoute} from '@angular/router';
+import {Subject} from 'rxjs';
+import {distinctUntilChanged, takeUntil} from 'rxjs/operators';
 
 
 @Component({
@@ -10,7 +12,7 @@
     templateUrl: './metadata-tab.component.html',
     styleUrls: ['./metadata-tab.component.css']
 })
-export class MetadataTabComponent implements OnInit {
+export class MetadataTabComponent implements OnInit , OnDestroy {
 
     counter = 0;
     tags = new Set<string>();
@@ -24,7 +26,7 @@
     errorMessage: string;
     versionPattern = '^(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)$';
     isNameEditable = false;
-
+    ngUnsubscribe = new Subject();
     constructor(
         private route: ActivatedRoute,
         private packageCreationService: PackageCreationService,
@@ -38,7 +40,11 @@
         this.metaDataTab.mapOfCustomKey = this.customKeysMap;
         this.metaDataTab.mode = this.modeType;
         this.isNameEditable = this.route.snapshot.paramMap.get('id') == null;
-        this.packageCreationStore.state$.subscribe(element => {
+        this.packageCreationStore.state$
+            .pipe(
+                distinctUntilChanged((a: any, b: any) => JSON.stringify(a) === JSON.stringify(b)),
+                takeUntil(this.ngUnsubscribe))
+            .subscribe(element => {
 
             if (element && element.metaData) {
 
@@ -133,5 +139,10 @@
         this.packageCreationStore.changeMetaData(newMetaData);
     }
 
+    ngOnDestroy() {
 
+        this.ngUnsubscribe.next();
+        this.ngUnsubscribe.complete();
+        this.ngUnsubscribe.unsubscribe();
+    }
 }