feat(views/table): add column to open note

This commit is contained in:
Elian Doran 2025-06-28 17:23:42 +03:00
parent 4a26f30d65
commit 56d366a286
No known key found for this signature in database
2 changed files with 17 additions and 4 deletions

View File

@ -1,8 +1,7 @@
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 { title } from "process";
import type { ColumnDefinition } from "tabulator-tables"; import type { ColumnDefinition } from "tabulator-tables";
import link from "../../../services/link.js";
export type TableData = { export type TableData = {
noteId: string; noteId: string;
@ -39,7 +38,6 @@ export function buildColumnDefinitions(info: PromotedAttributeInformation[]) {
headerSort: false, headerSort: false,
hozAlign: "center", hozAlign: "center",
formatter(cell) { formatter(cell) {
console.log(cell);
const iconClass = cell.getValue(); const iconClass = cell.getValue();
return `<span class="bx ${iconClass}"></span>`; return `<span class="bx ${iconClass}"></span>`;
}, },
@ -66,6 +64,21 @@ export function buildColumnDefinitions(info: PromotedAttributeInformation[]) {
}); });
} }
// End actions
columnDefs.push({
title: "Open note",
width: 40,
hozAlign: "center",
formatter: () => `<span class="bx bx-window-open"></span>`,
cellClick: (e, cell) => {
const noteId = cell.getRow().getCell("noteId").getValue();
console.log("Got note ID", noteId);
if (noteId) {
link.goToLinkExt(e as MouseEvent, `#root/${noteId}`);
}
}
});
return columnDefs; return columnDefs;
} }

View File

@ -81,7 +81,7 @@ 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 modules = [SortModule, FormatModule]; const modules = [SortModule, FormatModule, InteractionModule];
for (const module of modules) { for (const module of modules) {
Tabulator.registerModule(module); Tabulator.registerModule(module);
} }