Fixes for workflow association of operation 68/70568/1
authorArielk <Ariel.Kenan@amdocs.com>
Tue, 16 Oct 2018 13:29:14 +0000 (16:29 +0300)
committerArielk <Ariel.Kenan@amdocs.com>
Tue, 16 Oct 2018 13:29:27 +0000 (16:29 +0300)
Change-Id: Iae0bc661f986614b8223c247339aab728c14f5f7
Issue-ID: SDC-1814
Signed-off-by: Arielk <Ariel.Kenan@amdocs.com>
catalog-ui/src/app/ng2/pages/interface-operation/interface-operation.page.component.ts
catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/operation-creator.component.ts
catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/param-row/param-row.component.html

index 2dff6a8..da9cf5f 100644 (file)
@@ -102,10 +102,10 @@ export class InterfaceOperationComponent {
                 this.modalInstance.instance.dynamicContent.instance.createParamLists();
                 this.ModalServiceNg2.closeCurrentModal();
 
-                const {operation, isAssociateWorkflow} = this.modalInstance.instance.dynamicContent.instance;
+                const {operation, isUsingExistingWF} = this.modalInstance.instance.dynamicContent.instance;
                 this.openOperation = {...operation};
 
-                if (!this.enableWorkflowAssociation && !isAssociateWorkflow) {
+                if (this.enableWorkflowAssociation && !isUsingExistingWF()) {
                     operation.workflowId = null;
                     operation.workflowVersionId = null;
                 }
@@ -167,13 +167,13 @@ export class InterfaceOperationComponent {
         this.modalInstance.instance.open();
     }
 
-    private createOperation = (operation: OperationModel): any => {
+    private createOperation = (operation: OperationModel): void => {
         this.ComponentServiceNg2.createInterfaceOperation(this.component, operation).subscribe((response: CreateOperationResponse) => {
             this.openOperation = null;
             this.operationList.push(new OperationModel(response));
             this.operationList.sort((a, b) => a.operationType.localeCompare(b.operationType));
 
-            if (response.workflowId && operation.workflowAssociationType === 'EXISTING') {
+            if (response.workflowId && operation.workflowAssociationType === WORKFLOW_ASSOCIATION_OPTIONS.EXISTING) {
                 const resourceId = this.component.uuid;
                 const operationId = response.uniqueId;
                 const workflowId = response.workflowId;
@@ -186,7 +186,7 @@ export class InterfaceOperationComponent {
         });
     }
 
-    private updateOperation = (operation: OperationModel): any => {
+    private updateOperation = (operation: OperationModel): void => {
         this.ComponentServiceNg2.updateInterfaceOperation(this.component, operation).subscribe(newOperation => {
             this.openOperation = null;
             const index = _.findIndex(this.operationList, el => el.uniqueId === operation.uniqueId);
index 207bfa9..62473bd 100644 (file)
@@ -92,7 +92,9 @@ export class OperationCreatorComponent {
 
         const inputOperation = this.input.operation;
         this.operation = new OperationModel(inputOperation || {});
-        this.operation.workflowAssociationType = inputOperation ? inputOperation.workflowAssociationType : WORKFLOW_ASSOCIATION_OPTIONS.NONE;
+        if (!inputOperation) {
+            this.operation.workflowAssociationType = WORKFLOW_ASSOCIATION_OPTIONS.NONE;
+        }
 
         if (this.enableWorkflowAssociation) {
             this.isLoading = true;
@@ -118,7 +120,6 @@ export class OperationCreatorComponent {
                 this.buildParams();
                 this.updateTable();
             } else {
-                this.operation.workflowAssociationType = WORKFLOW_ASSOCIATION_OPTIONS.EXISTING;
                 this.onSelectWorkflow(inputOperation.workflowVersionId).add(() => {
                     this.buildParams();
                     this.updateTable();
@@ -172,7 +173,7 @@ export class OperationCreatorComponent {
                     versions, version => version.state === this.workflowServiceNg2.VERSION_STATE_CERTIFIED
                 ).sort((a, b) => a.name.localeCompare(b.name)),
                 (version: any) => {
-                    if (!this.assignInputParameters[this.operation.workflowId][version.id] && !selectedVersionId) {
+                    if (!this.assignInputParameters[this.operation.workflowId][version.id] && version.id !== selectedVersionId) {
                         this.assignInputParameters[this.operation.workflowId][version.id] = _.map(version.inputs, (input: OperationParameter) => {
                             return new OperationParameter({...input, type: input.type.toLowerCase()});
                         })
@@ -182,14 +183,15 @@ export class OperationCreatorComponent {
                             return new OperationParameter({...output, type: output.type.toLowerCase()});
                         })
                         .sort((a, b) => a.name.localeCompare(b.name));
-                    } else if (selectedVersionId) {
-                        this.assignInputParameters[this.operation.workflowId][version.id] = [];
-                        this.assignOutputParameters[this.operation.workflowId][version.id] = [];
                     }
                     return new DropdownValue(version.id, `V ${version.name}`);
                 }
             );
 
+            if (selectedVersionId) {
+                this.assignInputParameters[this.operation.workflowId][selectedVersionId] = [];
+                this.assignOutputParameters[this.operation.workflowId][selectedVersionId] = [];
+            }
             if (!selectedVersionId && this.workflowVersions.length) {
                 this.operation.workflowVersionId = _.last(this.workflowVersions).value;
             }
@@ -264,7 +266,7 @@ export class OperationCreatorComponent {
         this.operation.createOutputParamsList(this.outputParameters);
     }
 
-    isUsingExistingWF(): boolean {
+    isUsingExistingWF = (): boolean => {
         return this.operation.workflowAssociationType === WORKFLOW_ASSOCIATION_OPTIONS.EXISTING;
     }
 
index 29e8a35..94d2fce 100644 (file)
 
 <div class="cell field-property" *ngIf="isInputParam">
     <ui-element-dropdown
-        *ngIf="filteredInputProps.length > 0"
+        *ngIf="filteredInputProps.length > 0 || !isAssociateWorkflow"
         data-tests-id="paramProperty"
         [values]="filteredInputProps"
         [(value)]="param.property"
         [readonly]="readonly">
     </ui-element-dropdown>
     <span
-        *ngIf="filteredInputProps.length == 0"
+        *ngIf="filteredInputProps.length == 0 && isAssociateWorkflow"
         class="no-properties-error">
         No available properties of this type.
     </span>