mirror of
https://github.com/wekan/wekan.git
synced 2026-02-26 09:54:08 +01:00
Use template-bound autorun in wekan-fullcalendar to prevent Blaze current view errors
This commit is contained in:
parent
2fe490ec3d
commit
8dafc774d8
1 changed files with 12 additions and 12 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import { Template } from 'meteor/templating';
|
||||
import { Tracker } from 'meteor/tracker';
|
||||
|
||||
const FullCalendarCore = require('@fullcalendar/core/main.cjs.js');
|
||||
const FullCalendarDayGrid = require('@fullcalendar/daygrid/main.cjs.js');
|
||||
|
|
@ -9,9 +8,10 @@ const FullCalendarTimeGrid = require('@fullcalendar/timegrid/main.cjs.js');
|
|||
const FullCalendarLocalesAll = require('@fullcalendar/core/locales-all.js');
|
||||
|
||||
Template.fullcalendar.onRendered(function () {
|
||||
const instance = this;
|
||||
const container = this.find('div');
|
||||
|
||||
this.autorunHandle = Tracker.autorun(() => {
|
||||
this.autorunHandle = this.autorun(() => {
|
||||
const data = Template.currentData() || {};
|
||||
let preservedViewType = null;
|
||||
let preservedDate = null;
|
||||
|
|
@ -39,16 +39,16 @@ Template.fullcalendar.onRendered(function () {
|
|||
options.locales = FullCalendarLocalesAll.default;
|
||||
}
|
||||
|
||||
if (this.calendar) {
|
||||
if (instance.calendar) {
|
||||
// Keep the user's current view/date when reactive data updates.
|
||||
if (this.calendar.view && this.calendar.view.type) {
|
||||
preservedViewType = this.calendar.view.type;
|
||||
if (instance.calendar.view && instance.calendar.view.type) {
|
||||
preservedViewType = instance.calendar.view.type;
|
||||
}
|
||||
if (this.calendar.getDate) {
|
||||
preservedDate = this.calendar.getDate();
|
||||
if (instance.calendar.getDate) {
|
||||
preservedDate = instance.calendar.getDate();
|
||||
}
|
||||
this.calendar.destroy();
|
||||
this.calendar = null;
|
||||
instance.calendar.destroy();
|
||||
instance.calendar = null;
|
||||
}
|
||||
|
||||
if (preservedViewType && !options.initialView) {
|
||||
|
|
@ -58,7 +58,7 @@ Template.fullcalendar.onRendered(function () {
|
|||
options.initialDate = preservedDate;
|
||||
}
|
||||
|
||||
this.calendar = new FullCalendarCore.Calendar(container, {
|
||||
instance.calendar = new FullCalendarCore.Calendar(container, {
|
||||
plugins: [
|
||||
FullCalendarDayGrid.default,
|
||||
FullCalendarInteraction.default,
|
||||
|
|
@ -69,8 +69,8 @@ Template.fullcalendar.onRendered(function () {
|
|||
});
|
||||
|
||||
// Allow callers to manually access and refetch without jQuery plugin API.
|
||||
container._wekanCalendar = this.calendar;
|
||||
this.calendar.render();
|
||||
container._wekanCalendar = instance.calendar;
|
||||
instance.calendar.render();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue