From 3d70a51f3650acd71bf86812651f3d5374e28192 Mon Sep 17 00:00:00 2001 From: Arielk Date: Mon, 4 Feb 2019 17:22:02 +0200 Subject: Edit op crashes for existing WF Change-Id: I2901820a46d8360daa76b46600c67134c63f079a Issue-ID: SDC-2084 Signed-off-by: Arielk --- .../interface-operation.page.component.ts | 9 ++- .../operation-creator.component.ts | 64 ++++++++++------------ 2 files changed, 37 insertions(+), 36 deletions(-) (limited to 'catalog-ui/src/app/ng2') 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 70a0e958bb..b22a4bdc83 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 @@ -111,6 +111,7 @@ export class InterfaceOperationComponent { isLoading: boolean; interfaceTypes:{ [interfaceType: string]: Array }; modalTranslation: ModalTranslation; + workflows: Array; @Input() component: IComponent; @Input() readonly: boolean; @@ -132,16 +133,19 @@ export class InterfaceOperationComponent { ngOnInit(): void { this.isLoading = true; + const workflowSubscription = this.enableWorkflowAssociation ? this.WorkflowServiceNg2.getWorkflows() : Promise.resolve(); Observable.forkJoin( this.ComponentServiceNg2.getInterfaces(this.component), this.ComponentServiceNg2.getComponentInputs(this.component), - this.ComponentServiceNg2.getInterfaceTypes(this.component) + this.ComponentServiceNg2.getInterfaceTypes(this.component), + workflowSubscription ).subscribe((response: Array) => { this.isLoading = false; this.initInterfaces(response[0].interfaces); this.sortInterfaces(); this.inputs = response[1].inputs; this.interfaceTypes = response[2]; + this.workflows = response[3]; }); } @@ -239,6 +243,7 @@ export class InterfaceOperationComponent { }; const input: OperationCreatorInput = { + allWorkflows: this.workflows, inputOperation: operation, interfaces: this.interfaces, inputProperties: this.inputs, @@ -246,7 +251,7 @@ export class InterfaceOperationComponent { readonly: this.readonly, isService: this.component.isService(), interfaceTypes: this.interfaceTypes, - validityChangedCallback: this.enableOrDisableSaveButton + validityChangedCallback: this.enableOrDisableSaveButton, }; const modalConfig: IModalConfig = { diff --git a/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/operation-creator.component.ts b/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/operation-creator.component.ts index fd9e1cf5a8..329ce704c3 100644 --- a/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/operation-creator.component.ts +++ b/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/operation-creator.component.ts @@ -31,6 +31,7 @@ class TypedDropDownOption extends DropDownOption { } export interface OperationCreatorInput { + allWorkflows: Array, inputOperation: OperationModel, interfaces: Array, inputProperties: Array, @@ -38,7 +39,7 @@ export interface OperationCreatorInput { readonly: boolean, isService: boolean, interfaceTypes: { [interfaceType: string]: Array }, - validityChangedCallback: Function + validityChangedCallback: Function, } @Component({ @@ -59,6 +60,7 @@ export class OperationCreatorComponent { operationNames: Array = []; validityChangedCallback: Function; + allWorkflows: Array; workflows: Array = []; workflowVersions: Array = []; inputProperties: Array = []; @@ -132,8 +134,6 @@ export class OperationCreatorComponent { const inputOperation = this.inputOperation; this.operation = new OperationModel(inputOperation || {}); - this.onSelectInterface(new DropDownOption(this.operation.interfaceType)); - this.validityChanged(); this.operationOutputs = _.reduce( this.interfaces, @@ -147,42 +147,45 @@ export class OperationCreatorComponent { []); if (this.enableWorkflowAssociation) { - this.isLoading = true; - this.workflowServiceNg2.getWorkflows().subscribe(workflows => { - this.isLoading = false; - this.workflows = _.map( - _.filter( - workflows, - (workflow: any) => { - if (workflow.archiving === this.workflowServiceNg2.WF_STATE_ACTIVE) { - return true; - } - if (workflow.archiving === this.workflowServiceNg2.WF_STATE_ARCHIVED && - workflow.id === this.operation.workflowId) { - this.archivedWorkflowId = workflow.id; - return true; - } - return false; + this.workflows = _.map( + _.filter( + this.allWorkflows, + (workflow: any) => { + if (workflow.archiving === this.workflowServiceNg2.WF_STATE_ACTIVE) { + return true; } - ), - (workflow: any) => new DropdownValue(workflow.id, workflow.name) - ); - this.reconstructOperation(); - }); - } else { - this.reconstructOperation(); + if (workflow.archiving === this.workflowServiceNg2.WF_STATE_ARCHIVED && + workflow.id === this.operation.workflowId) { + this.archivedWorkflowId = workflow.id; + return true; + } + return false; + } + ), + (workflow: any) => new DropdownValue(workflow.id, workflow.name) + ); } + this.reconstructOperation(); + this.validityChanged(); + this.updateTable(); } reconstructOperation = () => { const inputOperation = this.inputOperation; if (inputOperation) { + this.onSelectInterface(new DropDownOption(this.operation.interfaceType)); if (this.enableWorkflowAssociation && inputOperation.workflowVersionId && this.isUsingExistingWF(inputOperation)) { + this.assignInputParameters[this.operation.workflowId] = {[inputOperation.workflowVersionId]: []}; + this.assignOutputParameters[this.operation.workflowId] = {[inputOperation.workflowVersionId]: []}; + this.inputParameters = this.assignInputParameters[this.operation.workflowId][this.operation.workflowVersionId]; + this.outputParameters = this.assignOutputParameters[this.operation.workflowId][this.operation.workflowVersionId]; const sub = this.onSelectWorkflow(new DropDownOption(inputOperation.workflowId), inputOperation.workflowVersionId); if (sub) { sub.add(() => { this.buildParams(); this.updateTable(); + this.operation.workflowVersionId = '-1'; + setTimeout(() => this.operation.workflowVersionId = this.inputOperation.workflowVersionId, 0); }); } } else { @@ -196,8 +199,6 @@ export class OperationCreatorComponent { this.isEditMode = true; } } - this.updateTable(); - this.validityChanged(); } buildParams = () => { @@ -274,7 +275,7 @@ export class OperationCreatorComponent { onSelectWorkflow(workflowId: DropDownOption, selectedVersionId?: string): Subscription { - if (_.isUndefined(workflowId) || workflowId.value === this.operation.workflowId) { + if (_.isUndefined(workflowId)) { return; } this.operation.workflowId = workflowId.value; @@ -307,11 +308,6 @@ export class OperationCreatorComponent { 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; } -- cgit 1.2.3-korg