feat(views/table): update new column in context menu to support relations also

This commit is contained in:
Elian Doran 2025-07-19 14:17:48 +03:00
parent cb8a5cbb62
commit d487da0b2f
No known key found for this signature in database
4 changed files with 13 additions and 5 deletions

View File

@ -26,6 +26,11 @@ export interface MenuCommandItem<T> {
title: string;
command?: T;
type?: string;
/**
* The icon to display in the menu item.
*
* If not set, no icon is displayed and the item will appear shifted slightly to the left if there are other items with icons. To avoid this, use `bx bx-empty`.
*/
uiIcon?: string;
badges?: MenuItemBadge[];
templateNoteId?: string;

View File

@ -139,11 +139,13 @@ function showHeaderContextMenu(_e: Event, tabulator: Tabulator) {
uiIcon: "bx bx-empty",
items: buildColumnItems(tabulator)
},
{ title: "----" },
{
title: t("table_view.new-column"),
uiIcon: "bx bx-columns",
handler: () => getParentComponent(e)?.triggerCommand("addNewTableColumn", {})
uiIcon: "bx bx-empty",
enabled: false
},
...buildInsertSubmenu(e)
],
selectMenuItemHandler() {},
x: e.pageX,
@ -246,7 +248,7 @@ function buildColumnItems(tabulator: Tabulator) {
return items;
}
function buildInsertSubmenu(e: MouseEvent, referenceColumn: ColumnComponent, direction: "before" | "after"): MenuItem<unknown>[] {
function buildInsertSubmenu(e: MouseEvent, referenceColumn?: ColumnComponent, direction?: "before" | "after"): MenuItem<unknown>[] {
return [
{
title: t("table_view.new-column-label"),

View File

@ -46,7 +46,8 @@
<li data-list-item-id="e3bb3951707ab03fccab11c9b83d8f7a1">Press <em>Add new column</em> at the bottom of the table.</li>
<li data-list-item-id="e59ac48e5d7f2f1119d27db5b01eb0635">Right click on an existing column and select Add column to the left/right.</li>
<li
data-list-item-id="e681ba5bf3901016423216783a17f13f8">Right click on the empty space of the column header and select <em>New column</em>.</li>
data-list-item-id="e681ba5bf3901016423216783a17f13f8">Right click on the empty space of the column header and select <em>Label</em> or <em>Relation</em> in
the <em>New column </em>section.</li>
</ul>
<h3>Adding new rows</h3>
<p>Each row is actually a note that is a child of the Collection note.</p>

View File

@ -35,7 +35,7 @@ To create a new column, either:
* Press _Add new column_ at the bottom of the table.
* Right click on an existing column and select Add column to the left/right.
* Right click on the empty space of the column header and select _New column_.
* Right click on the empty space of the column header and select _Label_ or _Relation_ in the _New column_ section.
### Adding new rows