[ADF-1740] disabling start process button when the process name is empty (#2483)

* [ADF-1740] disabling start process button when the process name is empty

* [ADF-1740] removed wrong fdescribe
This commit is contained in:
Vito
2017-10-17 15:11:06 +01:00
committed by Eugenio Romano
parent fa7f89c75f
commit 073003ba9a
7 changed files with 36 additions and 2 deletions

View File

@@ -114,6 +114,7 @@ and store the form field as metadata. The param nameNode is optional.
| showTitle | boolean | true | Toggle rendering of the form title. |
| showCompleteButton | boolean | true | Toggle rendering of the `Complete` outcome button. |
| disableCompleteButton | boolean | false | The `Complete` outcome button is shown but it will be disabled. |
| disableStartProcessButton | boolean | false | The `Start Process` outcome button is shown but it will be disabled. |
| showSaveButton | boolean | true | Toggle rendering of the `Save` outcome button. |
| readOnly | boolean | false | Toggle readonly state of the form. Enforces all form widgets render readonly if enabled. |
| showRefreshButton | boolean | true | Toggle rendering of the `Refresh` button. |

View File

@@ -577,6 +577,10 @@ export let startMockForm = {
{
id: 'complete',
name: 'Complete'
},
{
id: 'start_process',
name: 'Start Process'
}
],
javascriptEvents: [],

View File

@@ -775,6 +775,17 @@ describe('FormComponent', () => {
expect(formComponent.isOutcomeButtonEnabled(completeOutcome)).toBeFalsy();
});
it('should disable start process outcome button when disableStartProcessButton is true', () => {
let formModel = new FormModel();
formComponent.form = formModel;
formComponent.disableStartProcessButton = true;
expect(formModel.isValid).toBeTruthy();
let startProcessOutcome = formComponent.form.outcomes.find(outcome => outcome.name === FormOutcomeModel.START_PROCESS_ACTION);
expect(formComponent.isOutcomeButtonEnabled(startProcessOutcome)).toBeFalsy();
});
it('should raise [executeOutcome] event for formService', (done) => {
formService.executeOutcome.subscribe(() => {
done();

View File

@@ -75,6 +75,9 @@ export class FormComponent implements OnInit, OnChanges {
@Input()
disableCompleteButton: boolean = false;
@Input()
disableStartProcessButton: boolean = false;
@Input()
showSaveButton: boolean = true;
@@ -148,6 +151,9 @@ export class FormComponent implements OnInit, OnChanges {
if (outcome.name === FormOutcomeModel.COMPLETE_ACTION) {
return this.disableCompleteButton ? false : this.form.isValid;
}
if (outcome.name === FormOutcomeModel.START_PROCESS_ACTION) {
return this.disableStartProcessButton ? false : this.form.isValid;
}
return this.form.isValid;
}
return false;

View File

@@ -17,6 +17,7 @@
</mat-select>
</mat-form-field>
<activiti-start-form *ngIf="hasStartForm()"
[disableStartProcessButton]="!hasProcessName()"
[processDefinitionId]="currentProcessDef.id"
(outcomeClick)="onOutcomeClick($event)"
[showRefreshButton]="false">

View File

@@ -353,7 +353,14 @@ describe('StartProcessInstanceComponent', () => {
it('should enable start button when name and process filled out', async(() => {
fixture.detectChanges();
let startButton = fixture.nativeElement.querySelector('#button-start');
expect(startButton.enable).toBeFalsy();
expect(startButton.disabled).toBeFalsy();
}));
it('should disable the start process button when process name is empty', async(() => {
component.name = '';
fixture.detectChanges();
let startButton = fixture.nativeElement.querySelector('#button-start');
expect(startButton.disabled).toBeTruthy();
}));
});

View File

@@ -154,4 +154,8 @@ export class StartProcessInstanceComponent implements OnChanges {
}
this.resetErrorMessage();
}
hasProcessName(): boolean {
return this.name ? true : false;
}
}