Skip to content

Commit 3c4cc51

Browse files
feat(calendar-web): add buildFormats method to customize event display formats
1 parent 42b461c commit 3c4cc51

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/pluggableWidgets/calendar-web/src/helpers/CalendarPropsBuilder.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ObjectItem } from "mendix";
2-
import { CalendarProps as ReactCalendarProps, NavigateAction, ViewsProps } from "react-big-calendar";
2+
import { CalendarProps as ReactCalendarProps, Formats, NavigateAction, ViewsProps } from "react-big-calendar";
33
import { withDragAndDropProps } from "react-big-calendar/lib/addons/dragAndDrop";
44

55
import { CalendarContainerProps } from "../../typings/CalendarProps";
@@ -47,6 +47,7 @@ export class CalendarPropsBuilder {
4747

4848
build(): DragAndDropCalendarProps<CalendarEvent> {
4949
const CustomWeek = CustomWeekController.getComponent(this.visibleDays);
50+
const formats = this.buildFormats();
5051
const views: ViewsProps<CalendarEvent> = this.isCustomView
5152
? { day: true, week: true, month: true, work_week: CustomWeek, agenda: true }
5253
: { day: true, week: true, month: true };
@@ -60,6 +61,7 @@ export class CalendarPropsBuilder {
6061
work_week: this.customCaption
6162
},
6263
events: this.events,
64+
formats,
6365
localizer,
6466
resizable: this.props.editable !== "never",
6567
selectable: this.props.enableCreate,
@@ -106,6 +108,16 @@ export class CalendarPropsBuilder {
106108
}
107109
}
108110

111+
private buildFormats(): Formats {
112+
const formats: Formats = {};
113+
114+
if (this.props.showEventDate === false) {
115+
formats.eventTimeRangeFormat = () => "";
116+
}
117+
118+
return formats;
119+
}
120+
109121
private buildTime(hour: number): Date {
110122
const time = new Date();
111123
time.setMinutes(0, 0, 0);

0 commit comments

Comments
 (0)