diff --git a/apps/client/src/widgets/view_widgets/table_view.ts b/apps/client/src/widgets/view_widgets/table_view.ts index 420841781..21304ba22 100644 --- a/apps/client/src/widgets/view_widgets/table_view.ts +++ b/apps/client/src/widgets/view_widgets/table_view.ts @@ -2,8 +2,7 @@ import froca from "../../services/froca.js"; import ViewMode, { type ViewModeArgs } from "./view_mode.js"; import { createGrid, AllCommunityModule, ModuleRegistry, GridOptions } from "ag-grid-community"; import { setLabel } from "../../services/attributes.js"; -import getPromotedAttributeInformation from "./table_view/parser.js"; -import { buildData, TableData } from "./table_view/data.js"; +import getPromotedAttributeInformation, { buildData, TableData } from "./table_view/data.js"; import applyHeaderCustomization from "./table_view/header-customization.js"; import server from "../../services/server.js"; import type { GridState } from "ag-grid-community"; diff --git a/apps/client/src/widgets/view_widgets/table_view/data.ts b/apps/client/src/widgets/view_widgets/table_view/data.ts index 126a8e537..17257ba8b 100644 --- a/apps/client/src/widgets/view_widgets/table_view/data.ts +++ b/apps/client/src/widgets/view_widgets/table_view/data.ts @@ -1,7 +1,6 @@ import { GridOptions } from "ag-grid-community"; import FNote from "../../../entities/fnote.js"; import type { LabelType } from "../../../services/promoted_attribute_definition_parser.js"; -import { default as getPromotedAttributeInformation, type PromotedAttributeInformation } from "./parser.js"; export type TableData = { noteId: string; @@ -9,6 +8,11 @@ export type TableData = { labels: Record; }; +export interface PromotedAttributeInformation { + name: string; + title?: string; + type?: LabelType; +} type GridLabelType = 'text' | 'number' | 'boolean' | 'date' | 'dateString' | 'object'; @@ -84,3 +88,26 @@ export function buildRowDefinitions(notes: FNote[], infos: PromotedAttributeInfo return definitions; } + +export default function getPromotedAttributeInformation(parentNote: FNote) { + const info: PromotedAttributeInformation[] = []; + for (const promotedAttribute of parentNote.getPromotedDefinitionAttributes()) { + if (promotedAttribute.type !== "label") { + console.warn("Relations are not supported for now"); + continue; + } + + const def = promotedAttribute.getDefinition(); + if (def.multiplicity !== "single") { + console.warn("Multiple values are not supported for now"); + continue; + } + + info.push({ + name: promotedAttribute.name.split(":", 2)[1], + title: def.promotedAlias, + type: def.labelType + }) + } + return info; +} diff --git a/apps/client/src/widgets/view_widgets/table_view/parser.ts b/apps/client/src/widgets/view_widgets/table_view/parser.ts deleted file mode 100644 index 7719948b6..000000000 --- a/apps/client/src/widgets/view_widgets/table_view/parser.ts +++ /dev/null @@ -1,31 +0,0 @@ -import FNote from "../../../entities/fnote"; -import { LabelType } from "../../../services/promoted_attribute_definition_parser"; - -export interface PromotedAttributeInformation { - name: string; - title?: string; - type?: LabelType; -} - -export default function getPromotedAttributeInformation(parentNote: FNote) { - const info: PromotedAttributeInformation[] = []; - for (const promotedAttribute of parentNote.getPromotedDefinitionAttributes()) { - if (promotedAttribute.type !== "label") { - console.warn("Relations are not supported for now"); - continue; - } - - const def = promotedAttribute.getDefinition(); - if (def.multiplicity !== "single") { - console.warn("Multiple values are not supported for now"); - continue; - } - - info.push({ - name: promotedAttribute.name.split(":", 2)[1], - title: def.promotedAlias, - type: def.labelType - }) - } - return info; -}