Skip to content

Commit

Permalink
New event made through agenda view new event has next half hour time
Browse files Browse the repository at this point in the history
  • Loading branch information
wrdhub committed Jul 25, 2024
1 parent 2440d60 commit 0f0ba8c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/calendar-app/calendar/view/CalendarAgendaView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<CalendarAgendaViewAttrs> {
Expand Down Expand Up @@ -188,7 +188,12 @@ export class CalendarAgendaView implements Component<CalendarAgendaViewAttrs> {
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",
}),
})
Expand Down
2 changes: 1 addition & 1 deletion src/calendar-app/calendar/view/CalendarView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export class CalendarView extends BaseTopLevelView implements TopLevelView<Calen
scrollPosition: this.viewModel.getScrollPosition(),
onScrollPositionChange: (newPosition: number) => this.viewModel.setScrollPosition(newPosition),
onViewChanged: (vnode) => this.viewModel.setViewParameters(vnode.dom as HTMLElement),
onCreateEvent: () => this.createNewEventDialog(),
onNewEvent: (date) => this.createNewEventDialog(date),
} satisfies CalendarAgendaViewAttrs),
})

Expand Down

0 comments on commit 0f0ba8c

Please sign in to comment.