feat(board): display promoted attributes

This commit is contained in:
Elian Doran 2025-11-12 19:07:23 +02:00
parent b759c5e7d2
commit 62dc570d38
No known key found for this signature in database
2 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,29 @@
import FNote from "../../entities/fnote";
interface PromotedAttributesDisplayProps {
note: FNote;
}
export default function PromotedAttributesDisplay({ note }: PromotedAttributesDisplayProps) {
const promotedDefinitionAttributes = note.getPromotedDefinitionAttributes();
return (
<div className="promoted-attributes">
{promotedDefinitionAttributes.map((attr) => {
const def = attr.getDefinition();
const [ type, name ] = attr.name.split(":", 2);
const value = note.getLabelValue(name);
const friendlyName = def?.promotedAlias ?? name;
if (!value) return null;
return (
<div key={attr.name} className="promoted-attribute">
<strong>{friendlyName}:</strong> {value}
</div>
);
}
)}
</div>
)
}

View File

@ -6,6 +6,7 @@ import { BoardViewContext, TitleEditor } from ".";
import { ContextMenuEvent } from "../../../menus/context_menu";
import { openNoteContextMenu } from "./context_menu";
import { t } from "../../../services/i18n";
import PromotedAttributesDisplay from "../../attribute_widgets/PromotedAttributesDisplay";
export const CARD_CLIPBOARD_TYPE = "trilium/board-card";
@ -108,6 +109,7 @@ export default function Card({
title={t("board_view.edit-note-title")}
onClick={handleEdit}
/>
<PromotedAttributesDisplay note={note} />
</>
) : (
<TitleEditor