Skip to content

Commit 62dc570

Browse files
committed
feat(board): display promoted attributes
1 parent b759c5e commit 62dc570

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import FNote from "../../entities/fnote";
2+
3+
interface PromotedAttributesDisplayProps {
4+
note: FNote;
5+
}
6+
7+
export default function PromotedAttributesDisplay({ note }: PromotedAttributesDisplayProps) {
8+
const promotedDefinitionAttributes = note.getPromotedDefinitionAttributes();
9+
10+
return (
11+
<div className="promoted-attributes">
12+
{promotedDefinitionAttributes.map((attr) => {
13+
const def = attr.getDefinition();
14+
const [ type, name ] = attr.name.split(":", 2);
15+
const value = note.getLabelValue(name);
16+
const friendlyName = def?.promotedAlias ?? name;
17+
if (!value) return null;
18+
19+
return (
20+
<div key={attr.name} className="promoted-attribute">
21+
<strong>{friendlyName}:</strong> {value}
22+
</div>
23+
);
24+
}
25+
)}
26+
</div>
27+
)
28+
29+
}

apps/client/src/widgets/collections/board/card.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { BoardViewContext, TitleEditor } from ".";
66
import { ContextMenuEvent } from "../../../menus/context_menu";
77
import { openNoteContextMenu } from "./context_menu";
88
import { t } from "../../../services/i18n";
9+
import PromotedAttributesDisplay from "../../attribute_widgets/PromotedAttributesDisplay";
910

1011
export const CARD_CLIPBOARD_TYPE = "trilium/board-card";
1112

@@ -108,6 +109,7 @@ export default function Card({
108109
title={t("board_view.edit-note-title")}
109110
onClick={handleEdit}
110111
/>
112+
<PromotedAttributesDisplay note={note} />
111113
</>
112114
) : (
113115
<TitleEditor

0 commit comments

Comments
 (0)