` | Emitted when the start process operation fails |
-### Start a process part of an app
+### Start a process with a default name and pre-selected process definition name
```html
+ [name]="PROCESS_NAME"
+ [processDefinitionName]="PROCESS_DEFINITION_NAME">
```
-Use this method to preselect which process to start if there is more than one process in your app.
+If your app has more than one process definition, with the property processDefinitionName you can select as dropdown default value your PROCESS_DEFINITION_NAME. The name will be the PROCESS_NAME.
+You can configure the processDefinitionName value in your custom `app.config.json`
+You can configure the process name value in your custom `app.config.json`
### Start a process not included in an app
```html
+ [processDefinitionName]="PROCESS_DEFINITION_NAME">
```
-Use this method to preselect which process to start
+With the property processDefinitionName you can select as dropdown default value your PROCESS_DEFINITION_NAME.
+You can configure the processDefinitionName values in your custom `app.config.json`
### Custom data example
diff --git a/lib/process-services/process-list/components/start-process.component.html b/lib/process-services/process-list/components/start-process.component.html
index 98ebbd7843..8d8952a0c1 100644
--- a/lib/process-services/process-list/components/start-process.component.html
+++ b/lib/process-services/process-list/components/start-process.component.html
@@ -12,7 +12,7 @@
- {{'ADF_PROCESS_LIST.START_PROCESS.FORM.TYPE_PLACEHOLDER' | translate}}
+ {{'ADF_PROCESS_LIST.START_PROCESS.FORM.TYPE_PLACEHOLDER' | translate}}
{{ processDef.name }}
diff --git a/lib/process-services/process-list/components/start-process.component.spec.ts b/lib/process-services/process-list/components/start-process.component.spec.ts
index 2dd0c70f58..ce8b1b9dda 100644
--- a/lib/process-services/process-list/components/start-process.component.spec.ts
+++ b/lib/process-services/process-list/components/start-process.component.spec.ts
@@ -274,7 +274,7 @@ describe('StartFormComponent', () => {
it('should select processDefinition based on processDefinition input', async(() => {
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(Observable.of(testMultipleProcessDefs));
component.appId = 123;
- component.processDefinition = 'My Process 2';
+ component.processDefinitionName = 'My Process 2';
component.ngOnChanges({});
fixture.detectChanges();
fixture.whenStable().then(() => {
@@ -292,16 +292,6 @@ describe('StartFormComponent', () => {
});
}));
- it('should select automatically the first processDefinition if the app contain multiple process and there is no processDefinition in input', async(() => {
- getDefinitionsSpy = getDefinitionsSpy.and.returnValue(Observable.of(testMultipleProcessDefs));
- component.appId = 123;
- component.ngOnChanges({});
- fixture.detectChanges();
- fixture.whenStable().then(() => {
- expect(component.selectedProcessDef.name).toBe(JSON.parse(JSON.stringify(testMultipleProcessDefs[0])).name);
- });
- }));
-
describe('dropdown', () => {
it('should hide the process dropdown if showSelectProcessDropdown is false', async(() => {
@@ -319,7 +309,7 @@ describe('StartFormComponent', () => {
it('should show the process dropdown if showSelectProcessDropdown is false', async(() => {
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(Observable.of(testMultipleProcessDefs));
component.appId = 123;
- component.processDefinition = 'My Process 2';
+ component.processDefinitionName = 'My Process 2';
component.showSelectProcessDropdown = true;
component.ngOnChanges({});
fixture.detectChanges();
@@ -332,7 +322,7 @@ describe('StartFormComponent', () => {
it('should show the process dropdown by default', async(() => {
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(Observable.of(testMultipleProcessDefs));
component.appId = 123;
- component.processDefinition = 'My Process 2';
+ component.processDefinitionName = 'My Process 2';
component.ngOnChanges({});
fixture.detectChanges();
fixture.whenStable().then(() => {
@@ -454,14 +444,18 @@ describe('StartFormComponent', () => {
});
}));
- it('should emit start event when start select a process and add a name', () => {
+ it('should emit start event when start select a process and add a name', async(() => {
let startSpy: jasmine.Spy = spyOn(component.start, 'emit');
- component.selectedProcessDef.id = '1001';
+ component.selectedProcessDef = testProcessDefRepr;
component.name = 'my:Process';
component.startProcess();
fixture.detectChanges();
- expect(startSpy).toHaveBeenCalled();
- });
+ fixture.whenStable().then(() => {
+ let startButton = fixture.nativeElement.querySelector('#button-start');
+ startButton.click();
+ expect(startSpy).toHaveBeenCalled();
+ });
+ }));
it('should not emit start event when start the process without select a process and name', () => {
component.name = null;
diff --git a/lib/process-services/process-list/components/start-process.component.ts b/lib/process-services/process-list/components/start-process.component.ts
index 86312cae2f..d08fda65ea 100644
--- a/lib/process-services/process-list/components/start-process.component.ts
+++ b/lib/process-services/process-list/components/start-process.component.ts
@@ -50,7 +50,7 @@ export class StartProcessInstanceComponent implements OnChanges {
appId: number;
@Input()
- processDefinition: string;
+ processDefinitionName: string;
@Input()
variables: ProcessInstanceVariable[];
@@ -106,16 +106,12 @@ export class StartProcessInstanceComponent implements OnChanges {
(processDefinitionRepresentations: ProcessDefinitionRepresentation[]) => {
this.processDefinitions = processDefinitionRepresentations;
- if (this.processDefinitions.length === 1 || !this.processDefinition) {
+ if (this.hasSingleProcessDefinition()) {
this.selectedProcessDef = this.processDefinitions[0];
} else {
this.selectedProcessDef = this.processDefinitions.find((currentProcessDefinition) => {
- return currentProcessDefinition.name === this.processDefinition;
+ return currentProcessDefinition.name === this.processDefinitionName;
});
-
- if (!this.selectedProcessDef) {
- this.selectedProcessDef = this.processDefinitions[0];
- }
}
},
() => {
@@ -124,6 +120,10 @@ export class StartProcessInstanceComponent implements OnChanges {
}
+ hasSingleProcessDefinition(): boolean {
+ return this.processDefinitions.length === 1;
+ }
+
getAlfrescoRepositoryName(): string {
let alfrescoRepositoryName = this.appConfig.get('alfrescoRepositoryName');
if (!alfrescoRepositoryName) {