From a4ecfab099c398111056fe98bd44ab8c9df46e01 Mon Sep 17 00:00:00 2001 From: Marien van Overbeek Date: Wed, 6 Sep 2023 15:27:00 +0200 Subject: [PATCH] Add setting "Click day to create event" vs "Click to open day" (in month view) (#495) Co-authored-by: Davis Haupt --- src/ui/settings.ts | 13 +++++++++++++ src/ui/view.ts | 10 +++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/ui/settings.ts b/src/ui/settings.ts index 472ad38..e2df8d1 100644 --- a/src/ui/settings.ts +++ b/src/ui/settings.ts @@ -26,6 +26,7 @@ export interface FullCalendarSettings { mobile: string; }; timeFormat24h: boolean; + clickToCreateEventFromMonthView: boolean; } export const DEFAULT_SETTINGS: FullCalendarSettings = { @@ -37,6 +38,7 @@ export const DEFAULT_SETTINGS: FullCalendarSettings = { mobile: "timeGrid3Days", }, timeFormat24h: false, + clickToCreateEventFromMonthView: true, }; const WEEKDAYS = [ @@ -231,6 +233,17 @@ export class FullCalendarSettingTab extends PluginSettingTab { }); }); + new Setting(containerEl) + .setName("Click on a day in month view to create event") + .setDesc("Switch off to open day view on click instead.") + .addToggle((toggle) => { + toggle.setValue(this.plugin.settings.clickToCreateEventFromMonthView); + toggle.onChange(async (val) => { + this.plugin.settings.clickToCreateEventFromMonthView = val; + await this.plugin.saveSettings(); + }); + }); + containerEl.createEl("h2", { text: "Manage Calendars" }); addCalendarButton( this.app, diff --git a/src/ui/view.ts b/src/ui/view.ts index 2bc033e..8a70ee7 100644 --- a/src/ui/view.ts +++ b/src/ui/view.ts @@ -160,7 +160,15 @@ export class CalendarView extends ItemView { allDay ); try { - launchCreateModal(this.plugin, partialEvent); + if ( + this.plugin.settings.clickToCreateEventFromMonthView || + viewType !== "dayGridMonth" + ) { + launchCreateModal(this.plugin, partialEvent); + } else { + this.fullCalendarView?.changeView("timeGridDay"); + this.fullCalendarView?.gotoDate(start); + } } catch (e) { if (e instanceof Error) { console.error(e);