From e09a7fb6e09fbe024018b6b08f5ecb784f73669c Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 28 Jun 2025 12:24:40 +0300 Subject: [PATCH] chore(views/table): reintroduce rows --- .../widgets/view_widgets/table_view/index.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) 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 26f5b9ee7..3017ebfb1 100644 --- a/apps/client/src/widgets/view_widgets/table_view/index.ts +++ b/apps/client/src/widgets/view_widgets/table_view/index.ts @@ -1,7 +1,7 @@ import froca from "../../../services/froca.js"; import ViewMode, { type ViewModeArgs } from "../view_mode.js"; import attributes, { setLabel } from "../../../services/attributes.js"; -import getPromotedAttributeInformation, { buildColumnDefinitions, buildData, TableData } from "./data.js"; +import getPromotedAttributeInformation, { buildColumnDefinitions, buildData, buildRowDefinitions, TableData } from "./data.js"; import server from "../../../services/server.js"; import SpacedUpdate from "../../../services/spaced_update.js"; import branches from "../../../services/branches.js"; @@ -54,7 +54,7 @@ export default class TableView extends ViewMode { private $container: JQuery; private args: ViewModeArgs; private spacedUpdate: SpacedUpdate; - private api?: GridApi; + private api?: Tabulator; private newAttribute?: Attribute; constructor(args: ViewModeArgs) { @@ -81,12 +81,21 @@ export default class TableView extends ViewMode { const viewStorage = await this.viewStorage.restore(); const initialState = viewStorage?.gridState; + this.api = new Tabulator(el, { + }); + this.loadData(); + } + + private async loadData() { + if (!this.api) { + return; + } + const notes = await froca.getNotes(this.args.noteIds); const info = getPromotedAttributeInformation(this.parentNote); - const table = new Tabulator(el, { - columns: buildColumnDefinitions(info) - }); + this.api.setColumns(buildColumnDefinitions(info)); + this.api.setData(buildRowDefinitions(this.parentNote, notes, info)); } private onSave() {