mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-17 07:12:30 +08:00
feat(calendar): support displaying of attributes and realtions with multiple cardinality
This commit is contained in:
parent
6c1cb71c9f
commit
85917d7207
@ -138,7 +138,7 @@ export default class CalendarView extends ViewMode {
|
|||||||
|
|
||||||
// Promoted attributes
|
// Promoted attributes
|
||||||
if (promotedAttributes) {
|
if (promotedAttributes) {
|
||||||
for (const [name, value] of Object.entries(promotedAttributes)) {
|
for (const [name, value] of promotedAttributes) {
|
||||||
html += `\
|
html += `\
|
||||||
<div class="promoted-attribute">
|
<div class="promoted-attribute">
|
||||||
<span class="promoted-attribute-name">${name}</span>: <span class="promoted-attribute-value">${value}</span>
|
<span class="promoted-attribute-name">${name}</span>: <span class="promoted-attribute-value">${value}</span>
|
||||||
@ -353,7 +353,7 @@ export default class CalendarView extends ViewMode {
|
|||||||
const events: EventInput[] = [];
|
const events: EventInput[] = [];
|
||||||
|
|
||||||
const calendarDisplayedAttributes = note.getLabelValue("calendar:displayedAttributes")?.split(",");
|
const calendarDisplayedAttributes = note.getLabelValue("calendar:displayedAttributes")?.split(",");
|
||||||
let displayedAttributesData = null;
|
let displayedAttributesData: Array<[string, string]> | null = null;
|
||||||
if (calendarDisplayedAttributes) {
|
if (calendarDisplayedAttributes) {
|
||||||
displayedAttributesData = await this.#buildDisplayedAttributes(note, calendarDisplayedAttributes);
|
displayedAttributesData = await this.#buildDisplayedAttributes(note, calendarDisplayedAttributes);
|
||||||
}
|
}
|
||||||
@ -380,11 +380,11 @@ export default class CalendarView extends ViewMode {
|
|||||||
|
|
||||||
static async #buildDisplayedAttributes(note: FNote, calendarDisplayedAttributes: string[]) {
|
static async #buildDisplayedAttributes(note: FNote, calendarDisplayedAttributes: string[]) {
|
||||||
const filteredDisplayedAttributes = note.getAttributes().filter((attr): boolean => calendarDisplayedAttributes.includes(attr.name))
|
const filteredDisplayedAttributes = note.getAttributes().filter((attr): boolean => calendarDisplayedAttributes.includes(attr.name))
|
||||||
const result: Record<string, string> = {};
|
const result: Array<[string, string]> = [];
|
||||||
|
|
||||||
for (const attribute of filteredDisplayedAttributes) {
|
for (const attribute of filteredDisplayedAttributes) {
|
||||||
if (attribute.type === "label") result[attribute.name] = attribute.value;
|
if (attribute.type === "label") result.push([attribute.name, attribute.value]);
|
||||||
else result[attribute.name] = (await attribute.getTargetNote())?.title || ""
|
else result.push([attribute.name, (await attribute.getTargetNote())?.title || ""])
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user