39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
import { Controller } from '@hotwired/stimulus';
|
|
import { Calendar } from '@fullcalendar/core';
|
|
import dayGridPlugin from '@fullcalendar/daygrid';
|
|
import timeGridPlugin from '@fullcalendar/timegrid';
|
|
import listPlugin from '@fullcalendar/list';
|
|
|
|
/* stimulusFetch: 'lazy' */
|
|
export default class extends Controller {
|
|
|
|
initialize() {
|
|
|
|
}
|
|
|
|
connect() {
|
|
let calendar = new Calendar(this.element, {
|
|
plugins: [ dayGridPlugin, timeGridPlugin, listPlugin ],
|
|
initialView: 'dayGridMonth',
|
|
headerToolbar: {
|
|
left: 'prev,next today',
|
|
center: 'title',
|
|
right: 'dayGridMonth,timeGridWeek,listWeek'
|
|
}
|
|
});
|
|
calendar.render();
|
|
// calendar.render();
|
|
}
|
|
|
|
// Add custom controller actions here
|
|
// fooBar() { this.fooTarget.classList.toggle(this.bazClass) }
|
|
|
|
disconnect() {
|
|
// Called anytime its element is disconnected from the DOM
|
|
// (on page change, when it's removed from or moved in the DOM, etc.)
|
|
|
|
// Here you should remove all event listeners added in "connect()"
|
|
// this.fooTarget.removeEventListener('click', this._fooBar)
|
|
}
|
|
}
|