diff --git a/src/public/app/widgets/view_widgets/calendar_view.spec.ts b/src/public/app/widgets/view_widgets/calendar_view.spec.ts index c512a4d56..9623f0172 100644 --- a/src/public/app/widgets/view_widgets/calendar_view.spec.ts +++ b/src/public/app/widgets/view_widgets/calendar_view.spec.ts @@ -145,4 +145,21 @@ describe("Promoted attributes", () => { Mood: "happy" }) }); + + it("supports relations", async () => { + const note = buildNote({ + "title": "Hello", + "~assignee": buildNote({ + "title": "Target note" + }).noteId, + "#calendar:promotedAttributes": "relation:assignee", + "#relation:assignee": "promoted,alias=Assignee,single,text", + }); + + const event = await CalendarView.buildEvent(note, "2025-04-04"); + expect(event).toHaveLength(1); + expect(event[0]?.promotedAttributes).toMatchObject({ + "Assignee": "Target note" + }) + }); }); diff --git a/src/public/app/widgets/view_widgets/calendar_view.ts b/src/public/app/widgets/view_widgets/calendar_view.ts index 512d5a650..e38f95690 100644 --- a/src/public/app/widgets/view_widgets/calendar_view.ts +++ b/src/public/app/widgets/view_widgets/calendar_view.ts @@ -378,8 +378,6 @@ export default class CalendarView extends ViewMode { const filteredPromotedAttributes = note.getPromotedDefinitionAttributes().filter((attr) => promotedAttributeNames.includes(attr.name)); const result: Record = {}; - console.log("Got promoted attributes ", promotedAttributeNames, filteredPromotedAttributes); - for (const promotedAttribute of filteredPromotedAttributes) { const [ type, name ] = promotedAttribute.name.split(":", 2); const definition = promotedAttribute.getDefinition(); @@ -389,12 +387,15 @@ export default class CalendarView extends ViewMode { continue; } - // TODO: Add support for relations - if (type !== "label" || !note.hasLabel(name)) { - continue; + let value: string | undefined | null = null; + + if (type === "label" && note.hasLabel(name)) { + value = note.getLabelValue(name); + } else if (type === "relation" && note.hasRelation(name)) { + const targetNote = await note.getRelationTarget(name); + value = targetNote?.title; } - const value = note.getLabelValue(name); const friendlyName = definition.promotedAlias ?? name; if (friendlyName && value) { result[friendlyName] = value;