@@ -84,6 +84,9 @@ import {
84
84
} from "./calendarConstants" ;
85
85
import { EventOptionControl } from "./eventOptionsControl" ;
86
86
import { EventImpl } from "@fullcalendar/core/internal" ;
87
+ import DatePicker from "antd/es/date-picker" ;
88
+
89
+ const DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss" ;
87
90
88
91
function fixOldData ( oldData : any ) {
89
92
if ( ! Boolean ( oldData ) ) return ;
@@ -205,6 +208,7 @@ let childrenMap: any = {
205
208
updatedEvents : stateComp < JSONObject > ( { } ) ,
206
209
insertedEvents : stateComp < JSONObject > ( { } ) ,
207
210
deletedEvents : stateComp < JSONObject > ( { } ) ,
211
+ inputFormat : withDefault ( StringControl , DATE_TIME_FORMAT ) ,
208
212
} ;
209
213
210
214
// this should ensure backwards compatibility with older versions of the SDK
@@ -245,6 +249,7 @@ let CalendarBasicComp = (function () {
245
249
modalStyle ?:any ;
246
250
showVerticalScrollbar ?:boolean ;
247
251
initialData : Array < EventType > ;
252
+ inputFormat : string ;
248
253
} , dispatch : any ) => {
249
254
const comp = useContext ( EditorContext ) ?. getUICompByName (
250
255
useContext ( CompNameContext )
@@ -531,7 +536,14 @@ let CalendarBasicComp = (function () {
531
536
const modalTitle = ifEdit
532
537
? trans ( "calendar.editEvent" )
533
538
: trans ( "calendar.creatEvent" ) ;
534
- form && form . setFieldsValue ( event ) ;
539
+ if ( form ) {
540
+ const eventData = {
541
+ ...event ,
542
+ start : Boolean ( event . start ) ? dayjs ( event . start , props . inputFormat ) : null ,
543
+ end : Boolean ( event . end ) ? dayjs ( event . end , props . inputFormat ) : null ,
544
+ }
545
+ form . setFieldsValue ( eventData )
546
+ }
535
547
const eventId = editEvent . current ?. id ;
536
548
537
549
CustomModal . confirm ( {
@@ -589,13 +601,21 @@ let CalendarBasicComp = (function () {
589
601
label = { trans ( "calendar.eventStartTime" ) }
590
602
name = "start"
591
603
>
592
- < Input />
604
+ < DatePicker
605
+ showTime
606
+ format = { props . inputFormat }
607
+ popupStyle = { { zIndex : 2050 } }
608
+ />
593
609
</ Form . Item >
594
610
< Form . Item
595
611
label = { trans ( "calendar.eventEndTime" ) }
596
612
name = "end"
597
613
>
598
- < Input />
614
+ < DatePicker
615
+ showTime
616
+ format = { props . inputFormat }
617
+ popupStyle = { { zIndex : 2050 } }
618
+ />
599
619
</ Form . Item >
600
620
< Form . Item
601
621
label = { trans ( "calendar.eventAllDay" ) }
@@ -739,7 +759,11 @@ let CalendarBasicComp = (function () {
739
759
animation,
740
760
animationDelay,
741
761
animationDuration,
742
- animationIterationCount } = form . getFieldsValue ( ) ;
762
+ animationIterationCount,
763
+ start,
764
+ end,
765
+ allDay,
766
+ } = form . getFieldsValue ( ) ;
743
767
const idExist = props . events . findIndex (
744
768
( item : EventType ) => item . id === id
745
769
) ;
@@ -757,6 +781,9 @@ let CalendarBasicComp = (function () {
757
781
label,
758
782
detail,
759
783
id,
784
+ start : dayjs ( start , DateParser ) . format ( ) ,
785
+ end : dayjs ( end , DateParser ) . format ( ) ,
786
+ allDay,
760
787
...( groupId !== undefined ? { groupId } : null ) ,
761
788
...( resourceId !== undefined ? { resourceId } : null ) ,
762
789
...( color !== undefined ? { color } : null ) ,
@@ -779,9 +806,9 @@ let CalendarBasicComp = (function () {
779
806
handleEventDataChange ( changeEvents ) ;
780
807
} else {
781
808
const createInfo = {
782
- allDay : event . allDay ,
783
- start : event . start ,
784
- end : event . end ,
809
+ allDay : allDay ,
810
+ start : dayjs ( start , DateParser ) . format ( ) ,
811
+ end : dayjs ( end , DateParser ) . format ( ) ,
785
812
id,
786
813
label,
787
814
detail,
@@ -1033,6 +1060,7 @@ let CalendarBasicComp = (function () {
1033
1060
modalStyle : { getPropertyView : ( ) => any ; } ;
1034
1061
licenseKey : { getView : ( ) => any ; propertyView : ( arg0 : { label : string ; } ) => any ; } ;
1035
1062
showVerticalScrollbar : { propertyView : ( arg0 : { label : string ; } ) => any ; } ;
1063
+ inputFormat : { propertyView : ( arg0 : { } ) => any ; } ;
1036
1064
} ) => {
1037
1065
const license = children . licenseKey . getView ( ) ;
1038
1066
@@ -1072,6 +1100,22 @@ let CalendarBasicComp = (function () {
1072
1100
{ children . eventMaxStack . propertyView ( { label : trans ( "calendar.eventMaxStack" ) , tooltip : trans ( "calendar.eventMaxStackTooltip" ) , } ) }
1073
1101
</ Section >
1074
1102
< Section name = { sectionNames . layout } >
1103
+ { children . inputFormat . propertyView ( {
1104
+ label : trans ( "calendar.inputFormat" ) ,
1105
+ placeholder : DATE_TIME_FORMAT ,
1106
+ tooltip : (
1107
+ < >
1108
+ { trans ( "calendar.reference" ) }
1109
+ < a
1110
+ href = { `https://day.js.org/docs/en/display/format` }
1111
+ target = { "_blank" }
1112
+ rel = "noreferrer"
1113
+ >
1114
+ dayjs format
1115
+ </ a >
1116
+ </ >
1117
+ ) ,
1118
+ } ) }
1075
1119
{ children . licenseKey . propertyView ( { label : trans ( "calendar.license" ) , tooltip : trans ( "calendar.licenseTooltip" ) , } ) }
1076
1120
{ license == ""
1077
1121
? children . currentFreeView . propertyView ( { label : trans ( "calendar.defaultView" ) , tooltip : trans ( "calendar.defaultViewTooltip" ) , } )
0 commit comments