Skip to content

Commit

Permalink
Add setting clickToCreateEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
marienvo committed Sep 3, 2023
1 parent 9d8f866 commit fd8417b
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;
clickToCreateEvent: boolean;
}

export const DEFAULT_SETTINGS: FullCalendarSettings = {
Expand All @@ -37,6 +38,7 @@ export const DEFAULT_SETTINGS: FullCalendarSettings = {
mobile: "timeGrid3Days",
},
timeFormat24h: false,
clickToCreateEvent: 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.clickToCreateEvent);
toggle.onChange(async (val) => {
this.plugin.settings.clickToCreateEvent = 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.clickToCreateEvent ||
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 fd8417b

Please sign in to comment.