chore(views/table): translate column menu

This commit is contained in:
Elian Doran 2025-07-13 16:52:29 +03:00
parent 08e08d8920
commit c8ffb8d694
No known key found for this signature in database
2 changed files with 16 additions and 9 deletions

View File

@ -1944,7 +1944,13 @@
},
"table_view": {
"new-row": "New row",
"new-column": "New column"
"new-column": "New column",
"sort-column-by": "Sort by \"{{title}}\"",
"sort-column-ascending": "Ascending",
"sort-column-descending": "Descending",
"sort-column-clear": "Clear sorting",
"hide-column": "Hide column \"{{title}}\"",
"show-hide-columns": "Show/hide columns"
},
"book_properties_config": {
"hide-weekends": "Hide weekends",

View File

@ -5,7 +5,6 @@ import branches from "../../../services/branches.js";
import { t } from "../../../services/i18n.js";
import link_context_menu from "../../../menus/link_context_menu.js";
import type FNote from "../../../entities/fnote.js";
import appContext from "../../../components/app_context.js";
export function setupContextMenu(tabulator: Tabulator, parentNote: FNote) {
tabulator.on("rowContext", (e, row) => showRowContextMenu(e, row, parentNote));
@ -22,12 +21,12 @@ function showColumnContextMenu(_e: UIEvent, column: ColumnComponent, tabulator:
contextMenu.show({
items: [
{
title: `Sort by ${title}`,
title: t("table_view.sort-column-by", { title }),
enabled: !!field,
uiIcon: "bx bx-sort-alt-2",
items: [
{
title: "Ascending",
title: t("table_view.sort-column-ascending"),
checked: (sorter?.dir === "asc"),
uiIcon: "bx bx-empty",
handler: () => tabulator.setSort([
@ -38,7 +37,7 @@ function showColumnContextMenu(_e: UIEvent, column: ColumnComponent, tabulator:
])
},
{
title: "Descending",
title: t("table_view.sort-column-descending"),
checked: (sorter?.dir === "desc"),
uiIcon: "bx bx-empty",
handler: () => tabulator.setSort([
@ -51,7 +50,7 @@ function showColumnContextMenu(_e: UIEvent, column: ColumnComponent, tabulator:
]
},
{
title: "Clear sorting",
title: t("table_view.sort-column-clear"),
enabled: sorters.length > 0,
uiIcon: "bx bx-empty",
handler: () => tabulator.clearSort()
@ -60,12 +59,13 @@ function showColumnContextMenu(_e: UIEvent, column: ColumnComponent, tabulator:
title: "----"
},
{
title: `Hide column ${title}`,
title: t("table_view.hide-column", { title }),
enabled: !!field,
uiIcon: "bx bx-hide",
handler: () => column.hide()
},
{
title: "Show/hide columns",
title: t("table_view.show-hide-columns"),
uiIcon: "bx bx-empty",
items: buildColumnItems()
},
@ -79,12 +79,13 @@ function showColumnContextMenu(_e: UIEvent, column: ColumnComponent, tabulator:
function buildColumnItems() {
const items: MenuItem<unknown>[] = [];
for (const column of tabulator.getColumns()) {
const { title, visible } = column.getDefinition();
const { title, visible, field } = column.getDefinition();
items.push({
title,
checked: visible,
uiIcon: "bx bx-empty",
enabled: !!field,
handler: () => column.toggle()
});
}