Skip to content

Commit 1d52bc0

Browse files
committed
fix(calendar-web): standart view preview, rename custom week to work week
1 parent a255dca commit 1d52bc0

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

packages/pluggableWidgets/calendar-web/src/Calendar.editorPreview.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import classnames from "classnames";
22
import { ReactElement } from "react";
3-
import { Calendar, dateFnsLocalizer, EventPropGetter } from "react-big-calendar";
3+
import { Calendar, dateFnsLocalizer, EventPropGetter, View } from "react-big-calendar";
44
import { CalendarPreviewProps } from "../typings/CalendarProps";
55
import { createConfigurableToolbar, CustomToolbar } from "./components/Toolbar";
66
import { eventPropGetter, format, getDay, parse, startOfWeek } from "./utils/calendar-utils";
@@ -75,27 +75,35 @@ export function preview(props: CalendarPreviewProps): ReactElement {
7575
// Cast eventPropGetter to satisfy preview Calendar generic
7676
const previewEventPropGetter = eventPropGetter as unknown as EventPropGetter<(typeof events)[0]>;
7777

78+
const isCustomView = props.view === "custom";
7879
const toolbar =
79-
props.view === "custom" && props.toolbarItems?.length
80+
isCustomView && props.toolbarItems?.length
8081
? createConfigurableToolbar(
8182
props.toolbarItems.map(i => ({
8283
itemType: i.itemType,
8384
position: i.position,
8485
caption: i.caption,
85-
renderMode: i.renderMode
86+
renderMode: i.renderMode,
87+
customButtonTooltip: undefined,
88+
customButtonStyle: i.buttonStyle
8689
})) as any
8790
)
8891
: CustomToolbar;
8992

93+
const defaultView = isCustomView ? props.defaultViewCustom : props.defaultViewStandard;
94+
const views: View[] = isCustomView
95+
? (["day", "week", "month", "work_week"] as View[])
96+
: (["day", "week", "month"] as View[]);
97+
9098
return (
9199
<div className={classnames("widget-events-preview", "widget-calendar", className)} style={wrapperStyle}>
92100
<Calendar
93101
components={{ toolbar }}
94-
defaultView={props.defaultViewStandard}
102+
defaultView={defaultView}
95103
events={events}
96104
localizer={localizer}
97105
messages={{ ...localizer.messages, work_week: "Custom" }}
98-
views={["day", "week", "month", "work_week"]}
106+
views={views}
99107
eventPropGetter={previewEventPropGetter}
100108
/>
101109
</div>

packages/pluggableWidgets/calendar-web/src/Calendar.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
<enumerationValue key="day">Day</enumerationValue>
103103
<enumerationValue key="week">Week</enumerationValue>
104104
<enumerationValue key="month">Month</enumerationValue>
105-
<enumerationValue key="work_week">Custom</enumerationValue>
105+
<enumerationValue key="work_week">Work week</enumerationValue>
106106
<enumerationValue key="agenda">Agenda</enumerationValue>
107107
</enumerationValues>
108108
</property>
@@ -148,7 +148,7 @@
148148
<enumerationValue key="month">Month view button</enumerationValue>
149149
<enumerationValue key="agenda">Agenda view button</enumerationValue>
150150
<enumerationValue key="week">Week view button</enumerationValue>
151-
<enumerationValue key="work_week">Custom week view button</enumerationValue>
151+
<enumerationValue key="work_week">Work week view button</enumerationValue>
152152
<enumerationValue key="title">Title date text</enumerationValue>
153153
<enumerationValue key="previous">Previous button</enumerationValue>
154154
<enumerationValue key="next">Next button</enumerationValue>

0 commit comments

Comments
 (0)