Skip to content

Commit 7eb6f6f

Browse files
committed
fix(calendar-web): custom agenda view fix
1 parent bff4e18 commit 7eb6f6f

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ObjectItem } from "mendix";
22
import { DateLocalizer, Formats, ViewsProps } from "react-big-calendar";
33
import { CalendarContainerProps } from "../../typings/CalendarProps";
44
import { createConfigurableToolbar, CustomToolbar, ResolvedToolbarItem } from "../components/Toolbar";
5-
import { eventPropGetter } from "../utils/calendar-utils";
5+
import { eventPropGetter, getTextValue } from "../utils/calendar-utils";
66
import { CalendarEvent, DragAndDropCalendarProps } from "../utils/typings";
77
import { CustomWeekController } from "./CustomWeekController";
88

@@ -318,21 +318,22 @@ export class CalendarPropsBuilder {
318318
if (!items || items.length === 0) {
319319
return undefined;
320320
}
321+
321322
return items.map(i => ({
322323
itemType: i.itemType,
323324
position: i.position,
324-
caption: i.caption?.value,
325+
caption: getTextValue(i.caption?.value),
325326
renderMode: i.renderMode,
326-
customButtonTooltip: i.buttonTooltip?.value,
327+
customButtonTooltip: getTextValue(i.buttonTooltip?.value),
327328
customButtonStyle: i.buttonStyle,
328-
customViewHeaderDayFormat: i.customViewHeaderDayFormat?.value,
329-
customViewCellDateFormat: i.customViewCellDateFormat?.value,
330-
customViewGutterTimeFormat: i.customViewGutterTimeFormat?.value,
331-
customViewGutterDateFormat: i.customViewGutterDateFormat?.value,
332-
customViewAllDayText: i.customViewAllDayText?.value,
333-
customViewTextHeaderDate: i.customViewTextHeaderDate?.value,
334-
customViewTextHeaderTime: i.customViewTextHeaderTime?.value,
335-
customViewTextHeaderEvent: i.customViewTextHeaderEvent?.value
329+
customViewHeaderDayFormat: getTextValue(i.customViewHeaderDayFormat?.value),
330+
customViewCellDateFormat: getTextValue(i.customViewCellDateFormat?.value),
331+
customViewGutterTimeFormat: getTextValue(i.customViewGutterTimeFormat?.value),
332+
customViewGutterDateFormat: getTextValue(i.customViewGutterDateFormat?.value),
333+
customViewAllDayText: getTextValue(i.customViewAllDayText?.value),
334+
customViewTextHeaderDate: getTextValue(i.customViewTextHeaderDate?.value),
335+
customViewTextHeaderTime: getTextValue(i.customViewTextHeaderTime?.value),
336+
customViewTextHeaderEvent: getTextValue(i.customViewTextHeaderEvent?.value)
336337
}));
337338
}
338339
}

packages/pluggableWidgets/calendar-web/src/utils/calendar-utils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ export function getViewRange(view: string, date: Date): { start: Date; end: Date
107107
}
108108
}
109109

110+
/**
111+
* Converts empty or whitespace-only strings to undefined.
112+
* Useful for handling optional textTemplate values from Mendix.
113+
* @param value - The string value to check
114+
* @returns The trimmed value if non-empty, otherwise undefined
115+
*/
116+
export function getTextValue(value?: string): string | undefined {
117+
return value && value.trim().length > 0 ? value : undefined;
118+
}
119+
110120
// Helper to get Mendix session locale
111121
export interface MendixLocaleData {
112122
code: string;

0 commit comments

Comments
 (0)