diff --git a/ng2-components/ng2-activiti-processlist/src/components/start-process.component.html b/ng2-components/ng2-activiti-processlist/src/components/start-process.component.html
index 3f56b10f0a..4d7d1d491b 100644
--- a/ng2-components/ng2-activiti-processlist/src/components/start-process.component.html
+++ b/ng2-components/ng2-activiti-processlist/src/components/start-process.component.html
@@ -1,33 +1,30 @@
\ No newline at end of file
diff --git a/ng2-components/ng2-activiti-processlist/src/components/start-process.component.spec.ts b/ng2-components/ng2-activiti-processlist/src/components/start-process.component.spec.ts
index a87a78644e..b95511be24 100644
--- a/ng2-components/ng2-activiti-processlist/src/components/start-process.component.spec.ts
+++ b/ng2-components/ng2-activiti-processlist/src/components/start-process.component.spec.ts
@@ -21,7 +21,6 @@ import {
MdButtonModule,
MdCardModule,
MdInputModule,
- MdProgressSpinnerModule,
MdSelectModule
} from '@angular/material';
import { ActivitiFormModule, FormService } from 'ng2-activiti-form';
@@ -299,18 +298,19 @@ describe('StartProcessInstanceComponent', () => {
expect(startSpy).not.toHaveBeenCalled();
});
- it('should true if form is valid', async(() => {
- component.currentProcessDef = testProcessDefRepr;
+ it('should able to start the process when the required fields are filled up', async(() => {
+ let startSpy: jasmine.Spy = spyOn(component.start, 'emit');
component.name = 'my:process1';
- component.currentProcessDef.id = '1001';
- component.isStartFormMissingOrValid();
- component.validateForm();
+ component.onProcessDefChange('my:process1');
+ fixture.detectChanges();
fixture.whenStable().then(() => {
- expect(component.validateForm()).toBe(true);
+ let startButton = fixture.nativeElement.querySelector('#button-start');
+ startButton.click();
+ expect(startSpy).toHaveBeenCalled();
});
}));
- it('should true if startFrom defined', async(() => {
+ it('should return true if startFrom defined', async(() => {
component.currentProcessDef = testProcessDefRepr;
component.name = 'my:process1';
component.currentProcessDef.hasStartForm = true;
diff --git a/ng2-components/ng2-activiti-processlist/src/components/start-process.component.ts b/ng2-components/ng2-activiti-processlist/src/components/start-process.component.ts
index f99f45284f..eaedc127d0 100644
--- a/ng2-components/ng2-activiti-processlist/src/components/start-process.component.ts
+++ b/ng2-components/ng2-activiti-processlist/src/components/start-process.component.ts
@@ -122,6 +122,10 @@ export class StartProcessInstanceComponent implements OnChanges {
return this.currentProcessDef && this.currentProcessDef.hasStartForm;
}
+ isProcessDefinitionEmpty() {
+ return this.processDefinitions ? (this.processDefinitions.length > 0 || this.errorMessageId) : this.errorMessageId;
+ }
+
isStartFormMissingOrValid() {
if (this.startForm) {
return this.startForm.form && this.startForm.form.isValid;
@@ -142,6 +146,10 @@ export class StartProcessInstanceComponent implements OnChanges {
this.errorMessageId = '';
}
+ hasErrorMessage() {
+ return this.processDefinitions.length === 0 && !this.errorMessageId;
+ }
+
public onOutcomeClick(outcome: string) {
this.startProcess(outcome);
}