mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-1880] processDefinitionId parameter in adf-start-process (#2848)
* processDefinitionId parameter in adf-start-process * fix test * fix test
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user