diff --git a/docs/start-process.component.md b/docs/start-process.component.md index 806d4db9c4..6d4b0983de 100644 --- a/docs/start-process.component.md +++ b/docs/start-process.component.md @@ -1,6 +1,6 @@ # Start Process component -Displays Start Process, allowing the user to specify some basic details needed to start a new process instance. +Displays Start Process, allowing the user to specify some details like process name and process definition, which are the most basic requirement to start a new process instance. The user have to select the process definition from a dropdown if there are more than one process definition available. If there is just one process definition available for the app, then it is auto-selected. There is a error message shown if no process definition is available. ![adf-start-process ](docassets/images/startProcess.png) 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 3203e9aa1d..ff0385b3df 100644 --- a/lib/process-services/process-list/components/start-process.component.html +++ b/lib/process-services/process-list/components/start-process.component.html @@ -9,7 +9,7 @@ - + {{'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 3e5c6fa833..5c259f41a6 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 @@ -154,6 +154,18 @@ describe('StartProcessInstanceComponent', () => { }); })); + it('should auto-select process def from dropdown if there is just one process def', () => { + let change = new SimpleChange(null, '123', true); + component.ngOnChanges({'appId': change}); + component.processDefinitions[0] = testProcessDefRepr; + fixture.detectChanges(); + fixture.whenStable().then(() => { + let selectElement = fixture.nativeElement.querySelector('mat-select > .mat-select-trigger'); + expect(selectElement).not.toBeNull(); + expect(selectElement).toBeDefined(); + expect(selectElement.innerText).toBe('My Process 1'); + }); + }); }); describe('input changes', () => { @@ -321,35 +333,39 @@ describe('StartProcessInstanceComponent', () => { let change = new SimpleChange(null, '123', true); component.ngOnChanges({'appId': change}); fixture.detectChanges(); - component.onProcessDefChange('my:process1'); - fixture.whenStable(); - startBtn = fixture.nativeElement.querySelector('#button-start'); })); it('should have start button disabled when name not filled out', async(() => { component.name = ''; fixture.detectChanges(); - expect(startBtn.disabled).toBe(true); + fixture.whenStable().then(() => { + startBtn = fixture.nativeElement.querySelector('#button-start'); + expect(startBtn.disabled).toBe(true); + }); })); - it('should have start button disabled when no process is selected', async(() => { + it('should have start button disabled when no process is selected', () => { component.onProcessDefChange(''); fixture.detectChanges(); + startBtn = fixture.nativeElement.querySelector('#button-start'); expect(startBtn.disabled).toBe(true); - })); + }); - it('should enable start button when name and process filled out', async(() => { + it('should enable start button when name and process filled out', () => { + component.onProcessDefChange('my:process1'); fixture.detectChanges(); - let startButton = fixture.nativeElement.querySelector('#button-start'); - expect(startButton.disabled).toBeFalsy(); - })); + fixture.whenStable().then(() => { + startBtn = fixture.nativeElement.querySelector('#button-start'); + expect(startBtn.disabled).toBe(false); + }); + }); - it('should disable the start process button when process name is empty', async(() => { + it('should disable the start process button when process name is empty', () => { component.name = ''; fixture.detectChanges(); let startButton = fixture.nativeElement.querySelector('#button-start'); - expect(startButton.disabled).toBeTruthy(); - })); + expect(startButton.disabled).toBe(true); + }); }); 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 2c16a45acf..230d3c3ca0 100644 --- a/lib/process-services/process-list/components/start-process.component.ts +++ b/lib/process-services/process-list/components/start-process.component.ts @@ -95,6 +95,13 @@ export class StartProcessInstanceComponent implements OnChanges { } } + compareProcessDef = (processDefId) => { + if (this.processDefinitions && this.processDefinitions.length === 1 && processDefId === this.processDefinitions[0].id) { + this.onProcessDefChange(processDefId); + return true; + } + } + onProcessDefChange(processDefinitionId) { let processDef = this.processDefinitions.find((processDefinition) => { return processDefinition.id === processDefinitionId;