Skip to content

Commit 02452a0

Browse files
committed
feat(board/promoted_attributes): display relations with icon
1 parent e9f40c4 commit 02452a0

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

apps/client/src/widgets/attribute_widgets/PromotedAttributesDisplay.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { DefinitionObject } from "../../services/promoted_attribute_definition_p
77
import { formatDateTime } from "../../utils/formatters";
88
import { ComponentChildren } from "preact";
99
import Icon from "../react/Icon";
10-
import css_class_manager from "../../services/css_class_manager";
10+
import NoteLink from "../react/NoteLink";
1111

1212
interface PromotedAttributesDisplayProps {
1313
note: FNote;
@@ -30,7 +30,7 @@ export default function PromotedAttributesDisplay({ note, ignoredAttributes }: P
3030
const className = `${attr.type === "label" ? "label" + " " + attr.def.labelType : "relation"}`;
3131
return (
3232
<span key={attr.friendlyName} className={`promoted-attribute type-${className}`}>
33-
{formatLabelValue(attr)}
33+
{attr.type === "relation" ? formatRelation(attr) : formatLabelValue(attr)}
3434
</span>
3535
);
3636
}
@@ -84,13 +84,19 @@ function formatLabelValue(attr: AttributeWithDefinitions): ComponentChildren {
8484
}
8585
}
8686

87+
function formatRelation(attr: AttributeWithDefinitions): ComponentChildren {
88+
return (
89+
<><strong>{attr.friendlyName}:</strong> <NoteLink notePath={attr.value} showNoteIcon /></>
90+
)
91+
}
92+
8793
function getAttributesWithDefinitions(note: FNote, attributesToIgnore: string[] = []): AttributeWithDefinitions[] {
8894
const promotedDefinitionAttributes = note.getPromotedDefinitionAttributes();
8995
const result: AttributeWithDefinitions[] = [];
9096
for (const attr of promotedDefinitionAttributes) {
9197
const def = attr.getDefinition();
9298
const [ type, name ] = attr.name.split(":", 2);
93-
const value = note.getLabelValue(name);
99+
const value = type === "label" ? note.getLabelValue(name) : note.getRelationValue(name);
94100
const friendlyName = def?.promotedAlias || name;
95101
if (!value) continue;
96102
if (attributesToIgnore.includes(name)) continue;

0 commit comments

Comments
 (0)