isLoading: boolean;
interfaceTypes:{ [interfaceType: string]: Array<string> };
modalTranslation: ModalTranslation;
+ workflows: Array<any>;
@Input() component: IComponent;
@Input() readonly: boolean;
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<any>) => {
this.isLoading = false;
this.initInterfaces(response[0].interfaces);
this.sortInterfaces();
this.inputs = response[1].inputs;
this.interfaceTypes = response[2];
+ this.workflows = response[3];
});
}
};
const input: OperationCreatorInput = {
+ allWorkflows: this.workflows,
inputOperation: operation,
interfaces: this.interfaces,
inputProperties: this.inputs,
readonly: this.readonly,
isService: this.component.isService(),
interfaceTypes: this.interfaceTypes,
- validityChangedCallback: this.enableOrDisableSaveButton
+ validityChangedCallback: this.enableOrDisableSaveButton,
};
const modalConfig: IModalConfig = {
}
export interface OperationCreatorInput {
+ allWorkflows: Array<any>,
inputOperation: OperationModel,
interfaces: Array<InterfaceModel>,
inputProperties: Array<InputBEModel>,
readonly: boolean,
isService: boolean,
interfaceTypes: { [interfaceType: string]: Array<string> },
- validityChangedCallback: Function
+ validityChangedCallback: Function,
}
@Component({
operationNames: Array<TypedDropDownOption> = [];
validityChangedCallback: Function;
+ allWorkflows: Array<any>;
workflows: Array<DropdownValue> = [];
workflowVersions: Array<DropdownValue> = [];
inputProperties: Array<InputBEModel> = [];
const inputOperation = this.inputOperation;
this.operation = new OperationModel(inputOperation || {});
- this.onSelectInterface(new DropDownOption(this.operation.interfaceType));
- this.validityChanged();
this.operationOutputs = _.reduce(
this.interfaces,
[]);
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 {
this.isEditMode = true;
}
}
- this.updateTable();
- this.validityChanged();
}
buildParams = () => {
onSelectWorkflow(workflowId: DropDownOption, selectedVersionId?: string): Subscription {
- if (_.isUndefined(workflowId) || workflowId.value === this.operation.workflowId) {
+ if (_.isUndefined(workflowId)) {
return;
}
this.operation.workflowId = workflowId.value;
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;
}