mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
AAE-40741 Form rule Validate form doesn't do anything (#11788)
This commit is contained in:
+34
@@ -510,4 +510,38 @@ describe('DateCloudWidgetComponent', () => {
|
||||
expect(widget.field.validationSummary.message).toBe('FORM.FIELD.REQUIRED');
|
||||
});
|
||||
});
|
||||
|
||||
describe('showAllValidationErrors', () => {
|
||||
it('should mark dateInputControl as touched when showAllValidationErrors is true', () => {
|
||||
widget.field = new FormFieldModel(form, {
|
||||
id: 'date-field-id',
|
||||
name: 'date-name',
|
||||
type: 'date',
|
||||
required: true
|
||||
});
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(widget.dateInputControl.touched).toBe(false);
|
||||
|
||||
form.showAllValidationErrors = true;
|
||||
widget.updateReactiveFormControl();
|
||||
|
||||
expect(widget.dateInputControl.touched).toBe(true);
|
||||
});
|
||||
|
||||
it('should not mark dateInputControl as touched when showAllValidationErrors is false', () => {
|
||||
widget.field = new FormFieldModel(form, {
|
||||
id: 'date-field-id',
|
||||
name: 'date-name',
|
||||
type: 'date',
|
||||
required: true
|
||||
});
|
||||
fixture.detectChanges();
|
||||
|
||||
form.showAllValidationErrors = false;
|
||||
widget.updateReactiveFormControl();
|
||||
|
||||
expect(widget.dateInputControl.touched).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -88,6 +88,9 @@ export class DateCloudWidgetComponent extends WidgetComponent implements OnInit,
|
||||
updateReactiveFormControl(): void {
|
||||
this.setFormControlValue();
|
||||
this.updateFormControlState();
|
||||
if (this.field?.form?.showAllValidationErrors) {
|
||||
this.dateInputControl.markAsTouched();
|
||||
}
|
||||
this.validateField();
|
||||
}
|
||||
|
||||
|
||||
+38
@@ -1410,6 +1410,44 @@ describe('DropdownCloudWidgetComponent', () => {
|
||||
expect(allOptions.length).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('showAllValidationErrors', () => {
|
||||
it('should mark dropdownControl as touched when showAllValidationErrors is true', () => {
|
||||
const form = new FormModel();
|
||||
widget.field = new FormFieldModel(form, {
|
||||
id: 'dropdown-id',
|
||||
name: 'dropdown-name',
|
||||
type: FormFieldTypes.DROPDOWN,
|
||||
required: true,
|
||||
options: fakeOptionList
|
||||
});
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(widget.dropdownControl.touched).toBe(false);
|
||||
|
||||
form.showAllValidationErrors = true;
|
||||
widget.updateReactiveFormControl();
|
||||
|
||||
expect(widget.dropdownControl.touched).toBe(true);
|
||||
});
|
||||
|
||||
it('should not mark dropdownControl as touched when showAllValidationErrors is false', () => {
|
||||
const form = new FormModel();
|
||||
widget.field = new FormFieldModel(form, {
|
||||
id: 'dropdown-id',
|
||||
name: 'dropdown-name',
|
||||
type: FormFieldTypes.DROPDOWN,
|
||||
required: true,
|
||||
options: fakeOptionList
|
||||
});
|
||||
fixture.detectChanges();
|
||||
|
||||
form.showAllValidationErrors = false;
|
||||
widget.updateReactiveFormControl();
|
||||
|
||||
expect(widget.dropdownControl.touched).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('DropdownCloudWidgetComponent instantiated by FormFieldComponent wrapper', () => {
|
||||
|
||||
+3
@@ -165,6 +165,9 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI
|
||||
this.setFormControlValue();
|
||||
|
||||
this.updateFormControlState();
|
||||
if (this.field?.form?.showAllValidationErrors) {
|
||||
this.dropdownControl.markAsTouched();
|
||||
}
|
||||
this.handleErrors();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user