From 3bd2c8a81308050cbcb422f0d568d751d25841f4 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Fri, 16 Aug 2024 10:23:38 +0300 Subject: [PATCH] calendar 0 duration fix --- .../crm/src/views/calendar/calendar.js | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/client/modules/crm/src/views/calendar/calendar.js b/client/modules/crm/src/views/calendar/calendar.js index 0632249994..5f6f980bb7 100644 --- a/client/modules/crm/src/views/calendar/calendar.js +++ b/client/modules/crm/src/views/calendar/calendar.js @@ -466,9 +466,7 @@ class CalendarView extends View { } /** - * @private - * @param {Object.} o - * @return {{ + * @typedef {{ * recordId, * dateStart?: string, * originalColor?: string, @@ -480,7 +478,16 @@ class CalendarView extends View { * title: string, * dateEndDate?: ?string, * status?: string, - * }} + * allDay?: boolean, + * start?: Date, + * end?: Date, + * }} module:modules/crm/views/calendar/calendar~FcEvent + */ + + /** + * @private + * @param {Object.} o + * @return {module:modules/crm/views/calendar/calendar~FcEvent} */ convertToFcEvent(o) { const event = { @@ -1315,7 +1322,7 @@ class CalendarView extends View { /** * @private * @param {EventImpl} event - * @return {Object.} + * @return {module:modules/crm/views/calendar/calendar~FcEvent} */ obtainPropsFromEvent(event) { const props = {}; @@ -1337,10 +1344,19 @@ class CalendarView extends View { /** * @private * @param {EventImpl} event - * @param {Object.} props + * @param {{start?: Date, end?: Date, allDay: boolean} & Record} props */ applyPropsToEvent(event, props) { if ('start' in props) { + if ( + !props.allDay && + props.end && + props.end.getTime() === props.start.getTime() + ) { + // Otherwise, 0-duration event would disappear. + props.end = moment(props.end).add(1, 'hour').toDate(); + } + event.setDates(props.start, props.end, {allDay: props.allDay}); }