Skip to content

Build your personal knowledge base with Trilium Notes

feat(board): option to hide the "Add column" button (closes #11709)

Elian Doranabadfda5e76c
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index f04623eb57..0e8b1a4edb 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -772,6 +772,7 @@
"include_archived": "Includes archived notes in this collection, which are otherwise left out.",
"board_column_width": "For board collections, how wide the columns are drawn: <code>narrow</code>, <code>medium</code> or <code>wide</code>. Ignored on mobile, which draws them at a width of its own.",
"board_show_inbox": "For board collections, shows the inbox column, which lists all child notes that are not assigned to a board column.",
+ "board_hide_add_column": "For board collections, hides the <em>Add column</em> button after the last column. Columns can still be added from the context menu of the board or of a column.",
"board_card_redirect_to": "On a board card, opening the card jumps to the note this points at instead of opening the card itself.",
"board_sort_columns": "For board collections, the order the columns sort their cards in, which a column follows unless it is given an order of its own. Holds <code>title</code>, <code>creationDate</code> or <code>attr:</code> followed by a promoted attribute's name.",
"board_sort_columns_descending": "For board collections, runs the order in <code>#board:sortColumns</code> backwards.",
@@ -3579,6 +3580,8 @@
"show-archived-notes": "Show archived cards/columns",
"general": "General",
"show-archived": "Show archived cards and columns",
+ "show-add-column-button": "Show the \"Add column\" button",
+ "show-add-column-button-description": "Columns can still be added from the context menu of the board or of a column.",
"copy-reference": "Copy reference",
"reference-column-missing": "That column is no longer on this board.",
"reference-archived": "That card is archived, so the board is not showing it.",
diff --git a/apps/client/src/widgets/attribute_widgets/attr_help.ts b/apps/client/src/widgets/attribute_widgets/attr_help.ts
index a2c137af20..fc599d6b3d 100644
--- a/apps/client/src/widgets/attribute_widgets/attr_help.ts
+++ b/apps/client/src/widgets/attribute_widgets/attr_help.ts
@@ -158,6 +158,7 @@ export const ATTR_HELP: AttrHelpMap = {
maxNestingDepth: t("attribute_detail.max_nesting_depth"),
includeArchived: t("attribute_detail.include_archived"),
"board:showInbox": t("attribute_detail.board_show_inbox"),
+ "board:hideAddColumn": t("attribute_detail.board_hide_add_column"),
"board:columnWidth": t("attribute_detail.board_column_width"),
"board:sortColumns": t("attribute_detail.board_sort_columns"),
"board:sortColumnsDescending": t("attribute_detail.board_sort_columns_descending"),
diff --git a/apps/client/src/widgets/collections/board/api.ts b/apps/client/src/widgets/collections/board/api.ts
index 7803a65390..f96973b450 100644
--- a/apps/client/src/widgets/collections/board/api.ts
+++ b/apps/client/src/widgets/collections/board/api.ts
@@ -729,6 +729,11 @@ export default class BoardApi {
await this.setInboxEnabled(false);
}
+ /** Whether the board draws the button after its last column that adds a column. */
+ async setAddColumnShown(shown: boolean) {
+ await attributes.setBooleanWithInheritance(this.parentNote, "board:hideAddColumn", !shown);
+ }
+
/** Whether the board draws the notes filed as archived, cards and columns alike. */
async setArchivedShown(shown: boolean) {
await attributes.setBooleanWithInheritance(this.parentNote, "includeArchived", shown);
diff --git a/apps/client/src/widgets/collections/board/index.spec.tsx b/apps/client/src/widgets/collections/board/index.spec.tsx
index de36b7912b..ee0ec0794c 100644
--- a/apps/client/src/widgets/collections/board/index.spec.tsx
+++ b/apps/client/src/widgets/collections/board/index.spec.tsx
@@ -257,11 +257,12 @@ describe("Collapsed board columns", () => {
});
/** A board whose first column is stored collapsed and holds two cards. */
- async function setup({ keepCollapsed = false } = {}) {
+ async function setup({ keepCollapsed = false, hideAddColumn = false } = {}) {
const note = buildNote({
title: "Board",
"#collection": "",
"#viewType": "board",
+ ...(hideAddColumn ? { "#board:hideAddColumn": "true" } : {}),
children: [
{ id: "card1", title: "First", "#status": "To Do" },
{ id: "card2", title: "Second", "#status": "To Do" },
@@ -700,6 +701,40 @@ describe("Collapsed board columns", () => {
archived.mockRestore();
});
+ it("leaves out the add-column button when hidden, and still opens its editor from the menu",
+ async () => {
+ const { mountPoint } = await setup({ hideAddColumn: true });
+ const show = vi.spyOn(contextMenu, "show").mockImplementation(async () => {});
+
+ expect(mountPoint.querySelector(".board-view-container")).not.toBeNull();
+ expect(mountPoint.querySelector(".board-add-column")).toBeNull();
+
+ mountPoint.querySelector(".board-view-container")
+ ?.dispatchEvent(new MouseEvent("contextmenu", { bubbles: true }));
+ const items = show.mock.calls.at(-1)?.[0].items ?? [];
+ const addColumn = items.find(item =>
+ item && "uiIcon" in item && item.uiIcon === "bx bx-columns");
+ if (!addColumn || !("handler" in addColumn)) {
+ throw new Error("expected an add-column entry");
+ }
+
+ await act(async () => {
+ addColumn.handler?.(addColumn, {} as never);
+ await flush();
+ });
+ const editor = mountPoint.querySelector<HTMLInputElement>(".board-add-column input");
+ if (!editor) throw new Error("expected the add-column editor to be open");
+
+ await act(async () => {
+ editor.dispatchEvent(new FocusEvent("blur"));
+ editor.dispatchEvent(new FocusEvent("focusout", { bubbles: true }));
+ await flush();
+ });
+ expect(mountPoint.querySelector(".board-add-column")).toBeNull();
+
+ show.mockRestore();
+ });
+
/** A column and a card answer for their own presses, and the board does not speak over them. */
it("leaves a press inside a column to the column", async () => {
const { mountPoint } = await setup();
diff --git a/apps/client/src/widgets/collections/board/index.tsx b/apps/client/src/widgets/collections/board/index.tsx
index efaff6f0f9..cf2b880f10 100644
--- a/apps/client/src/widgets/collections/board/index.tsx
+++ b/apps/client/src/widgets/collections/board/index.tsx
@@ -405,6 +405,7 @@ function Board({
let viewConfig = adoptedConfig ?? storedConfig;
const [ includeArchived ] = useNoteLabelBoolean(parentNote, "includeArchived");
const [ inboxEnabled ] = useNoteLabelBoolean(parentNote, "board:showInbox");
+ const [ addColumnHidden ] = useNoteLabelBoolean(parentNote, "board:hideAddColumn");
// Read undefaulted: a board naming no width wears no class, so `--board-column-width` keeps
// whatever it inherits.
const [ storedColumnWidth ] = useNoteLabel(parentNote, COLUMN_WIDTH_LABEL);
@@ -1539,7 +1540,9 @@ function Board({
</div>
- {editing && <editing.AddNewColumn
+ {/* The board's menu opens its column editor in this slot, so the slot is
+ drawn while that editor is open even with the button hidden. */}
+ {editing && (!addColumnHidden || isCreatingColumn) && <editing.AddNewColumn
api={api}
isInRelationMode={isInRelationMode}
columnCount={shownColumns.length}
diff --git a/apps/client/src/widgets/collections/board/properties.spec.tsx b/apps/client/src/widgets/collections/board/properties.spec.tsx
index 6a7ac43701..2cce81ddb8 100644
--- a/apps/client/src/widgets/collections/board/properties.spec.tsx
+++ b/apps/client/src/widgets/collections/board/properties.spec.tsx
@@ -88,6 +88,7 @@ describe("Board properties", () => {
const api = {
setInboxEnabled: async (enabled: boolean) => { toggled.push([ "inbox", enabled ]); },
setArchivedShown: async (shown: boolean) => { toggled.push([ "archived", shown ]); },
+ setAddColumnShown: async (shown: boolean) => { toggled.push([ "add-column", shown ]); },
getCardTemplateIds: () => [ "type:text:text/html" ],
setCardTemplateIds: async (ids: string[]) => { stored.push(ids); },
getStoredPromotedAttributes: () => [ { name: "dueDate" }, { name: "owner" } ],
@@ -159,16 +160,25 @@ describe("Board properties", () => {
const rows = general()
?.querySelectorAll(".tn-card-section:not(.tn-card-section-nested)") ?? [];
- expect(rows.length).toBe(4);
+ expect(rows.length).toBe(5);
expect(toggleAt(0)?.classList.contains("on")).toBe(false);
expect(toggleAt(1)?.classList.contains("on")).toBe(true);
+ expect(toggleAt(2)?.classList.contains("on")).toBe(true);
+
+ labels["board:hideAddColumn"] = "true";
+ act(() => { render(null, container); });
+ draw();
+ expect(toggleAt(2)?.classList.contains("on")).toBe(false);
});
it("asks the board to show each of them", () => {
act(() => { toggleAt(0)?.click(); });
act(() => { toggleAt(1)?.click(); });
+ act(() => { toggleAt(2)?.click(); });
- expect(toggled).toEqual([ [ "inbox", true ], [ "archived", false ] ]);
+ expect(toggled).toEqual([
+ [ "inbox", true ], [ "archived", false ], [ "add-column", false ]
+ ]);
});
function toggleAt(index: number) {
diff --git a/apps/client/src/widgets/collections/board/properties.tsx b/apps/client/src/widgets/collections/board/properties.tsx
index 34a257e1cf..97696593b9 100644
--- a/apps/client/src/widgets/collections/board/properties.tsx
+++ b/apps/client/src/widgets/collections/board/properties.tsx
@@ -66,6 +66,7 @@ export default function BoardProperties({ api, note, shown, onClose }: {
function General({ api, note }: { api: BoardApi, note: FNote }) {
const [ inboxShown ] = useNoteLabelBoolean(note, "board:showInbox");
const [ archivedShown ] = useNoteLabelBoolean(note, "includeArchived");
+ const [ addColumnHidden ] = useNoteLabelBoolean(note, "board:hideAddColumn");
const [ columnWidth ] =
useNoteLabelWithDefault(note, COLUMN_WIDTH_LABEL, DEFAULT_COLUMN_WIDTH);
const defaultSort = useBoardSort(note);
@@ -100,6 +101,17 @@ function General({ api, note }: { api: BoardApi, note: FNote }) {
/>
</OptionCardSection>
+ <OptionCardSection
+ name="board-show-add-column"
+ label={t("board_view.show-add-column-button")}
+ description={t("board_view.show-add-column-button-description")}
+ >
+ <FormToggle
+ currentValue={!addColumnHidden}
+ onChange={(shown) => api.setAddColumnShown(shown)}
+ />
+ </OptionCardSection>
+
{/* `body.mobile` in index.css fixes the column width against the viewport, which is
what the three widths here would otherwise set. */}
{!isMobile() && (
diff --git a/docs/User Guide/User Guide/Collections/Kanban Board.md b/docs/User Guide/User Guide/Collections/Kanban Board.md
index b72a6fe606..b66518edf5 100644
--- a/docs/User Guide/User Guide/Collections/Kanban Board.md
+++ b/docs/User Guide/User Guide/Collections/Kanban Board.md
@@ -19,6 +19,13 @@ You can create a new column by pressing the <span class="tn-icon bx bx-plus"></s
Enter the new name (which must not match another column), optionally select an icon by pressing the circle at the start of the text box, and then press the (+) button or <kbd>Enter</kbd>. Click or tap outside the text box, or press <kbd>Esc</kbd>, to dismiss it.
+Columns can also be added from a context menu:
+
+* To add a column at the end of the board, right-click an empty area of the board and select <span class="tn-icon bx bx-columns"></span> **Add new column**.
+* To add a column next to an existing one, open its column menu and select <span class="tn-icon bx bx-columns"></span> **Add new column** → **Before** (<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Enter</kbd>) or **After** (<kbd>Ctrl</kbd>+<kbd>Enter</kbd>).
+
+Once a board is set up, the **Add column** button can be hidden. To do so, go to <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20menu.md">Note menu</a> → **Board properties** and turn off **Show the "Add column" button** (under the **General** section), or apply the `#board:hideAddColumn` label to the board note. Columns can still be added from the context menus above.
+
### Reordering columns
The order of the columns can be changed at any time. There are several ways to do this:
@@ -114,7 +121,7 @@ Cards with attributes that have no value set are always sorted at the end of the
#### Configuring the default sorting options
-Every new column uses the **Board's default** sorting option, which is initially set to manual sorting on new boards. However, the default can be changed to any other sorting criterion and direction. To configure it, go to **Note menu** → **Board properties** → **Default card order** (under the **General** section).
+Every new column uses the **Board's default** sorting option, which is initially set to manual sorting on new boards. However, the default can be changed to any other sorting criterion and direction. To configure it, go to <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20menu.md">Note menu</a> → **Board properties** → **Default card order** (under the **General** section).
Once the default is changed, all columns set to the **Board's default** sorting option will follow the new sorting options.
@@ -159,7 +166,7 @@ Optionally, the inbox column can also list nested notes from the board collectio
### Changing the width of columns
-There are three predefined widths for board columns: narrow (default), medium, and wide. To change the width, open the **Note menu** → **Board properties** → **Column width** (under the **General** section). This option applies to every column on the board, except in the mobile version.
+There are three predefined widths for board columns: narrow (default), medium, and wide. To change the width, open the <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20menu.md">Note menu</a> → **Board properties** → **Column width** (under the **General** section). This option applies to every column on the board, except in the mobile version.
The same option is also available through the `#board:columnWidth` label (read more about <a class="reference-link" href="../Advanced%20Usage/Attributes.md">Attributes</a>) on the board note, which accepts “`narrow`”, “`medium`”, or “`wide`” as its value.
@@ -310,7 +317,7 @@ By default, the face of a card displays a minimal set of information: the title,
To create a new attribute, follow these steps:
-1. Go to **Note menu** → **Board properties**, find the **Card attributes** section, and then press the <span class="tn-icon bx bx-plus"></span> **Create a new attribute** button.
+1. Go to <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20menu.md">Note menu</a> → **Board properties**, find the **Card attributes** section, and then press the <span class="tn-icon bx bx-plus"></span> **Create a new attribute** button.
2. Enter a name for the attribute. This is the internal name used by Trilium, so do not use spaces or special characters.
3. Select a type (text, number, checkbox, and so on).
4. Set the display name. This is the name shown on the card.
@@ -335,7 +342,7 @@ For attributes of the “select” or “checkbox” type, you can quickly chang
#### Reordering, hiding, redefining, and deleting custom attributes
-Go to **Note menu** → **Board properties**. Under the **Card attributes** section, you can:
+Go to <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20menu.md">Note menu</a> → **Board properties**. Under the **Card attributes** section, you can:
* Hold the **\=** handle shown beside an attribute, and then drag the item up or down to reorder the attributes. This determines the order in which the attributes are displayed on the card.
* Turn off the toggle to hide an attribute from the card's face. The attribute remains available when you edit the card. For the current grouping attribute, the toggle is disabled.
@@ -350,7 +357,7 @@ If cards define an attribute with the same name but a different type or differen
When you create a new card, Trilium offers four templates by default: **Text**, **Markdown**, **Canvas**, and **Spreadsheet**. You can customize this list to include other note types or custom templates with predefined placeholder content and prefilled card attributes.
-To customize the card templates, go to **Note menu** → **Board properties** and find **Card templates**. Here you can:
+To customize the card templates, go to <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20menu.md">Note menu</a> → **Board properties** and find **Card templates**. Here you can:
* Include a note type or note template already created in your knowledge base by pressing the <span class="tn-icon bx bx-list-plus"></span> **Add existing template** button and then selecting the desired note type or template.
* Create a new template by pressing the <span class="tn-icon bx bx-plus"></span> **Create a new template** button. The template editor will open, where you can define the icon, title, default attribute values, and default content. The note template will be created as a child of the board collection.
@@ -388,7 +395,7 @@ Switching the grouping attribute lets you view your cards by priority, category,
#### Deleting a grouping attribute
-To delete a grouping attribute, go to **Note menu** → **Board properties**, find the attribute under the **Card attributes** section, and press the corresponding <span class="tn-icon bx bx-trash"></span> button.
+To delete a grouping attribute, go to <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20menu.md">Note menu</a> → **Board properties**, find the attribute under the **Card attributes** section, and press the corresponding <span class="tn-icon bx bx-trash"></span> button.
#### Grouping by relations
diff --git a/packages/commons/src/lib/builtin_attributes.ts b/packages/commons/src/lib/builtin_attributes.ts
index a4cbf93b63..4c9e3df198 100644
--- a/packages/commons/src/lib/builtin_attributes.ts
+++ b/packages/commons/src/lib/builtin_attributes.ts
@@ -270,6 +270,7 @@ const BUILTIN_ATTRIBUTES = [
{ type: "label", name: "maxNestingDepth", valueType: "number", hasUserValue: true },
{ type: "label", name: "includeArchived", valueType: "boolean", hasUserValue: true },
{ type: "label", name: "board:showInbox", valueType: "boolean", hasUserValue: true },
+ { type: "label", name: "board:hideAddColumn", valueType: "boolean", hasUserValue: true },
// Carried by a card that stands in for another note: opening it navigates there instead.
{ type: "relation", name: "board:cardRedirectTo" },
// The previous name of the relation above. Still read, so existing boards keep redirecting.