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. |
|
| showTitle | boolean | true | Toggle rendering of the form title. |
|
||||||
| showCompleteButton | boolean | true | Toggle rendering of the `Complete` outcome button. |
|
| showCompleteButton | boolean | true | Toggle rendering of the `Complete` outcome button. |
|
||||||
| disableCompleteButton | boolean | false | The `Complete` outcome button is shown but it will be disabled. |
|
| 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. |
|
| 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. |
|
| 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. |
|
| showRefreshButton | boolean | true | Toggle rendering of the `Refresh` button. |
|
||||||
|
@@ -577,6 +577,10 @@ export let startMockForm = {
|
|||||||
{
|
{
|
||||||
id: 'complete',
|
id: 'complete',
|
||||||
name: 'Complete'
|
name: 'Complete'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'start_process',
|
||||||
|
name: 'Start Process'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
javascriptEvents: [],
|
javascriptEvents: [],
|
||||||
|
@@ -775,6 +775,17 @@ describe('FormComponent', () => {
|
|||||||
expect(formComponent.isOutcomeButtonEnabled(completeOutcome)).toBeFalsy();
|
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) => {
|
it('should raise [executeOutcome] event for formService', (done) => {
|
||||||
formService.executeOutcome.subscribe(() => {
|
formService.executeOutcome.subscribe(() => {
|
||||||
done();
|
done();
|
||||||
|
@@ -75,6 +75,9 @@ export class FormComponent implements OnInit, OnChanges {
|
|||||||
@Input()
|
@Input()
|
||||||
disableCompleteButton: boolean = false;
|
disableCompleteButton: boolean = false;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
disableStartProcessButton: boolean = false;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
showSaveButton: boolean = true;
|
showSaveButton: boolean = true;
|
||||||
|
|
||||||
@@ -148,6 +151,9 @@ export class FormComponent implements OnInit, OnChanges {
|
|||||||
if (outcome.name === FormOutcomeModel.COMPLETE_ACTION) {
|
if (outcome.name === FormOutcomeModel.COMPLETE_ACTION) {
|
||||||
return this.disableCompleteButton ? false : this.form.isValid;
|
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 this.form.isValid;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@@ -16,7 +16,8 @@
|
|||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<activiti-start-form *ngIf="hasStartForm()"
|
<activiti-start-form *ngIf="hasStartForm()"
|
||||||
|
[disableStartProcessButton]="!hasProcessName()"
|
||||||
[processDefinitionId]="currentProcessDef.id"
|
[processDefinitionId]="currentProcessDef.id"
|
||||||
(outcomeClick)="onOutcomeClick($event)"
|
(outcomeClick)="onOutcomeClick($event)"
|
||||||
[showRefreshButton]="false">
|
[showRefreshButton]="false">
|
||||||
|
@@ -353,7 +353,14 @@ describe('StartProcessInstanceComponent', () => {
|
|||||||
it('should enable start button when name and process filled out', async(() => {
|
it('should enable start button when name and process filled out', async(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
let startButton = fixture.nativeElement.querySelector('#button-start');
|
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();
|
this.resetErrorMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasProcessName(): boolean {
|
||||||
|
return this.name ? true : false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user