From 4a26f30d65ab6b95335d88058211181dd0adca8a Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 28 Jun 2025 17:07:11 +0300 Subject: [PATCH] feat(views/table): render note icon --- .../src/widgets/view_widgets/table_view/data.ts | 13 +++++++++++++ .../src/widgets/view_widgets/table_view/index.ts | 8 ++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 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 1eb6faebd..c9034607f 100644 --- a/apps/client/src/widgets/view_widgets/table_view/data.ts +++ b/apps/client/src/widgets/view_widgets/table_view/data.ts @@ -32,6 +32,18 @@ export async function buildData(parentNote: FNote, info: PromotedAttributeInform export function buildColumnDefinitions(info: PromotedAttributeInformation[]) { const columnDefs: ColumnDefinition[] = [ + { + field: "iconClass", + title: "Icon", + width: 40, + headerSort: false, + hozAlign: "center", + formatter(cell) { + console.log(cell); + const iconClass = cell.getValue(); + return ``; + }, + }, { field: "noteId", title: "Note ID", @@ -92,6 +104,7 @@ export async function buildRowDefinitions(parentNote: FNote, notes: FNote[], inf } } definitions.push({ + iconClass: note.getIcon(), noteId: note.noteId, title: note.title, labels, diff --git a/apps/client/src/widgets/view_widgets/table_view/index.ts b/apps/client/src/widgets/view_widgets/table_view/index.ts index 2c9fe484e..0eb795fa8 100644 --- a/apps/client/src/widgets/view_widgets/table_view/index.ts +++ b/apps/client/src/widgets/view_widgets/table_view/index.ts @@ -8,7 +8,7 @@ import branches from "../../../services/branches.js"; import type { CommandListenerData, EventData } from "../../../components/app_context.js"; import type { Attribute } from "../../../services/attribute_parser.js"; import note_create from "../../../services/note_create.js"; -import {Tabulator, SortModule} from 'tabulator-tables'; +import {Tabulator, SortModule, FormatModule} from 'tabulator-tables'; import "tabulator-tables/dist/css/tabulator_bootstrap5.min.css"; const TPL = /*html*/` @@ -81,7 +81,11 @@ export default class TableView extends ViewMode { const viewStorage = await this.viewStorage.restore(); const initialState = viewStorage?.gridState; - Tabulator.registerModule(SortModule); + const modules = [SortModule, FormatModule]; + for (const module of modules) { + Tabulator.registerModule(module); + } + this.api = new Tabulator(el, {}); this.loadData(); }