mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4461] FormCloud - fix date validations (#4776)
* [ADF-4443] FormCloud - fix date validations * [ADF-4443] - add save validation * [ADF-4443] - PR changes * [ADF-4443] FormCloud - fix date validations * fix unit tests * [ADF-4443] - add save validation * [ADF-4443] - PR changes * Revert changes on save form * Revert check form valid on save
This commit is contained in:
committed by
Eugenio Romano
parent
8b5038218e
commit
6040f59391
@@ -70,7 +70,7 @@ export abstract class FormBaseComponent {
|
|||||||
|
|
||||||
/** Contains a list of form field validator instances. */
|
/** Contains a list of form field validator instances. */
|
||||||
@Input()
|
@Input()
|
||||||
fieldValidators: FormFieldValidator[] = [];
|
fieldValidators: FormFieldValidator[];
|
||||||
|
|
||||||
/** Emitted when the supplied form values have a validation error. */
|
/** Emitted when the supplied form values have a validation error. */
|
||||||
@Output()
|
@Output()
|
||||||
|
@@ -189,5 +189,20 @@ describe('DateWidgetComponent', () => {
|
|||||||
dateButton = <HTMLButtonElement> element.querySelector('button');
|
dateButton = <HTMLButtonElement> element.querySelector('button');
|
||||||
expect(dateButton.disabled).toBeTruthy();
|
expect(dateButton.disabled).toBeTruthy();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should set isValid to false when the value is not a correct date value', async(() => {
|
||||||
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
|
id: 'date-field-id',
|
||||||
|
name: 'date-name',
|
||||||
|
value: 'aa',
|
||||||
|
type: 'date',
|
||||||
|
readOnly: 'false'
|
||||||
|
});
|
||||||
|
widget.field.isVisible = true;
|
||||||
|
widget.field.readOnly = false;
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(widget.field.isValid).toBeFalsy();
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -80,5 +80,4 @@ export class DateWidgetComponent extends WidgetComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
this.onFieldChanged(this.field);
|
this.onFieldChanged(this.field);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -29,7 +29,9 @@ import { FormBaseComponent,
|
|||||||
WidgetVisibilityService,
|
WidgetVisibilityService,
|
||||||
FormService,
|
FormService,
|
||||||
NotificationService,
|
NotificationService,
|
||||||
FormRenderingService } from '@alfresco/adf-core';
|
FormRenderingService,
|
||||||
|
FORM_FIELD_VALIDATORS,
|
||||||
|
FormFieldValidator } from '@alfresco/adf-core';
|
||||||
import { FormCloudService } from '../services/form-cloud.service';
|
import { FormCloudService } from '../services/form-cloud.service';
|
||||||
import { FormCloud } from '../models/form-cloud.model';
|
import { FormCloud } from '../models/form-cloud.model';
|
||||||
import { TaskVariableCloud } from '../models/task-variable-cloud.model';
|
import { TaskVariableCloud } from '../models/task-variable-cloud.model';
|
||||||
@@ -62,6 +64,9 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
|
|||||||
@Input()
|
@Input()
|
||||||
data: TaskVariableCloud[];
|
data: TaskVariableCloud[];
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
fieldValidators: FormFieldValidator[] = [...FORM_FIELD_VALIDATORS];
|
||||||
|
|
||||||
/** Emitted when the form is submitted with the `Save` or custom outcomes. */
|
/** Emitted when the form is submitted with the `Save` or custom outcomes. */
|
||||||
@Output()
|
@Output()
|
||||||
formSaved: EventEmitter<FormCloud> = new EventEmitter<FormCloud>();
|
formSaved: EventEmitter<FormCloud> = new EventEmitter<FormCloud>();
|
||||||
|
Reference in New Issue
Block a user