[ADF-1880] processDefinitionId parameter in adf-start-process (#2848)

* processDefinitionId parameter in adf-start-process

* fix test

* fix test
This commit is contained in:
Eugenio Romano
2018-01-19 11:04:03 +00:00
committed by GitHub
parent e883f5c83d
commit 807d7e0f78
5 changed files with 142 additions and 44 deletions

View File

@@ -49,6 +49,9 @@ export class StartProcessInstanceComponent implements OnChanges {
@Input()
appId: number;
@Input()
processDefinitionId: string;
@Input()
variables: ProcessInstanceVariable[];
@@ -89,22 +92,41 @@ export class StartProcessInstanceComponent implements OnChanges {
this.moveNodeFromCStoPS();
}
let appIdChange = changes['appId'];
let appId = appIdChange ? appIdChange.currentValue : null;
this.load(appId);
if (changes['appId'] && changes['appId'].currentValue) {
this.appId = changes['appId'].currentValue;
}
this.loadStartProcess();
}
public load(appId?: number) {
public loadStartProcess() {
this.resetSelectedProcessDefinition();
this.resetErrorMessage();
this.activitiProcess.getProcessDefinitions(appId).subscribe(
(res) => {
this.processDefinitions = res;
},
() => {
this.errorMessageId = 'ADF_PROCESS_LIST.START_PROCESS.ERROR.LOAD_PROCESS_DEFS';
}
);
if (this.appId) {
this.activitiProcess.getProcessDefinitions(this.appId).subscribe(
(processDefinitionRepresentations: ProcessDefinitionRepresentation[]) => {
this.processDefinitions = processDefinitionRepresentations;
if (this.processDefinitions.length === 1) {
this.currentProcessDef = JSON.parse(JSON.stringify(this.processDefinitions[0]));
} else {
if (this.processDefinitionId) {
this.processDefinitions = this.processDefinitions.filter((currentProcessDefinition) => {
return currentProcessDefinition.id === this.processDefinitionId;
});
this.currentProcessDef = JSON.parse(JSON.stringify(this.processDefinitions[0]));
}
}
},
() => {
this.errorMessageId = 'ADF_PROCESS_LIST.START_PROCESS.ERROR.LOAD_PROCESS_DEFS';
});
}
}
public hasMultipleProcessDefinitions(): boolean {
return this.processDefinitions.length > 1;
}
getAlfrescoRepositoryName(): string {