chore(views/table): reintroduce rows

This commit is contained in:
Elian Doran 2025-06-28 12:24:40 +03:00
parent 30f7939616
commit e09a7fb6e0
No known key found for this signature in database

View File

@ -1,7 +1,7 @@
import froca from "../../../services/froca.js"; import froca from "../../../services/froca.js";
import ViewMode, { type ViewModeArgs } from "../view_mode.js"; import ViewMode, { type ViewModeArgs } from "../view_mode.js";
import attributes, { setLabel } from "../../../services/attributes.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 server from "../../../services/server.js";
import SpacedUpdate from "../../../services/spaced_update.js"; import SpacedUpdate from "../../../services/spaced_update.js";
import branches from "../../../services/branches.js"; import branches from "../../../services/branches.js";
@ -54,7 +54,7 @@ export default class TableView extends ViewMode<StateInfo> {
private $container: JQuery<HTMLElement>; private $container: JQuery<HTMLElement>;
private args: ViewModeArgs; private args: ViewModeArgs;
private spacedUpdate: SpacedUpdate; private spacedUpdate: SpacedUpdate;
private api?: GridApi; private api?: Tabulator;
private newAttribute?: Attribute; private newAttribute?: Attribute;
constructor(args: ViewModeArgs) { constructor(args: ViewModeArgs) {
@ -81,12 +81,21 @@ export default class TableView extends ViewMode<StateInfo> {
const viewStorage = await this.viewStorage.restore(); const viewStorage = await this.viewStorage.restore();
const initialState = viewStorage?.gridState; 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 notes = await froca.getNotes(this.args.noteIds);
const info = getPromotedAttributeInformation(this.parentNote); const info = getPromotedAttributeInformation(this.parentNote);
const table = new Tabulator(el, { this.api.setColumns(buildColumnDefinitions(info));
columns: buildColumnDefinitions(info) this.api.setData(buildRowDefinitions(this.parentNote, notes, info));
});
} }
private onSave() { private onSave() {