Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AAE-21797] Datetime widget Min/Max values are checked on a field that is not required #9524

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,33 @@ describe('FormFieldModel', () => {
expect(form.values['datetime']).toEqual(expectedDateTimeFormat);
});

it('should set the value to null when the value is null', () => {
const form = new FormModel();
const field = new FormFieldModel(form, {
fieldType: 'FormFieldRepresentation',
id: 'datetime',
name: 'date and time',
type: 'datetime',
value: null,
required: false,
readOnly: false,
params: {
field: {
id: 'datetime',
name: 'date and time',
type: 'datetime',
value: null,
required: false,
readOnly: false
}
},
dateDisplayFormat: 'YYYY-MM-DD HH:mm'
});

expect(field.value).toBe(null);
expect(form.values['datetime']).toEqual(null);
});

it('should parse the checkbox set to "true" when it is readonly', () => {
const form = new FormModel();
const field = new FormFieldModel(form, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ export class FormFieldModel extends FormWidgetModel {
this.value = DateFnsUtils.formatDate(new Date(), this.dateDisplayFormat);
}

const dateTimeValue = new Date(this.value);
const dateTimeValue = this.value !== null ? new Date(this.value) : null;

if (isValidDate(dateTimeValue)) {
this.form.values[this.id] = dateTimeValue.toISOString();
Expand Down
Loading