Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3d1e09e

Browse files
update data on events drag/drop
1 parent62c5dec commit3d1e09e

File tree

2 files changed

+24
-35
lines changed

2 files changed

+24
-35
lines changed

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

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import adaptivePlugin from "@fullcalendar/adaptive";
1212
importdayGridPluginfrom"@fullcalendar/daygrid";
1313
importmultiMonthPluginfrom'@fullcalendar/multimonth';
1414
importtimeGridPluginfrom"@fullcalendar/timegrid";
15-
importinteractionPluginfrom"@fullcalendar/interaction";
15+
importinteractionPlugin,{EventResizeDoneArg}from"@fullcalendar/interaction";
1616
importlistPluginfrom"@fullcalendar/list";
1717
importallLocalesfrom"@fullcalendar/core/locales-all";
18-
import{EventContentArg,DateSelectArg}from"@fullcalendar/core";
18+
import{EventContentArg,DateSelectArg,EventDropArg}from"@fullcalendar/core";
1919
importmomentPluginfrom"@fullcalendar/moment";
2020

2121
importErrorBoundaryfrom"./errorBoundary";
@@ -83,6 +83,7 @@ import {
8383
resourceTimeGridHeaderToolbar,
8484
}from"./calendarConstants";
8585
import{EventOptionControl}from"./eventOptionsControl";
86+
import{EventImpl}from"@fullcalendar/core/internal";
8687

8788
functionfixOldData(oldData:any){
8889
if(!Boolean(oldData))return;
@@ -823,20 +824,34 @@ let CalendarBasicComp = (function () {
823824
showModal(event,false);
824825
},[editEvent,showModal]);
825826

826-
consthandleDrop=useCallback((eventInfo:EventType)=>{
827+
constupdateEventsOnDragOrResize=useCallback((eventInfo:EventImpl)=>{
828+
const{extendedProps, title, ...event}=eventInfo.toJSON();
829+
827830
leteventsList=[...props.events];
828831
consteventIdx=eventsList.findIndex(
829-
(item:EventType)=>item.id===eventInfo.id
832+
(item:EventType)=>item.id===event.id
830833
);
831834
if(eventIdx>-1){
832-
eventsList[eventIdx]=eventInfo;
835+
eventsList[eventIdx]={
836+
label:title,
837+
...event,
838+
...extendedProps,
839+
};
833840
handleEventDataChange(eventsList);
834841
}
842+
},[props.events,handleEventDataChange]);
843+
844+
consthandleDrop=useCallback((eventInfo:EventDropArg)=>{
845+
updateEventsOnDragOrResize(eventInfo.event);
835846

836847
if(typeofprops.onDropEvent==='function'){
837848
props.onDropEvent("dropEvent");
838849
}
839-
},[props.onDropEvent]);
850+
},[props.onDropEvent,updateEventsOnDragOrResize]);
851+
852+
consthandleResize=useCallback((eventInfo:EventResizeDoneArg)=>{
853+
updateEventsOnDragOrResize(eventInfo.event);
854+
},[props.onDropEvent,updateEventsOnDragOrResize]);
840855

841856
return(
842857
<Wrapper
@@ -854,7 +869,7 @@ let CalendarBasicComp = (function () {
854869
slotEventOverlap={false}
855870
events={events}
856871
dayHeaders={true}
857-
dayHeaderFormat={{weekday:'short',month:'numeric',day:'numeric',omitCommas:true}}
872+
//dayHeaderFormat={{ weekday: 'short', month: 'numeric', day: 'numeric', omitCommas: true }}
858873
expandRows={true}
859874
multiMonthMinWidth={250}
860875
nowIndicator={true}
@@ -944,15 +959,8 @@ let CalendarBasicComp = (function () {
944959
props.onEvent("change");
945960
}
946961
}}
947-
eventDrop={(info)=>{
948-
const{extendedProps, ...event}=info.event.toJSON();
949-
if(info.view){
950-
handleDrop({
951-
...event,
952-
...extendedProps,
953-
});
954-
}
955-
}}
962+
eventDrop={handleDrop}
963+
eventResize={handleResize}
956964
/>
957965
</ErrorBoundary>
958966
</Wrapper>

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -988,25 +988,6 @@ export const defaultEvents = [
988988
end:dayjs().hour(21).minute(30).second(0).format(DATE_TIME_FORMAT),
989989
color:"#079968",
990990
},
991-
{
992-
id:"6",
993-
label:"Coding",
994-
start:dayjs().hour(15).minute(0).second(0).format(DATE_TIME_FORMAT),
995-
end:dayjs().hour(17).minute(30).second(0).format(DATE_TIME_FORMAT),
996-
color:"#079968",
997-
backgroundColor:"#ffffff",
998-
detail:'Discuss project milestones and deliverables.',
999-
titleColor:"#000000",
1000-
detailColor:"#000000",
1001-
titleFontWeight:"normal",
1002-
titleFontStyle:"italic",
1003-
detailFontWeight:"normal",
1004-
detailFontStyle:"italic",
1005-
animation:"none",
1006-
animationDelay:"0s",
1007-
animationDuration:"0s",
1008-
animationIterationCount:"0",
1009-
},
1010991
];
1011992
exportconstresourcesEventsDefaultData=[
1012993
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp