mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
@@ -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. |
|
||||
|
@@ -577,6 +577,10 @@ export let startMockForm = {
|
||||
{
|
||||
id: 'complete',
|
||||
name: 'Complete'
|
||||
},
|
||||
{
|
||||
id: 'start_process',
|
||||
name: 'Start Process'
|
||||
}
|
||||
],
|
||||
javascriptEvents: [],
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -17,6 +17,7 @@
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<activiti-start-form *ngIf="hasStartForm()"
|
||||
[disableStartProcessButton]="!hasProcessName()"
|
||||
[processDefinitionId]="currentProcessDef.id"
|
||||
(outcomeClick)="onOutcomeClick($event)"
|
||||
[showRefreshButton]="false">
|
||||
|
@@ -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();
|
||||
}));
|
||||
|
||||
});
|
||||
|
@@ -154,4 +154,8 @@ export class StartProcessInstanceComponent implements OnChanges {
|
||||
}
|
||||
this.resetErrorMessage();
|
||||
}
|
||||
|
||||
hasProcessName(): boolean {
|
||||
return this.name ? true : false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user