mirror of
https://github.com/zadam/trilium.git
synced 2025-10-21 07:38:53 +02:00
chore(views/table): reintroduce column definitions
This commit is contained in:
parent
16b9375b9d
commit
30f7939616
@ -1,7 +1,8 @@
|
|||||||
import { GridOptions } from "ag-grid-community";
|
|
||||||
import FNote from "../../../entities/fnote.js";
|
import FNote from "../../../entities/fnote.js";
|
||||||
import type { LabelType } from "../../../services/promoted_attribute_definition_parser.js";
|
import type { LabelType } from "../../../services/promoted_attribute_definition_parser.js";
|
||||||
import froca from "../../../services/froca.js";
|
import froca from "../../../services/froca.js";
|
||||||
|
import { title } from "process";
|
||||||
|
import type { ColumnDefinition } from "tabulator-tables";
|
||||||
|
|
||||||
export type TableData = {
|
export type TableData = {
|
||||||
noteId: string;
|
noteId: string;
|
||||||
@ -30,26 +31,26 @@ export function buildData(parentNote: FNote, info: PromotedAttributeInformation[
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function buildColumnDefinitions(info: PromotedAttributeInformation[]) {
|
export function buildColumnDefinitions(info: PromotedAttributeInformation[]) {
|
||||||
const columnDefs: GridOptions<TableData>["columnDefs"] = [
|
const columnDefs: ColumnDefinition[] = [
|
||||||
{
|
{
|
||||||
field: "noteId",
|
field: "noteId",
|
||||||
editable: false
|
title: "Note ID",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: "title",
|
field: "title",
|
||||||
editable: true
|
title: "Title"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: "position"
|
field: "position",
|
||||||
|
title: "Position"
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const { name, title, type } of info) {
|
for (const { name, title, type } of info) {
|
||||||
columnDefs.push({
|
columnDefs.push({
|
||||||
field: `labels.${name}`,
|
field: `labels.${name}`,
|
||||||
headerName: title,
|
title: title ?? name,
|
||||||
cellDataType: mapDataType(type),
|
// cellDataType: mapDataType(type),
|
||||||
editable: true
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,16 +81,11 @@ 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;
|
||||||
|
|
||||||
const table = new Tabulator(el, {
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private async loadData() {
|
|
||||||
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);
|
||||||
|
|
||||||
this.api?.updateGridOptions({
|
const table = new Tabulator(el, {
|
||||||
...buildData(this.parentNote, info, notes)
|
columns: buildColumnDefinitions(info)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user