diff --git a/apps/client/src/services/promoted_attribute_definition_parser.ts b/apps/client/src/services/promoted_attribute_definition_parser.ts index f46040e2a..6cdb8edc6 100644 --- a/apps/client/src/services/promoted_attribute_definition_parser.ts +++ b/apps/client/src/services/promoted_attribute_definition_parser.ts @@ -1,4 +1,4 @@ -type LabelType = "text" | "number" | "boolean" | "date" | "datetime" | "time" | "url"; +export type LabelType = "text" | "number" | "boolean" | "date" | "datetime" | "time" | "url"; type Multiplicity = "single" | "multi"; export interface DefinitionObject { 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 e2ec94b92..69a2aed03 100644 --- a/apps/client/src/widgets/view_widgets/table_view/data.ts +++ b/apps/client/src/widgets/view_widgets/table_view/data.ts @@ -1,10 +1,13 @@ import { GridOptions } from "ag-grid-community"; import FNote from "../../../entities/fnote"; +import type { LabelType } from "../../../services/promoted_attribute_definition_parser.js"; type Data = { title: string; } & Record; +type GridLabelType = 'text' | 'number' | 'boolean' | 'date' | 'dateString' | 'object'; + export function buildData(parentNote: FNote, notes: FNote[]) { const { columnDefs, expectedLabels } = buildColumnDefinitions(parentNote); const rowData = buildRowDefinitions(notes, expectedLabels); @@ -42,7 +45,8 @@ export function buildColumnDefinitions(parentNote: FNote) { columnDefs.push({ field: attributeName, - headerName: title + headerName: title, + cellDataType: mapDataType(def.labelType) }); expectedLabels.push(attributeName); } @@ -50,6 +54,20 @@ export function buildColumnDefinitions(parentNote: FNote) { return { columnDefs, expectedLabels }; } +function mapDataType(labelType: LabelType | undefined): GridLabelType { + if (!labelType) { + return "text"; + } + + switch (labelType) { + case "date": + return "dateString"; + case "text": + default: + return "text" + } +} + export function buildRowDefinitions(notes: FNote[], expectedLabels: string[]): GridOptions["rowData"] { const definitions: GridOptions["rowData"] = []; for (const note of notes) {