From 470afcbe20557c90bef256d0587c746b15a47991 Mon Sep 17 00:00:00 2001 From: MenamAfzal Date: Thu, 25 Jul 2024 20:50:17 +0500 Subject: [PATCH 1/3] initial code --- .../lowcoder-comps/src/comps/calendarComp/calendarComp.tsx | 7 ++++++- .../lowcoder/src/comps/controls/eventHandlerControl.tsx | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/client/packages/lowcoder-comps/src/comps/calendarComp/calendarComp.tsx b/client/packages/lowcoder-comps/src/comps/calendarComp/calendarComp.tsx index f3711990d..2eb7b0755 100644 --- a/client/packages/lowcoder-comps/src/comps/calendarComp/calendarComp.tsx +++ b/client/packages/lowcoder-comps/src/comps/calendarComp/calendarComp.tsx @@ -32,6 +32,7 @@ import { hiddenPropertyView, ChangeEventHandlerControl, DragEventHandlerControl, + CalendarEventHandlerControl, Section, sectionNames, dropdownControl, @@ -76,7 +77,7 @@ let childrenMap: any = { resourcesEvents: jsonValueExposingStateControl("resourcesEvents", resourcesEventsDefaultData), resources: jsonValueExposingStateControl("resources", resourcesDefaultData), resourceName: withDefault(StringControl, trans("calendar.resourcesDefault")), - onEvent: ChangeEventHandlerControl, + onEvent: CalendarEventHandlerControl, // onDropEvent: safeDragEventHandlerControl, editable: withDefault(BoolControl, true), showEventTime: withDefault(BoolControl, true), @@ -287,6 +288,10 @@ let CalendarBasicComp = (function () { } const handleDbClick = () => { + console.log("props.events", props.events) + console.log("props.onEvent", props.onEvent) + console.log("props", props) + const event = props.events.value.find( (item: EventType) => item.id === editEvent.current?.id ) as EventType; diff --git a/client/packages/lowcoder/src/comps/controls/eventHandlerControl.tsx b/client/packages/lowcoder/src/comps/controls/eventHandlerControl.tsx index 20c600348..3a22afe71 100644 --- a/client/packages/lowcoder/src/comps/controls/eventHandlerControl.tsx +++ b/client/packages/lowcoder/src/comps/controls/eventHandlerControl.tsx @@ -700,6 +700,11 @@ export const DragEventHandlerControl = eventHandlerControl([ dropEvent, ] as const); +export const CalendarEventHandlerControl = eventHandlerControl([ + changeEvent, + doubleClickEvent, +] as const); + export const ElementEventHandlerControl = eventHandlerControl([ openEvent, editedEvent, From 6a1b7cc2ff299f2aee605f5fd44af65e4e2882f1 Mon Sep 17 00:00:00 2001 From: Meenam Afzal Date: Fri, 26 Jul 2024 23:46:54 +0500 Subject: [PATCH 2/3] double click handled --- .../src/comps/calendarComp/calendarComp.tsx | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/client/packages/lowcoder-comps/src/comps/calendarComp/calendarComp.tsx b/client/packages/lowcoder-comps/src/comps/calendarComp/calendarComp.tsx index 2eb7b0755..aad1032ba 100644 --- a/client/packages/lowcoder-comps/src/comps/calendarComp/calendarComp.tsx +++ b/client/packages/lowcoder-comps/src/comps/calendarComp/calendarComp.tsx @@ -46,7 +46,9 @@ import { CalendarDeleteIcon, Tooltip, useMergeCompStyles, -} from "lowcoder-sdk"; + EditorContext, + CompNameContext, +} from 'lowcoder-sdk'; import { DefaultWithFreeViewOptions, @@ -121,6 +123,12 @@ let CalendarBasicComp = (function () { currentFreeView?: string; currentPremiumView?: string; }, dispatch: any) => { + + const comp = useContext(EditorContext).getUICompByName( + useContext(CompNameContext) + ); + const onEventVal = comp?.toJsonValue().comp.onEvent; + const theme = useContext(ThemeContext); const ref = createRef(); @@ -288,10 +296,6 @@ let CalendarBasicComp = (function () { } const handleDbClick = () => { - console.log("props.events", props.events) - console.log("props.onEvent", props.onEvent) - console.log("props", props) - const event = props.events.value.find( (item: EventType) => item.id === editEvent.current?.id ) as EventType; @@ -308,7 +312,17 @@ let CalendarBasicComp = (function () { }; showModal(eventInfo, true); } else { - showModal(editEvent.current, false); + if (onEventVal) { + onEventVal.forEach((event:any) => { + if (event.name === 'doubleClick') { + props.onEvent('doubleClick') + } else { + showModal(editEvent.current as EventType, false); + } + }); + } else { + showModal(editEvent.current, false); + } } }; @@ -438,7 +452,6 @@ let CalendarBasicComp = (function () { props.onDropEvent("dropEvent"); } }; - return ( Date: Mon, 29 Jul 2024 19:43:32 +0500 Subject: [PATCH 3/3] finnal tweaks --- .../src/comps/calendarComp/calendarComp.tsx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/client/packages/lowcoder-comps/src/comps/calendarComp/calendarComp.tsx b/client/packages/lowcoder-comps/src/comps/calendarComp/calendarComp.tsx index aad1032ba..180eba170 100644 --- a/client/packages/lowcoder-comps/src/comps/calendarComp/calendarComp.tsx +++ b/client/packages/lowcoder-comps/src/comps/calendarComp/calendarComp.tsx @@ -312,16 +312,11 @@ let CalendarBasicComp = (function () { }; showModal(eventInfo, true); } else { - if (onEventVal) { - onEventVal.forEach((event:any) => { - if (event.name === 'doubleClick') { - props.onEvent('doubleClick') - } else { - showModal(editEvent.current as EventType, false); - } - }); + if (onEventVal && onEventVal.some((e: any) => e.name === 'doubleClick')) { + // Check if 'doubleClick' is included in the array + props.onEvent('doubleClick'); } else { - showModal(editEvent.current, false); + showModal(editEvent.current as EventType, false); } } };