Skip to content

Commit b92f5ab

Browse files
author
Illia Obukhau
committed
fix(timeline-web): change month grouping in custom mode
1 parent 1d022ab commit b92f5ab

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

packages/pluggableWidgets/timeline-web/src/Timeline.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { TimelineContainerProps } from "../typings/TimelineProps";
33
import "./ui/Timeline.scss";
44
import { ActionValue, WebIcon } from "mendix";
55
import TimelineComponent, { getGroupHeaderByType } from "./components/TimelineComponent";
6-
import { getHeaderOption } from "./utils/utils";
6+
import { getGroupByMethodForCustomMode, getHeaderOption } from "./utils/utils";
77

88
export interface BasicItemType {
99
icon?: WebIcon;
@@ -44,7 +44,11 @@ export default function Timeline(props: TimelineContainerProps): ReactElement {
4444
action: props.onClick?.get(item)
4545
};
4646
} else {
47-
groupKey = getGroupHeaderByType(groupAttribute?.formatter, props.groupByKey, date);
47+
groupKey = getGroupHeaderByType(
48+
groupAttribute?.formatter,
49+
getGroupByMethodForCustomMode(props.groupByKey),
50+
date
51+
);
4852
constructedItem = {
4953
icon: props.customIcon?.get(item),
5054
groupHeader: props.customGroupHeader?.get(item),

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TimelineContainerProps } from "../../typings/TimelineProps";
1+
import { GroupByKeyEnum, GroupByMonthOptionsEnum, TimelineContainerProps } from "../../typings/TimelineProps";
22

33
export type GroupHeaderConfig = Pick<
44
TimelineContainerProps,
@@ -8,3 +8,11 @@ export type GroupHeaderConfig = Pick<
88
export function getHeaderOption({ groupByKey, groupByDayOptions, groupByMonthOptions }: GroupHeaderConfig) {
99
return groupByKey === "day" ? groupByDayOptions : groupByKey === "month" ? groupByMonthOptions : "year";
1010
}
11+
12+
export function getGroupByMethodForCustomMode(groupByKey: GroupByKeyEnum): GroupByMonthOptionsEnum | GroupByKeyEnum {
13+
if (groupByKey === "month") {
14+
return "monthYear";
15+
}
16+
17+
return groupByKey;
18+
}

packages/pluggableWidgets/timeline-web/typings/TimelineProps.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ export interface TimelineContainerProps {
4040
}
4141

4242
export interface TimelinePreviewProps {
43+
/**
44+
* @deprecated Deprecated since version 9.18.0. Please use class property instead.
45+
*/
4346
className: string;
47+
class: string;
4448
style: string;
4549
styleObject?: CSSProperties;
4650
readOnly: boolean;

0 commit comments

Comments
 (0)