Skip to content

Commit

Permalink
Add setting "Click day to create event" vs "Click to open day" (in mo…
Browse files Browse the repository at this point in the history
…nth view) (#495)


Co-authored-by: Davis Haupt <davis@davishaupt.com>
  • Loading branch information
marienvo and davish authored Sep 6, 2023
1 parent 9d8f866 commit a4ecfab
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/ui/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface FullCalendarSettings {
mobile: string;
};
timeFormat24h: boolean;
clickToCreateEventFromMonthView: boolean;
}

export const DEFAULT_SETTINGS: FullCalendarSettings = {
Expand All @@ -37,6 +38,7 @@ export const DEFAULT_SETTINGS: FullCalendarSettings = {
mobile: "timeGrid3Days",
},
timeFormat24h: false,
clickToCreateEventFromMonthView: true,
};

const WEEKDAYS = [
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 9 additions & 1 deletion src/ui/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a4ecfab

Please sign in to comment.