From c902f21374d4845514b0a0bdeba127ce59fe92cc Mon Sep 17 00:00:00 2001 From: Romain Lebbadi-Breteau <romain@lebbadi.fr> Date: Sat, 12 Feb 2022 18:41:30 -0500 Subject: [PATCH] Fix calendar.js --- assets/calendar.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/assets/calendar.js b/assets/calendar.js index 8629e61a..d13c171d 100644 --- a/assets/calendar.js +++ b/assets/calendar.js @@ -10,8 +10,6 @@ // start the Stimulus application //import './bootstrap'; -import 'tui-calendar'; - var Calendar = require('tui-calendar'); /* CommonJS */ @@ -89,19 +87,21 @@ $(function () { url: "/calendar/receive", success: function (data) { var cleanedData = [] - data.forEach(function(schedule){ - if (schedule) { - schedule.start = schedule.start._date - schedule.end = schedule.end._date - scheduleIds[scheduleIds.length] = parseInt(schedule.id) - currentSchedule++ - cleanedData[cleanedData.length] = schedule - } - }) - - // console.log(currentSchedule) - - calendar.createSchedules(cleanedData) + console.log(data) + if (Array.isArray(data)) + { + data.forEach(function(schedule){ + if (schedule) { + schedule.start = schedule.start._date + schedule.end = schedule.end._date + scheduleIds[scheduleIds.length] = parseInt(schedule.id) + currentSchedule++ + cleanedData[cleanedData.length] = schedule + } + }) + + calendar.createSchedules(cleanedData) + } }, }); -- GitLab