From 3d5b80b9035b9832f86326858b4c6c2cecd952a3 Mon Sep 17 00:00:00 2001 From: Arielk Date: Mon, 13 May 2019 15:30:27 +0300 Subject: operation artifact optional and fixes Change-Id: Ibce96d60248b26716ed518747444836b437f209f Issue-ID: SDC-2249 Signed-off-by: Arielk --- .../interface-operation.page.component.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'catalog-ui/src/app/ng2/pages/interface-operation/interface-operation.page.component.ts') diff --git a/catalog-ui/src/app/ng2/pages/interface-operation/interface-operation.page.component.ts b/catalog-ui/src/app/ng2/pages/interface-operation/interface-operation.page.component.ts index 7c0f23291b..9db24b6071 100644 --- a/catalog-ui/src/app/ng2/pages/interface-operation/interface-operation.page.component.ts +++ b/catalog-ui/src/app/ng2/pages/interface-operation/interface-operation.page.component.ts @@ -315,10 +315,12 @@ export class InterfaceOperationComponent { private createOperation = (operation: OperationModel): void => { this.ComponentServiceNg2.createInterfaceOperation(this.component, operation).subscribe((response: OperationModel) => { this.openOperation = null; + let curInterf = _.find( this.interfaces, interf => interf.type === operation.interfaceType ); + if (!curInterf) { curInterf = new UIInterfaceModel({ type: response.interfaceType, @@ -327,11 +329,13 @@ export class InterfaceOperationComponent { }); this.interfaces.push(curInterf); } - curInterf.operations.push(new UIOperationModel(response)); + + const newOpModel = new UIOperationModel(response); + curInterf.operations.push(newOpModel); this.sortInterfaces(); - if (operation.workflowAssociationType === WORKFLOW_ASSOCIATION_OPTIONS.EXTERNAL) { - this.ComponentServiceNg2.uploadInterfaceOperationArtifact(this.component, response, operation).subscribe(); + if (operation.workflowAssociationType === WORKFLOW_ASSOCIATION_OPTIONS.EXTERNAL && operation.artifactData) { + this.ComponentServiceNg2.uploadInterfaceOperationArtifact(this.component, newOpModel, operation).subscribe(); } else if (response.workflowId && operation.workflowAssociationType === WORKFLOW_ASSOCIATION_OPTIONS.EXISTING) { this.WorkflowServiceNg2.associateWorkflowArtifact(this.component, response).subscribe(); } else if (operation.workflowAssociationType === WORKFLOW_ASSOCIATION_OPTIONS.NEW) { @@ -341,7 +345,7 @@ export class InterfaceOperationComponent { } private updateOperation = (operation: OperationModel): void => { - this.ComponentServiceNg2.updateInterfaceOperation(this.component, operation).subscribe(newOperation => { + this.ComponentServiceNg2.updateInterfaceOperation(this.component, operation).subscribe((newOperation: OperationModel) => { this.openOperation = null; let oldOpIndex, oldInterf; @@ -356,11 +360,12 @@ export class InterfaceOperationComponent { oldInterf.operations.splice(oldOpIndex, 1); const newInterf = _.find(this.interfaces, interf => interf.type === operation.interfaceType); - newInterf.operations.push(new UIOperationModel(newOperation)); + const newOpModel = new UIOperationModel(newOperation); + newInterf.operations.push(newOpModel); this.sortInterfaces(); - if (operation.workflowAssociationType === WORKFLOW_ASSOCIATION_OPTIONS.EXTERNAL) { - this.ComponentServiceNg2.uploadInterfaceOperationArtifact(this.component, newOperation, operation).subscribe(); + if (operation.workflowAssociationType === WORKFLOW_ASSOCIATION_OPTIONS.EXTERNAL && operation.artifactData) { + this.ComponentServiceNg2.uploadInterfaceOperationArtifact(this.component, newOpModel, operation).subscribe(); } else if (newOperation.workflowId && operation.workflowAssociationType === WORKFLOW_ASSOCIATION_OPTIONS.EXISTING) { this.WorkflowServiceNg2.associateWorkflowArtifact(this.component, newOperation).subscribe(); } -- cgit 1.2.3-korg