From c65ec1494333de52a91675cf7001688a47db148d Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 13 Jul 2025 14:37:13 +0300 Subject: [PATCH] feat(views/table): hide column in contetx menu --- .../view_widgets/table_view/context_menu.ts | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/apps/client/src/widgets/view_widgets/table_view/context_menu.ts b/apps/client/src/widgets/view_widgets/table_view/context_menu.ts index af463027b..33278fcad 100644 --- a/apps/client/src/widgets/view_widgets/table_view/context_menu.ts +++ b/apps/client/src/widgets/view_widgets/table_view/context_menu.ts @@ -1,4 +1,4 @@ -import { RowComponent, Tabulator } from "tabulator-tables"; +import { ColumnComponent, RowComponent, Tabulator } from "tabulator-tables"; import contextMenu from "../../../menus/context_menu.js"; import { TableData } from "./rows.js"; import branches from "../../../services/branches.js"; @@ -9,6 +9,23 @@ import appContext from "../../../components/app_context.js"; export function setupContextMenu(tabulator: Tabulator, parentNote: FNote) { tabulator.on("rowContext", (e, row) => showRowContextMenu(e, row, parentNote)); + tabulator.on("headerContext", (e, col) => showColumnContextMenu(e, col)); +} + +function showColumnContextMenu(_e: UIEvent, column: ColumnComponent) { + const e = _e as MouseEvent; + contextMenu.show({ + items: [ + { + title: "Hide column", + handler: () => column.hide() + } + ], + selectMenuItemHandler() {}, + x: e.pageX, + y: e.pageY + }); + e.preventDefault(); } export function showRowContextMenu(_e: UIEvent, row: RowComponent, parentNote: FNote) { @@ -59,9 +76,7 @@ export function showRowContextMenu(_e: UIEvent, row: RowComponent, parentNote: F handler: () => branches.deleteNotes([ rowData.branchId ], false, false) } ], - selectMenuItemHandler: ({ command }) => { - link_context_menu.handleLinkContextMenuItem(command, rowData.noteId); - }, + selectMenuItemHandler: ({ command }) => link_context_menu.handleLinkContextMenuItem(command, rowData.noteId), x: e.pageX, y: e.pageY });