Skip to content

Commit ad9c718

Browse files
author
FalkWolsky
committed
Calendar Premium Views
1 parent 0b2e70f commit ad9c718

File tree

6 files changed

+115
-15
lines changed

6 files changed

+115
-15
lines changed

client/packages/lowcoder-comps/src/comps/calendarComp/calendarComp.tsx

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
CustomModal,
2121
jsonValueExposingStateControl,
2222
CalendarDeleteIcon,
23+
jsonValueStateControl,
2324
Tooltip,
2425
} from "lowcoder-sdk";
2526
import { default as Form } from "antd/es/form";
@@ -54,13 +55,17 @@ import {
5455
slotLabelFormat,
5556
viewClassNames,
5657
FormWrapper,
58+
resourcesDefaultData,
59+
resourcesEventsDefaultData,
60+
resourceTimeLineHeaderToolbar,
61+
resourceTimeGridHeaderToolbar,
5762
} from "./calendarConstants";
5863
import dayjs from "dayjs";
5964

60-
function filterViews() {}
61-
6265
const childrenMap = {
6366
events: jsonValueExposingStateControl("events", defaultData),
67+
resourcesEvents: jsonValueStateControl(resourcesEventsDefaultData),
68+
resources: jsonValueStateControl(resourcesDefaultData),
6469
onEvent: ChangeEventHandlerControl,
6570

6671
editable: withDefault(BoolControl, true),
@@ -70,15 +75,17 @@ const childrenMap = {
7075
DefaultWithPremiumViewOptions,
7176
"timeGridWeek"
7277
),
73-
7478
firstDay: dropdownControl(FirstDayOptions, "1"),
7579
showEventTime: withDefault(BoolControl, true),
7680
showWeekends: withDefault(BoolControl, true),
7781
showAllDay: withDefault(BoolControl, true),
7882
dayMaxEvents: withDefault(NumberControl, 2),
7983
eventMaxStack: withDefault(NumberControl, 0),
8084
style: styleControl(CalendarStyle),
81-
licenceKey: withDefault(StringControl, ""),
85+
licenceKey: withDefault(
86+
StringControl,
87+
"CC-Attribution-NonCommercial-NoDerivatives"
88+
),
8289
};
8390

8491
let CalendarBasicComp = (function () {
@@ -103,7 +110,7 @@ let CalendarBasicComp = (function () {
103110
};
104111
});
105112

106-
const {
113+
let {
107114
defaultDate,
108115
defaultFreeView,
109116
defaultPremiumView,
@@ -307,14 +314,28 @@ let CalendarBasicComp = (function () {
307314
}
308315
props.onEvent("change");
309316
form.resetFields();
310-
});
317+
}); //small change
311318
},
312319
onCancel: () => {
313320
form.resetFields();
314321
},
315322
});
316323
};
317324

325+
const toolBar = (defaultView: any) => {
326+
switch (defaultView) {
327+
case "resourceTimelineDay":
328+
return resourceTimeLineHeaderToolbar;
329+
break;
330+
case "resourceTimeGridDay":
331+
return resourceTimeGridHeaderToolbar;
332+
break;
333+
default:
334+
return headerToolbar;
335+
break;
336+
}
337+
};
338+
318339
let initialDate = defaultDate;
319340
try {
320341
initialDate = new Date(defaultDate).toISOString();
@@ -338,7 +359,12 @@ let CalendarBasicComp = (function () {
338359
>
339360
<FullCalendar
340361
slotEventOverlap={false}
341-
events={events}
362+
events={
363+
defaultView == "resourceTimelineDay" ||
364+
defaultView == "resourceTimeGridDay"
365+
? props.resourcesEvents.value
366+
: events
367+
}
342368
expandRows={true}
343369
height={"100%"}
344370
locale={getCalendarLocale()}
@@ -354,7 +380,7 @@ let CalendarBasicComp = (function () {
354380
resourceTimeGridPlugin,
355381
adaptivePlugin,
356382
]}
357-
headerToolbar={headerToolbar}
383+
headerToolbar={toolBar(defaultView)}
358384
moreLinkClick={(info) => {
359385
let left = 0;
360386
const ele = info.jsEvent.target as HTMLElement;
@@ -380,6 +406,12 @@ let CalendarBasicComp = (function () {
380406
buttonText={buttonText}
381407
schedulerLicenseKey={licenceKey}
382408
views={views}
409+
resources={
410+
defaultView == "resourceTimelineDay" ||
411+
defaultView == "resourceTimeGridDay"
412+
? props.resources.value
413+
: []
414+
}
383415
eventClassNames={() => (!showEventTime ? "no-time" : "")}
384416
slotLabelFormat={slotLabelFormat}
385417
viewClassNames={viewClassNames}
@@ -429,7 +461,7 @@ let CalendarBasicComp = (function () {
429461
}
430462
});
431463
if (needChange) {
432-
props.events.onChange(changeEvents);
464+
// props.events.onChange(changeEvents);
433465
props.onEvent("change");
434466
}
435467
}}
@@ -439,11 +471,15 @@ let CalendarBasicComp = (function () {
439471
})
440472
.setPropertyViewFn((children) => {
441473
let licence = children.licenceKey.getView();
474+
442475
return (
443476
<>
444477
<Section name={sectionNames.basic}>
445478
{children.events.propertyView({})}
446479
</Section>
480+
<Section name="Resources">
481+
{children.resources.propertyView({})}
482+
</Section>
447483
<Section name={sectionNames.interaction}>
448484
{children.licenceKey.propertyView({
449485
label: trans("calendar.licence"),
@@ -511,4 +547,4 @@ CalendarBasicComp = class extends CalendarBasicComp {
511547
export const CalendarComp = withExposingConfigs(CalendarBasicComp, [
512548
new NameConfig("events", trans("calendar.events")),
513549
NameConfigHidden,
514-
]);
550+
]);

client/packages/lowcoder-comps/src/comps/calendarComp/calendarConstants.tsx

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,6 @@ export enum ViewType {
781781
TIMEGRID = "timeGridDay",
782782
}
783783

784-
785784
export const DefaultWithPremiumViewOptions = [
786785
{
787786
label: trans("calendar.month"),
@@ -791,9 +790,13 @@ export const DefaultWithPremiumViewOptions = [
791790
label: trans("calendar.week"),
792791
value: "timeGridWeek",
793792
},
793+
{
794+
label: trans("calendar.resourceTimeGridDay"),
795+
value: "resourceTimeGridDay",
796+
},
794797
{
795798
label: trans("calendar.timeline"),
796-
value: "resourceTimeline",
799+
value: "resourceTimelineDay",
797800
},
798801
{
799802
label: trans("calendar.day"),
@@ -871,6 +874,52 @@ export const defaultData = [
871874
allDay: true,
872875
},
873876
];
877+
export const resourcesEventsDefaultData = [
878+
{
879+
resourceId: "d",
880+
title: "event 1",
881+
start: dayjs().hour(10).minute(0).second(0).format(DATE_TIME_FORMAT),
882+
end: dayjs().hour(17).minute(30).second(0).format(DATE_TIME_FORMAT),
883+
},
884+
{
885+
resourceId: "b",
886+
title: "event 5",
887+
start: dayjs().hour(8).minute(0).second(0).format(DATE_TIME_FORMAT),
888+
end: dayjs().hour(16).minute(30).second(0).format(DATE_TIME_FORMAT),
889+
},
890+
{
891+
resourceId: "a",
892+
title: "event 3",
893+
start: dayjs().hour(12).minute(0).second(0).format(DATE_TIME_FORMAT),
894+
end: dayjs().hour(21).minute(30).second(0).format(DATE_TIME_FORMAT),
895+
},
896+
];
897+
898+
export const resourcesDefaultData = [
899+
{
900+
id: "a",
901+
title: "Auditorium A",
902+
},
903+
{
904+
id: "b",
905+
title: "Auditorium B",
906+
eventColor: "green",
907+
},
908+
{
909+
id: "d",
910+
title: "Auditorium D",
911+
children: [
912+
{
913+
id: "d1",
914+
title: "Room D1",
915+
},
916+
{
917+
id: "d2",
918+
title: "Room D2",
919+
},
920+
],
921+
},
922+
];
874923

875924
export const buttonText = {
876925
today: trans("calendar.today"),
@@ -886,6 +935,16 @@ export const headerToolbar = {
886935
right: "prev today next dayGridMonth,timeGridWeek,timeGridDay,listWeek",
887936
};
888937

938+
export const resourceTimeLineHeaderToolbar = {
939+
left: "title",
940+
right:
941+
"prev today next resourceTimelineMonth,resourceTimelineWeek,resourceTimelineDay",
942+
};
943+
export const resourceTimeGridHeaderToolbar = {
944+
left: "title",
945+
right: "prev today next",
946+
};
947+
889948
const weekHeadContent = (info: DayHeaderContentArg) => {
890949
const text = info.text.split(" ");
891950
return {
@@ -943,4 +1002,4 @@ export const viewClassNames = (info: ViewContentArg) => {
9431002
}
9441003
}
9451004
return className;
946-
};
1005+
};

client/packages/lowcoder-comps/src/i18n/comps/locales/en.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ export const en = {
127127
week: "Week",
128128
day: "Day",
129129
list: "List",
130-
timeline: "TimeLine", //added by fred
130+
timeline: "Resource Timeline", //added by fred
131+
resourceTimeGridDay: "Resource Grid", //added by fred
131132
monday: "Monday",
132133
tuesday: "Tuesday",
133134
wednesday: "Wednesday",

client/packages/lowcoder-comps/src/i18n/comps/locales/zh.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ export const zh = {
120120
week: "周",
121121
day: "日",
122122
list: "列表",
123+
timeline: "时间轴",
124+
resourceTimeGridDay: "资源时间网格日",
123125
monday: "星期一",
124126
tuesday: "星期二",
125127
wednesday: "星期三",

client/packages/lowcoder-design/src/i18n/design/locales/en.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ export const en = {
1818
},
1919
prop: {
2020
basic: "Basic",
21+
resources: "Resources",
2122
interaction: "Interaction",
2223
advanced: "Advanced",
2324
validation: "Validation",
2425
layout: "Layout",
2526
labelStyle:"Label Style",
2627
style: "Style",
27-
meetings : "Meeting Settings",
28+
meetings: "Meeting Settings",
2829
data: "Data",
2930
},
3031
passwordInput: {

client/packages/lowcoder-design/src/i18n/design/locales/zh.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const zh = {
1818
},
1919
prop: {
2020
basic: "基础",
21+
resources: "资源",
2122
interaction: "交互",
2223
advanced: "高级",
2324
validation: "验证",

0 commit comments

Comments
 (0)