diff --git a/src/calendar-app/calendar/view/CalendarAgendaView.ts b/src/calendar-app/calendar/view/CalendarAgendaView.ts index a16b1fd2d7a2..c483c2cca387 100644 --- a/src/calendar-app/calendar/view/CalendarAgendaView.ts +++ b/src/calendar-app/calendar/view/CalendarAgendaView.ts @@ -16,7 +16,7 @@ import { DaySelector } from "../gui/day-selector/DaySelector.js" import { CalendarEventPreviewViewModel } from "../gui/eventpopup/CalendarEventPreviewViewModel.js" import { EventDetailsView } from "./EventDetailsView.js" import { getElementId, getListId } from "../../../common/api/common/utils/EntityUtils.js" -import { isAllDayEvent } from "../../../common/api/common/utils/CommonCalendarUtils.js" +import { isAllDayEvent, setNextHalfHour } from "../../../common/api/common/utils/CommonCalendarUtils.js" import { CalendarTimeIndicator } from "./CalendarTimeIndicator.js" import { Time } from "../../../common/calendar/date/Time.js" import { DaysToEvents } from "../../../common/calendar/date/CalendarEventsRepository.js" @@ -50,7 +50,7 @@ export type CalendarAgendaViewAttrs = { scrollPosition: number onScrollPositionChange: (newPosition: number) => unknown onViewChanged: (vnode: VnodeDOM) => unknown - onCreateEvent?: () => unknown + onNewEvent: (date: Date | null) => unknown } export class CalendarAgendaView implements Component { @@ -188,7 +188,12 @@ export class CalendarAgendaView implements Component { color: theme.list_message_bg, bottomContent: m(MainCreateButton, { label: "newEvent_action", - click: () => attrs.onCreateEvent?.(), + click: (e: MouseEvent) => { + let newDate = new Date(attrs.selectedDate) + attrs.onNewEvent(setNextHalfHour(newDate)) + + e.preventDefault() + }, class: "mt-s", }), }) diff --git a/src/calendar-app/calendar/view/CalendarView.ts b/src/calendar-app/calendar/view/CalendarView.ts index 14ae4a83a60e..ab29d62ada18 100644 --- a/src/calendar-app/calendar/view/CalendarView.ts +++ b/src/calendar-app/calendar/view/CalendarView.ts @@ -306,7 +306,7 @@ export class CalendarView extends BaseTopLevelView implements TopLevelView this.viewModel.setScrollPosition(newPosition), onViewChanged: (vnode) => this.viewModel.setViewParameters(vnode.dom as HTMLElement), - onCreateEvent: () => this.createNewEventDialog(), + onNewEvent: (date) => this.createNewEventDialog(date), } satisfies CalendarAgendaViewAttrs), })