Skip to content
Open
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
1 change: 1 addition & 0 deletions packages/volto/news/7993.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed the requirement to set the end date when "open end" is checked. @TimoBroeskamp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ const DatetimeWidgetComponent = (props) => {
if (id === 'end' && formData?.open_end) {
return null;
}
// If open_end is checked set formData.end to formData.start
if (formData?.open_end === true) {
formData.end = formData.start;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

const getInternalValue = () => {
return parseDateTime(toBackendLang(lang), value, undefined, moment.default);
Expand Down
6 changes: 4 additions & 2 deletions packages/volto/src/helpers/FormValidation/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ export const startEventDateRangeValidator = ({
formatMessage,
}: Validator) => {
const isValid =
value && formData.end && new Date(value) < new Date(formData.end);
(value && formData.end && new Date(value) < new Date(formData.end)) ||
(formData.open_end && formData.start === formData.end);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks with the backend defaults, see above. Better is to require that start <= end in case of open_end.

return !isValid
? formatMessage(messages.startEventRange, {
endDateValueOrEndFieldName: formData.end || 'end',
Expand All @@ -175,7 +176,8 @@ export const endEventDateRangeValidator = ({
formatMessage,
}: Validator) => {
const isValid =
value && formData.start && new Date(value) > new Date(formData.start);
(value && formData.start && new Date(value) > new Date(formData.start)) ||
(formData.open_end && formData.start === formData.end);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

return !isValid
? formatMessage(messages.endEventRange, {
startDateValueOrStartFieldName: formData.start || 'start',
Expand Down
Loading