mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 10:40:41 +01:00
feat(book/table): store hidden columns
This commit is contained in:
@@ -1,25 +1,35 @@
|
||||
import { createGrid, AllCommunityModule, ModuleRegistry, columnDropStyleBordered, GridOptions } from "ag-grid-community";
|
||||
import { createGrid, AllCommunityModule, ModuleRegistry, GridOptions } from "ag-grid-community";
|
||||
import { buildData, type TableData } from "./data.js";
|
||||
import FNote from "../../../entities/fnote.js";
|
||||
import getPromotedAttributeInformation, { PromotedAttributeInformation } from "./parser.js";
|
||||
import getPromotedAttributeInformation from "./parser.js";
|
||||
import { setLabel } from "../../../services/attributes.js";
|
||||
import applyHeaderCustomization from "./header-customization.js";
|
||||
import ViewModeStorage from "../view_mode_storage.js";
|
||||
import { type StateInfo } from "./storage.js";
|
||||
|
||||
ModuleRegistry.registerModules([ AllCommunityModule ]);
|
||||
|
||||
export default function renderTable(el: HTMLElement, parentNote: FNote, notes: FNote[]) {
|
||||
export default async function renderTable(el: HTMLElement, parentNote: FNote, notes: FNote[], storage: ViewModeStorage<StateInfo>) {
|
||||
const info = getPromotedAttributeInformation(parentNote);
|
||||
const viewStorage = await storage.restore();
|
||||
const initialState = viewStorage?.gridState;
|
||||
|
||||
createGrid(el, {
|
||||
...buildData(info, notes),
|
||||
...setupEditing(info),
|
||||
onGridReady(event) {
|
||||
...setupEditing(),
|
||||
initialState,
|
||||
async onGridReady(event) {
|
||||
applyHeaderCustomization(el, event.api);
|
||||
},
|
||||
onStateUpdated(event) {
|
||||
storage.store({
|
||||
gridState: event.api.getState()
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setupEditing(info: PromotedAttributeInformation[]): GridOptions<TableData> {
|
||||
function setupEditing(): GridOptions<TableData> {
|
||||
return {
|
||||
onCellValueChanged(event) {
|
||||
if (event.type !== "cellValueChanged") {
|
||||
@@ -37,3 +47,4 @@ function setupEditing(info: PromotedAttributeInformation[]): GridOptions<TableDa
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user