mirror of
https://github.com/zadam/trilium.git
synced 2025-10-21 07:38:53 +02:00
feat(views/table): separate data model for relations
This commit is contained in:
parent
b293643398
commit
a4664576fe
@ -9,6 +9,7 @@ export type TableData = {
|
|||||||
noteId: string;
|
noteId: string;
|
||||||
title: string;
|
title: string;
|
||||||
labels: Record<string, boolean | string | null>;
|
labels: Record<string, boolean | string | null>;
|
||||||
|
relations: Record<string, boolean | string | null>;
|
||||||
branchId: string;
|
branchId: string;
|
||||||
position: number;
|
position: number;
|
||||||
};
|
};
|
||||||
@ -100,8 +101,10 @@ export function buildColumnDefinitions(info: PromotedAttributeInformation[]) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const { name, title, type } of info) {
|
for (const { name, title, type } of info) {
|
||||||
|
const prefix = (type === "relation" ? "relations" : "labels");
|
||||||
|
|
||||||
columnDefs.push({
|
columnDefs.push({
|
||||||
field: `labels.${name}`,
|
field: `${prefix}.${name}`,
|
||||||
title: title ?? name,
|
title: title ?? name,
|
||||||
editor: "input",
|
editor: "input",
|
||||||
...labelTypeMappings[type ?? "text"],
|
...labelTypeMappings[type ?? "text"],
|
||||||
@ -135,9 +138,10 @@ export async function buildRowDefinitions(parentNote: FNote, notes: FNote[], inf
|
|||||||
}
|
}
|
||||||
|
|
||||||
const labels: typeof definitions[0]["labels"] = {};
|
const labels: typeof definitions[0]["labels"] = {};
|
||||||
|
const relations: typeof definitions[0]["relations"] = {};
|
||||||
for (const { name, type } of infos) {
|
for (const { name, type } of infos) {
|
||||||
if (type === "relation") {
|
if (type === "relation") {
|
||||||
labels[name] = note.getRelationValue(name);
|
relations[name] = note.getRelationValue(name);
|
||||||
} else if (type === "boolean") {
|
} else if (type === "boolean") {
|
||||||
labels[name] = note.hasLabel(name);
|
labels[name] = note.hasLabel(name);
|
||||||
} else {
|
} else {
|
||||||
@ -149,6 +153,7 @@ export async function buildRowDefinitions(parentNote: FNote, notes: FNote[], inf
|
|||||||
noteId: note.noteId,
|
noteId: note.noteId,
|
||||||
title: note.title,
|
title: note.title,
|
||||||
labels,
|
labels,
|
||||||
|
relations,
|
||||||
position: branch.notePosition,
|
position: branch.notePosition,
|
||||||
branchId: branch.branchId
|
branchId: branch.branchId
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user