feat(views/table): deduplicate columns

This commit is contained in:
Elian Doran
2025-07-04 21:15:10 +03:00
parent 461e085eff
commit 28a755306a

View File

@@ -88,15 +88,22 @@ export function buildColumnDefinitions(info: PromotedAttributeInformation[], exi
} }
]; ];
const seenFields = new Set<string>();
for (const { name, title, type } of info) { for (const { name, title, type } of info) {
const prefix = (type === "relation" ? "relations" : "labels"); const prefix = (type === "relation" ? "relations" : "labels");
const field = `${prefix}.${name}`;
if (seenFields.has(field)) {
continue;
}
columnDefs.push({ columnDefs.push({
field: `${prefix}.${name}`, field,
title: title ?? name, title: title ?? name,
editor: "input", editor: "input",
...labelTypeMappings[type ?? "text"], ...labelTypeMappings[type ?? "text"],
}); });
seenFields.add(field);
} }
applyHeaderMenu(columnDefs); applyHeaderMenu(columnDefs);