Skip to content

[WC-2892]: Calendar time format #1729

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

Open
wants to merge 2 commits into
base: spike/WC-2892-calendar-improvements
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions packages/pluggableWidgets/calendar-web/src/Calendar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@
<attributeType name="DateTime" />
</attributeTypes>
</property>
<property key="timeFormat" type="textTemplate" required="false">
<caption>Time format</caption>
<description>Default time format is "hh:mm a"</description>
</property>
<property key="minHour" type="integer" defaultValue="0">
<caption>Day start hour</caption>
<description>The hour at which the day view starts (0–23)</description>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { ObjectItem } from "mendix";
import { CalendarProps as ReactCalendarProps, Formats, NavigateAction, ViewsProps } from "react-big-calendar";
import {
CalendarProps as ReactCalendarProps,
DateLocalizer,
Formats,
NavigateAction,
ViewsProps
} from "react-big-calendar";
import { withDragAndDropProps } from "react-big-calendar/lib/addons/dragAndDrop";

import { CalendarContainerProps } from "../../typings/CalendarProps";
Expand Down Expand Up @@ -115,6 +121,14 @@ export class CalendarPropsBuilder {
formats.eventTimeRangeFormat = () => "";
}

if (this.props.timeFormat?.status === "available") {
const timeFormat = this.props.timeFormat.value ?? "hh:mm a";

formats.timeGutterFormat = (date: Date, _culture: string, localizer: DateLocalizer) => {
return localizer.format(date, timeFormat);
};
}

return formats;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface CalendarContainerProps {
defaultViewCustom: DefaultViewCustomEnum;
defaultViewStandard: DefaultViewStandardEnum;
startDateAttribute?: EditableValue<Date>;
timeFormat?: DynamicValue<string>;
minHour: number;
maxHour: number;
customViewCaption?: DynamicValue<string>;
Expand Down Expand Up @@ -99,6 +100,7 @@ export interface CalendarPreviewProps {
defaultViewCustom: DefaultViewCustomEnum;
defaultViewStandard: DefaultViewStandardEnum;
startDateAttribute: string;
timeFormat: string;
minHour: number | null;
maxHour: number | null;
customViewCaption: string;
Expand Down