2022-10-12 02:36:11 -04:00
|
|
|
import '@fullcalendar/core';
|
2022-10-14 11:41:01 -04:00
|
|
|
import { CalendarOptions, EventContentArg } from '@fullcalendar/core';
|
2022-10-14 11:45:33 -04:00
|
|
|
import { ResourceLabelContentArg } from '@fullcalendar/resource-common';
|
2022-10-12 02:36:11 -04:00
|
|
|
import timeGridPlugin from '@fullcalendar/timegrid';
|
|
|
|
import resourceTimelinePlugin from '@fullcalendar/resource-timeline';
|
2022-10-14 11:41:01 -04:00
|
|
|
import { createElement } from 'preact';
|
2022-10-12 02:36:11 -04:00
|
|
|
|
2022-10-12 02:10:52 -04:00
|
|
|
import { common_calendarOptions, main } from './common';
|
2021-11-15 16:43:54 -05:00
|
|
|
|
2021-11-17 15:57:47 -05:00
|
|
|
import './index.html';
|
2021-11-15 16:43:54 -05:00
|
|
|
|
2022-10-12 02:36:11 -04:00
|
|
|
const calendarOptions: CalendarOptions = {
|
|
|
|
...common_calendarOptions,
|
|
|
|
plugins: [
|
|
|
|
...(common_calendarOptions.plugins ?? []),
|
|
|
|
timeGridPlugin,
|
|
|
|
resourceTimelinePlugin,
|
|
|
|
],
|
|
|
|
headerToolbar: {
|
|
|
|
start: 'resourceTimeline,timeGridWeek',
|
|
|
|
center: 'title',
|
|
|
|
end: 'prev,next today',
|
|
|
|
},
|
|
|
|
buttonText: {
|
|
|
|
resourceTimeline: 'day',
|
|
|
|
},
|
|
|
|
initialView: 'resourceTimeline',
|
2022-10-14 11:45:33 -04:00
|
|
|
resourceLabelContent: (
|
|
|
|
arg: ResourceLabelContentArg,
|
|
|
|
h: typeof createElement
|
|
|
|
) => {
|
|
|
|
const calendar = arg.resource.extendedProps.calendar;
|
|
|
|
if (calendar) {
|
|
|
|
const embed_link = `https://calendar.google.com/calendar/embed?ctz=America%2FNew_York&src=${calendar}`;
|
|
|
|
const ical_link = `https://calendar.google.com/calendar/ical/${calendar}/public/basic.ics`;
|
|
|
|
return h(
|
|
|
|
'span',
|
|
|
|
null,
|
|
|
|
h('a', { href: embed_link }, arg.resource.title),
|
|
|
|
' ',
|
|
|
|
h('a', { href: ical_link }, ' [iCal 📅]')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2022-10-14 11:41:01 -04:00
|
|
|
eventContent: (arg: EventContentArg, h: typeof createElement) => {
|
2022-10-12 02:36:11 -04:00
|
|
|
if (arg.view.type != 'resourceTimeline') {
|
|
|
|
let resources = arg.event
|
|
|
|
.getResources()
|
2022-10-14 11:41:01 -04:00
|
|
|
.map((resource) => resource.id.trim())
|
2022-10-12 02:36:11 -04:00
|
|
|
.join('; ');
|
2022-10-14 11:41:01 -04:00
|
|
|
return h(
|
|
|
|
'div',
|
|
|
|
{ class: 'fc-event-main' },
|
|
|
|
h(
|
|
|
|
'div',
|
|
|
|
{ class: 'fc-event-main-frame' },
|
|
|
|
h('div', { class: 'fc-event-time' }, arg.timeText),
|
|
|
|
h(
|
|
|
|
'div',
|
|
|
|
{ class: 'fc-event-title-container' },
|
|
|
|
h(
|
|
|
|
'div',
|
|
|
|
{ class: 'fc-event-title fc-sticky' },
|
|
|
|
`${resources}: ${arg.event.title}`
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2022-10-12 02:36:11 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
main(calendarOptions, true);
|