From 8687fe14e110a59feb356a9d9efe6d7a6251e913 Mon Sep 17 00:00:00 2001 From: ahuang11 Date: Thu, 3 Oct 2024 18:34:03 -0700 Subject: [PATCH] lint --- panel/models/fullcalendar.js | 90 ++++++++++++++++-------------------- panel/widgets/calendar.py | 1 + 2 files changed, 42 insertions(+), 49 deletions(-) diff --git a/panel/models/fullcalendar.js b/panel/models/fullcalendar.js index 7904ff1e48..532d8dae93 100644 --- a/panel/models/fullcalendar.js +++ b/panel/models/fullcalendar.js @@ -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, @@ -18,7 +18,7 @@ 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, @@ -26,67 +26,59 @@ export function render({ model, el }) { 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); - }); -} \ No newline at end of file + const filteredPlugins = loadedPlugins.filter(plugin => plugin !== null) + createCalendar(filteredPlugins) + }) +} diff --git a/panel/widgets/calendar.py b/panel/widgets/calendar.py index 04083ee159..9b93bc8203 100644 --- a/panel/widgets/calendar.py +++ b/panel/widgets/calendar.py @@ -1,4 +1,5 @@ import datetime + from pathlib import Path import param