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
fix(table): edit a time column through a time picker
Elian Doran7bb6b890424b
diff --git a/apps/client/src/widgets/collections/table/columns.spec.ts b/apps/client/src/widgets/collections/table/columns.spec.tsindex 0c27f08ecf..1e24544034 100644--- a/apps/client/src/widgets/collections/table/columns.spec.ts+++ b/apps/client/src/widgets/collections/table/columns.spec.ts@@ -134,6 +134,27 @@ describe("restoreExistingData", () => {});});+describe("buildColumnDefinitions — typed columns", () => {+ it("edits every temporal type through its native picker, as the promoted field does", () => {+ const columns = buildColumnDefinitions({+ info: [+ { name: "date", type: "date" },+ { name: "datetime", type: "datetime" },+ { name: "time", type: "time" }+ ],+ movableRows: false,+ existingColumnData: undefined,+ rowNumberHint: 1+ });+ const editorOf = (name: string) => columns.find((column) => column.field === `labels.${name}`)?.editor;++ expect(editorOf("date")).toBe("date");+ expect(editorOf("datetime")).toBe("datetime");+ // A plain input here would be a text box to type "14:05" into by hand.+ expect(editorOf("time")).toBe("time");+ });+});+describe("buildColumnDefinitions — select columns", () => {/** Resolves the params a column hands its editor, which Tabulator asks for as a function. */function editorParamsOf(column: ColumnDefinition | undefined) {diff --git a/apps/client/src/widgets/collections/table/columns.tsx b/apps/client/src/widgets/collections/table/columns.tsxindex 77e3d430d5..67b5f382a4 100644--- a/apps/client/src/widgets/collections/table/columns.tsx+++ b/apps/client/src/widgets/collections/table/columns.tsx@@ -66,7 +66,9 @@ const labelTypeMappings: Record<ColumnType, Partial<ColumnDefinition>> = {sorter: "number"},time: {- editor: "input"+ // No `format` param, so the editor stays on the stored "HH:mm" and needs no luxon — the same+ // value, through the same native field, as the promoted attribute of this type.+ editor: "time"},url: {formatter: "link",