@@ -26,6 +26,7 @@ import { default as Form } from "antd/es/form";
26
26
import { default as Input } from "antd/es/input" ;
27
27
import { trans , getCalendarLocale } from "../../i18n/comps" ;
28
28
import { createRef , useContext , useRef , useState } from "react" ;
29
+ import resourceTimelinePlugin from "@fullcalendar/resource-timeline" ;
29
30
import FullCalendar from "@fullcalendar/react" ;
30
31
import dayGridPlugin from "@fullcalendar/daygrid" ;
31
32
import timeGridPlugin from "@fullcalendar/timegrid" ;
@@ -66,8 +67,9 @@ const childrenMap = {
66
67
dayMaxEvents : withDefault ( NumberControl , 2 ) ,
67
68
eventMaxStack : withDefault ( NumberControl , 0 ) ,
68
69
style : styleControl ( CalendarStyle ) ,
70
+ licenceKey : withDefault ( StringControl , "" ) ,
69
71
} ;
70
-
72
+
71
73
let CalendarBasicComp = ( function ( ) {
72
74
return new UICompBuilder ( childrenMap , ( props ) => {
73
75
const theme = useContext ( ThemeContext ) ;
@@ -83,7 +85,9 @@ let CalendarBasicComp = (function () {
83
85
start : dayjs ( item . start , DateParser ) . format ( ) ,
84
86
end : dayjs ( item . end , DateParser ) . format ( ) ,
85
87
allDay : item . allDay ,
86
- color : isValidColor ( item . color || "" ) ? item . color : theme ?. theme ?. primary ,
88
+ color : isValidColor ( item . color || "" )
89
+ ? item . color
90
+ : theme ?. theme ?. primary ,
87
91
...( item . groupId ? { groupId : item . groupId } : null ) ,
88
92
} ;
89
93
} ) ;
@@ -104,8 +108,13 @@ let CalendarBasicComp = (function () {
104
108
function renderEventContent ( eventInfo : EventContentArg ) {
105
109
const isList = eventInfo . view . type === "listWeek" ;
106
110
let sizeClass = "" ;
107
- if ( [ ViewType . WEEK , ViewType . DAY ] . includes ( eventInfo . view . type as ViewType ) ) {
108
- const duration = dayjs ( eventInfo . event . end ) . diff ( dayjs ( eventInfo . event . start ) , "minutes" ) ;
111
+ if (
112
+ [ ViewType . WEEK , ViewType . DAY ] . includes ( eventInfo . view . type as ViewType )
113
+ ) {
114
+ const duration = dayjs ( eventInfo . event . end ) . diff (
115
+ dayjs ( eventInfo . event . start ) ,
116
+ "minutes"
117
+ ) ;
109
118
if ( duration <= 30 || eventInfo . event . allDay ) {
110
119
sizeClass = "small" ;
111
120
} else if ( duration <= 60 ) {
@@ -137,7 +146,9 @@ let CalendarBasicComp = (function () {
137
146
onClick = { ( e ) => {
138
147
e . stopPropagation ( ) ;
139
148
props . onEvent ( "change" ) ;
140
- const event = events . filter ( ( item : EventType ) => item . id !== eventInfo . event . id ) ;
149
+ const event = events . filter (
150
+ ( item : EventType ) => item . id !== eventInfo . event . id
151
+ ) ;
141
152
props . events . onChange ( event ) ;
142
153
} }
143
154
onMouseDown = { ( e ) => {
@@ -195,7 +206,9 @@ let CalendarBasicComp = (function () {
195
206
} ;
196
207
197
208
const showModal = ( event : EventType , ifEdit : boolean ) => {
198
- const modalTitle = ifEdit ? trans ( "calendar.editEvent" ) : trans ( "calendar.creatEvent" ) ;
209
+ const modalTitle = ifEdit
210
+ ? trans ( "calendar.editEvent" )
211
+ : trans ( "calendar.creatEvent" ) ;
199
212
form && form . setFieldsValue ( event ) ;
200
213
const eventId = editEvent . current ?. id ;
201
214
CustomModal . confirm ( {
@@ -209,14 +222,18 @@ let CalendarBasicComp = (function () {
209
222
</ Tooltip >
210
223
}
211
224
name = "id"
212
- rules = { [ { required : true , message : trans ( "calendar.eventIdRequire" ) } ] }
225
+ rules = { [
226
+ { required : true , message : trans ( "calendar.eventIdRequire" ) } ,
227
+ ] }
213
228
>
214
229
< Input />
215
230
</ Form . Item >
216
231
< Form . Item
217
232
label = { trans ( "calendar.eventName" ) }
218
233
name = "title"
219
- rules = { [ { required : true , message : trans ( "calendar.eventNameRequire" ) } ] }
234
+ rules = { [
235
+ { required : true , message : trans ( "calendar.eventNameRequire" ) } ,
236
+ ] }
220
237
>
221
238
< Input />
222
239
</ Form . Item >
@@ -239,9 +256,13 @@ let CalendarBasicComp = (function () {
239
256
form . submit ( ) ;
240
257
return form . validateFields ( ) . then ( ( ) => {
241
258
const { id, groupId, color, title = "" } = form . getFieldsValue ( ) ;
242
- const idExist = props . events . value . findIndex ( ( item : EventType ) => item . id === id ) ;
259
+ const idExist = props . events . value . findIndex (
260
+ ( item : EventType ) => item . id === id
261
+ ) ;
243
262
if ( idExist > - 1 && id !== eventId ) {
244
- form . setFields ( [ { name : "id" , errors : [ trans ( "calendar.eventIdExist" ) ] } ] ) ;
263
+ form . setFields ( [
264
+ { name : "id" , errors : [ trans ( "calendar.eventIdExist" ) ] } ,
265
+ ] ) ;
245
266
throw new Error ( ) ;
246
267
}
247
268
if ( ifEdit ) {
@@ -306,7 +327,14 @@ let CalendarBasicComp = (function () {
306
327
locale = { getCalendarLocale ( ) }
307
328
locales = { allLocales }
308
329
firstDay = { Number ( firstDay ) }
309
- plugins = { [ dayGridPlugin , timeGridPlugin , interactionPlugin , listPlugin , momentPlugin ] }
330
+ plugins = { [
331
+ dayGridPlugin ,
332
+ timeGridPlugin ,
333
+ interactionPlugin ,
334
+ listPlugin ,
335
+ momentPlugin ,
336
+ resourceTimelinePlugin ,
337
+ ] }
310
338
headerToolbar = { headerToolbar }
311
339
moreLinkClick = { ( info ) => {
312
340
let left = 0 ;
@@ -319,15 +347,19 @@ let CalendarBasicComp = (function () {
319
347
}
320
348
} else {
321
349
if ( info . allDay ) {
322
- left = ele . offsetParent ?. parentElement ?. parentElement ?. offsetLeft || 0 ;
350
+ left =
351
+ ele . offsetParent ?. parentElement ?. parentElement ?. offsetLeft ||
352
+ 0 ;
323
353
} else {
324
354
left =
325
- ele . offsetParent ?. parentElement ?. parentElement ?. parentElement ?. offsetLeft || 0 ;
355
+ ele . offsetParent ?. parentElement ?. parentElement ?. parentElement
356
+ ?. offsetLeft || 0 ;
326
357
}
327
358
}
328
359
setLeft ( left ) ;
329
360
} }
330
361
buttonText = { buttonText }
362
+ schedulerLicenseKey = { props . licenceKey . value }
331
363
views = { views }
332
364
eventClassNames = { ( ) => ( ! showEventTime ? "no-time" : "" ) }
333
365
slotLabelFormat = { slotLabelFormat }
@@ -346,7 +378,9 @@ let CalendarBasicComp = (function () {
346
378
eventContent = { renderEventContent }
347
379
select = { ( info ) => handleCreate ( info ) }
348
380
eventClick = { ( info ) => {
349
- const event = events . find ( ( item : EventType ) => item . id === info . event . id ) ;
381
+ const event = events . find (
382
+ ( item : EventType ) => item . id === info . event . id
383
+ ) ;
350
384
editEvent . current = event ;
351
385
setTimeout ( ( ) => {
352
386
editEvent . current = undefined ;
@@ -387,12 +421,19 @@ let CalendarBasicComp = (function () {
387
421
. setPropertyViewFn ( ( children ) => {
388
422
return (
389
423
< >
390
- < Section name = { sectionNames . basic } > { children . events . propertyView ( { } ) } </ Section >
391
- < Section name = { sectionNames . interaction } > { children . onEvent . getPropertyView ( ) } </ Section >
424
+ < Section name = { sectionNames . basic } >
425
+ { children . events . propertyView ( { } ) }
426
+ </ Section >
427
+ < Section name = { sectionNames . interaction } >
428
+ { children . licenceKey . propertyView ( {
429
+ label : trans ( "calendar.licence" ) ,
430
+ } ) }
431
+ { children . onEvent . getPropertyView ( ) }
432
+ </ Section >
392
433
< Section name = { sectionNames . advanced } >
393
434
{ children . editable . propertyView ( {
394
- label : trans ( "calendar.editable" ) ,
395
- } ) }
435
+ label : trans ( "calendar.editable" ) ,
436
+ } ) }
396
437
{ children . defaultDate . propertyView ( {
397
438
label : trans ( "calendar.defaultDate" ) ,
398
439
tooltip : trans ( "calendar.defaultDateTooltip" ) ,
@@ -424,8 +465,12 @@ let CalendarBasicComp = (function () {
424
465
tooltip : trans ( "calendar.eventMaxStackTooltip" ) ,
425
466
} ) }
426
467
</ Section >
427
- < Section name = { sectionNames . layout } > { hiddenPropertyView ( children ) } </ Section >
428
- < Section name = { sectionNames . style } > { children . style . getPropertyView ( ) } </ Section >
468
+ < Section name = { sectionNames . layout } >
469
+ { hiddenPropertyView ( children ) }
470
+ </ Section >
471
+ < Section name = { sectionNames . style } >
472
+ { children . style . getPropertyView ( ) }
473
+ </ Section >
429
474
</ >
430
475
) ;
431
476
} )
0 commit comments