mirror of
https://github.com/zadam/trilium.git
synced 2025-10-21 07:38:53 +02:00
feat(calendar_view): render notes by their start date
This commit is contained in:
parent
4dc2803cc6
commit
64b446315d
@ -1,3 +1,5 @@
|
|||||||
|
import type { EventSourceInput } from "@fullcalendar/core";
|
||||||
|
import froca from "../../services/froca.js";
|
||||||
import ViewMode, { type ViewModeArgs } from "./view_mode.js";
|
import ViewMode, { type ViewModeArgs } from "./view_mode.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
@ -25,12 +27,14 @@ export default class CalendarView extends ViewMode {
|
|||||||
|
|
||||||
private $root: JQuery<HTMLElement>;
|
private $root: JQuery<HTMLElement>;
|
||||||
private $calendarContainer: JQuery<HTMLElement>;
|
private $calendarContainer: JQuery<HTMLElement>;
|
||||||
|
private noteIds: string[];
|
||||||
|
|
||||||
constructor(args: ViewModeArgs) {
|
constructor(args: ViewModeArgs) {
|
||||||
super(args);
|
super(args);
|
||||||
|
|
||||||
this.$root = $(TPL);
|
this.$root = $(TPL);
|
||||||
this.$calendarContainer = this.$root.find(".calendar-container");
|
this.$calendarContainer = this.$root.find(".calendar-container");
|
||||||
|
this.noteIds = args.noteIds;
|
||||||
args.$parent.append(this.$root);
|
args.$parent.append(this.$root);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,11 +44,32 @@ export default class CalendarView extends ViewMode {
|
|||||||
|
|
||||||
const calendar = new Calendar(this.$calendarContainer[0], {
|
const calendar = new Calendar(this.$calendarContainer[0], {
|
||||||
plugins: [ dayGridPlugin ],
|
plugins: [ dayGridPlugin ],
|
||||||
initialView: "dayGridMonth"
|
initialView: "dayGridMonth",
|
||||||
|
events: await CalendarView.#buildEvents(this.noteIds)
|
||||||
});
|
});
|
||||||
calendar.render();
|
calendar.render();
|
||||||
|
|
||||||
return this.$root;
|
return this.$root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async #buildEvents(noteIds: string[]) {
|
||||||
|
const notes = await froca.getNotes(noteIds);
|
||||||
|
const events: EventSourceInput = [];
|
||||||
|
|
||||||
|
for (const note of notes) {
|
||||||
|
const startDate = note.getAttributeValue("label", "startDate");
|
||||||
|
|
||||||
|
if (!startDate) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
events.push({
|
||||||
|
title: note.title,
|
||||||
|
start: startDate
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return events;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user