Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(book/table): support date type
Elian Dorand9443527eea2
diff --git a/apps/client/src/services/promoted_attribute_definition_parser.ts b/apps/client/src/services/promoted_attribute_definition_parser.tsindex f46040e2a8..6cdb8edc60 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.tsindex e2ec94b926..69a2aed03a 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<string, string>;+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<Data>["rowData"] {const definitions: GridOptions<Data>["rowData"] = [];for (const note of notes) {