mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 23:29:02 +02:00
feat(views/table): add sort by
This commit is contained in:
parent
af97d3ef1d
commit
d8d95db4ec
@ -14,15 +14,48 @@ export function setupContextMenu(tabulator: Tabulator, parentNote: FNote) {
|
|||||||
|
|
||||||
function showColumnContextMenu(_e: UIEvent, column: ColumnComponent, tabulator: Tabulator) {
|
function showColumnContextMenu(_e: UIEvent, column: ColumnComponent, tabulator: Tabulator) {
|
||||||
const e = _e as MouseEvent;
|
const e = _e as MouseEvent;
|
||||||
|
const { title, field } = column.getDefinition();
|
||||||
|
const sorter = tabulator.getSorters().find(sorter => sorter.field === field);
|
||||||
contextMenu.show({
|
contextMenu.show({
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
title: `Hide column ${column.getDefinition().title}`,
|
title: `Hide column ${title}`,
|
||||||
handler: () => column.hide()
|
handler: () => column.hide()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Show/hide columns",
|
title: "Show/hide columns",
|
||||||
items: buildColumnItems()
|
items: buildColumnItems()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "----"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: `Sort by ${title}`,
|
||||||
|
enabled: !!field,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
title: "Ascending",
|
||||||
|
checked: (sorter?.dir === "asc"),
|
||||||
|
uiIcon: "bx bx-empty",
|
||||||
|
handler: () => tabulator.setSort([
|
||||||
|
{
|
||||||
|
column: field!,
|
||||||
|
dir: "asc",
|
||||||
|
}
|
||||||
|
])
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Descending",
|
||||||
|
checked: (sorter?.dir === "desc"),
|
||||||
|
uiIcon: "bx bx-empty",
|
||||||
|
handler: () => tabulator.setSort([
|
||||||
|
{
|
||||||
|
column: field!,
|
||||||
|
dir: "desc"
|
||||||
|
}
|
||||||
|
])
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
selectMenuItemHandler() {},
|
selectMenuItemHandler() {},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user