Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
refactor(calendar): dedicated method for building event content
Elian Doraneea141225d6c
diff --git a/src/public/app/widgets/view_widgets/calendar_view.ts b/src/public/app/widgets/view_widgets/calendar_view.tsindex def38b5475..c9c7257139 100644--- a/src/public/app/widgets/view_widgets/calendar_view.ts+++ b/src/public/app/widgets/view_widgets/calendar_view.ts@@ -155,28 +155,7 @@ export default class CalendarView extends ViewMode {locale: await CalendarView.#getLocale(),height: "100%",nowIndicator: true,- eventContent: (e) => {- let html = "";- const { iconClass, promotedAttributes } = e.event.extendedProps;-- // Title and icon- if (iconClass) {- html += `<span class="${iconClass}"></span> `;- }- html += utils.escapeHtml(e.event.title);-- // Promoted attributes- if (promotedAttributes) {- for (const [name, value] of promotedAttributes) {- html += `\- <div class="promoted-attribute">- <span class="promoted-attribute-name">${name}</span>: <span class="promoted-attribute-value">${value}</span>- </div>`;- }- }-- return { html };- },+ eventContent: this.#buildEventContent,dateClick: async (e) => {if (!this.isCalendarRoot) {return;@@ -199,6 +178,29 @@ export default class CalendarView extends ViewMode {return this.$root;}+ #buildEventContent(e: EventDropArg) {+ let html = "";+ const { iconClass, promotedAttributes } = e.event.extendedProps;++ // Title and icon+ if (iconClass) {+ html += `<span class="${iconClass}"></span> `;+ }+ html += utils.escapeHtml(e.event.title);++ // Promoted attributes+ if (promotedAttributes) {+ for (const [name, value] of promotedAttributes) {+ html += `\+ <div class="promoted-attribute">+ <span class="promoted-attribute-name">${name}</span>: <span class="promoted-attribute-value">${value}</span>+ </div>`;+ }+ }++ return { html };+ }+static async #getLocale() {const locale = options.get("locale");