mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-30 03:32:26 +08:00
feat(calendar_view): allow rendering by custom attribute
This commit is contained in:
parent
8111352300
commit
10b2d19710
@ -1,6 +1,7 @@
|
|||||||
import type { EventSourceInput } from "@fullcalendar/core";
|
import type { EventSourceInput } from "@fullcalendar/core";
|
||||||
import froca from "../../services/froca.js";
|
import froca from "../../services/froca.js";
|
||||||
import ViewMode, { type ViewModeArgs } from "./view_mode.js";
|
import ViewMode, { type ViewModeArgs } from "./view_mode.js";
|
||||||
|
import type FNote from "../../entities/fnote.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<div class="calendar-view">
|
<div class="calendar-view">
|
||||||
@ -58,12 +59,14 @@ export default class CalendarView extends ViewMode {
|
|||||||
|
|
||||||
for (const note of notes) {
|
for (const note of notes) {
|
||||||
const startDate = note.getAttributeValue("label", "startDate");
|
const startDate = note.getAttributeValue("label", "startDate");
|
||||||
|
const customTitle = note.getAttributeValue("label", "calendar:title");
|
||||||
|
|
||||||
if (!startDate) {
|
if (!startDate) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const eventData: typeof events[0] = {
|
const eventData: typeof events[0] = {
|
||||||
title: note.title,
|
title: CalendarView.#parseCustomTitle(customTitle, note),
|
||||||
start: startDate
|
start: startDate
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -80,4 +83,15 @@ export default class CalendarView extends ViewMode {
|
|||||||
return events;
|
return events;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static #parseCustomTitle(customTitleValue: string | null, note: FNote) {
|
||||||
|
if (customTitleValue && customTitleValue.startsWith("#")) {
|
||||||
|
const labelValue = note.getAttributeValue("label", customTitleValue.substring(1));
|
||||||
|
if (labelValue) {
|
||||||
|
return labelValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return note.title;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user