Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 committed Oct 4, 2024
1 parent 458f8ed commit 8687fe1
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 49 deletions.
90 changes: 41 additions & 49 deletions panel/models/fullcalendar.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Calendar } from '@fullcalendar/core';
import {Calendar} from "@fullcalendar/core"

export function render({ model, el }) {
export function render({model, el}) {
function createCalendar(plugins) {
let calendar = new Calendar(el, {
const calendar = new Calendar(el, {
businessHours: model.business_hours,
buttonIcons: model.button_icons,
buttonText: model.button_text,
Expand All @@ -18,75 +18,67 @@ export function render({ model, el }) {
initialView: model.initial_view,
multiMonthMaxColumns: model.multi_month_max_columns,
nowIndicator: model.now_indicator,
plugins: plugins,
plugins,
showNonCurrentDates: model.show_non_current_dates,
stickyFooterScrollbar: model.sticky_footer_scrollbar,
stickyHeaderDates: model.sticky_header_dates,
titleFormat: model.title_format,
titleRangeSeparator: model.title_range_separator,
validRange: model.valid_range,
windowResizeDelay: model.window_resize_delay,
datesSet: function (info) {
model.send_msg({ 'current_date': calendar.getDate().toISOString() });
datesSet(info) {
model.send_msg({current_date: calendar.getDate().toISOString()})
},
});
})

if (model.aspect_ratio) {
calendar.setOption('aspectRatio', model.aspect_ratio);
calendar.setOption("aspectRatio", model.aspect_ratio)
}

model.on("msg:custom", (event) => {
if (event.type === 'next') {
calendar.next();
if (event.type === "next") {
calendar.next()
} else if (event.type === "prev") {
calendar.prev()
} else if (event.type === "prevYear") {
calendar.prevYear()
} else if (event.type === "nextYear") {
calendar.nextYear()
} else if (event.type === "today") {
calendar.today()
} else if (event.type === "gotoDate") {
calendar.gotoDate(event.date)
} else if (event.type === "incrementDate") {
calendar.incrementDate(event.increment)
} else if (event.type === "updateSize") {
calendar.updateSize()
} else if (event.type === "updateOption") {
calendar.setOption(event.key, event.value)
}
else if (event.type === 'prev') {
calendar.prev();
}
else if (event.type === 'prevYear') {
calendar.prevYear();
}
else if (event.type === 'nextYear') {
calendar.nextYear();
}
else if (event.type === 'today') {
calendar.today();
}
else if (event.type === 'gotoDate') {
calendar.gotoDate(event.date);
}
else if (event.type === 'incrementDate') {
calendar.incrementDate(event.increment);
}
else if (event.type === 'updateSize') {
calendar.updateSize();
}
else if (event.type === 'updateOption') {
calendar.setOption(event.key, event.value);
}
});
calendar.render();
})
calendar.render()
}

let plugins = [];
const plugins = []
function loadPluginIfNeeded(viewName, pluginName) {
if (model.initial_view.startsWith(viewName) ||
(model.header_toolbar && Object.values(model.header_toolbar).some(v => v.includes(viewName))) ||
(model.footer_toolbar && Object.values(model.footer_toolbar).some(v => v.includes(viewName)))) {
return import(`@fullcalendar/${pluginName}`).then(plugin => {
plugins.push(plugin.default);
return plugin.default;
});
plugins.push(plugin.default)
return plugin.default
})
}
return Promise.resolve(null);
return Promise.resolve(null)
}

Promise.all([
loadPluginIfNeeded('dayGrid', 'daygrid'),
loadPluginIfNeeded('timeGrid', 'timegrid'),
loadPluginIfNeeded('list', 'list'),
loadPluginIfNeeded('multiMonth', 'multimonth')
loadPluginIfNeeded("dayGrid", "daygrid"),
loadPluginIfNeeded("timeGrid", "timegrid"),
loadPluginIfNeeded("list", "list"),
loadPluginIfNeeded("multiMonth", "multimonth"),
]).then(loadedPlugins => {
const filteredPlugins = loadedPlugins.filter(plugin => plugin !== null);
createCalendar(filteredPlugins);
});
}
const filteredPlugins = loadedPlugins.filter(plugin => plugin !== null)
createCalendar(filteredPlugins)
})
}
1 change: 1 addition & 0 deletions panel/widgets/calendar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime

from pathlib import Path

import param
Expand Down

0 comments on commit 8687fe1

Please sign in to comment.