mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-02 05:00:40 +08:00
feat(calendar): support missing end time
This commit is contained in:
parent
9083c18392
commit
9412cfc19f
@ -160,4 +160,17 @@ describe("Promoted attributes", () => {
|
|||||||
expect(events[0]).toMatchObject({ title: "Note 1", start: "2025-05-05T13:36:00", end: "2025-05-05T14:56:00" });
|
expect(events[0]).toMatchObject({ title: "Note 1", start: "2025-05-05T13:36:00", end: "2025-05-05T14:56:00" });
|
||||||
expect(events[1]).toMatchObject({ title: "Note 2", start: "2025-05-07T13:36:00", end: "2025-05-08T14:56:00" });
|
expect(events[1]).toMatchObject({ title: "Note 2", start: "2025-05-07T13:36:00", end: "2025-05-08T14:56:00" });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("handles start time with missing end time", async () => {
|
||||||
|
const noteIds = buildNotes([
|
||||||
|
{ title: "Note 1", "#startDate": "2025-05-05", "#startTime": "13:30" },
|
||||||
|
{ title: "Note 2", "#startDate": "2025-05-07", "#endDate": "2025-05-08", "#startTime": "13:36" },
|
||||||
|
]);
|
||||||
|
const events = await CalendarView.buildEvents(noteIds);
|
||||||
|
|
||||||
|
expect(events).toHaveLength(2);
|
||||||
|
expect(events[0]).toMatchObject({ title: "Note 1", start: "2025-05-05T13:30:00", end: "2025-05-05T13:30:00" });
|
||||||
|
expect(events[1]).toMatchObject({ title: "Note 2", start: "2025-05-07T13:36:00", end: "2025-05-08" });
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -366,8 +366,9 @@ export default class CalendarView extends ViewMode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const title of titles) {
|
for (const title of titles) {
|
||||||
|
startDate = (startTime ? `${startDate}T${startTime}:00` : startDate);
|
||||||
if (!endDate) {
|
if (!endDate) {
|
||||||
if (endTime) {
|
if (!endTime) {
|
||||||
endDate = startDate;
|
endDate = startDate;
|
||||||
} else {
|
} else {
|
||||||
const endDateOffset = CalendarView.#offsetDate(endDate ?? startDate, 1);
|
const endDateOffset = CalendarView.#offsetDate(endDate ?? startDate, 1);
|
||||||
@ -377,7 +378,6 @@ export default class CalendarView extends ViewMode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
startDate = (startTime ? `${startDate}T${startTime}:00` : startDate);
|
|
||||||
endDate = (endTime ? `${endDate}T${endTime}:00` : endDate);
|
endDate = (endTime ? `${endDate}T${endTime}:00` : endDate);
|
||||||
const eventData: EventInput = {
|
const eventData: EventInput = {
|
||||||
title: title,
|
title: title,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user