Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client/collections/board: implement an inbox column
Adorian Doran1d9dcf281231
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 6b267cd620..435b79d1ef 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -3347,6 +3347,7 @@"new-column-relation": "Relation"},"book_properties_config": {+ "board-inbox-column": "Inbox column","hide-weekends": "Hide weekends","display-week-numbers": "Display week numbers","map-style": "Map style",@@ -3375,6 +3376,9 @@"archive-column": "Archive column","unarchive-column": "Unarchive column","archived-badge": "Archived",+ "inbox": "Inbox",+ "inbox-nested": "Include nested notes",+ "inbox-remove": "Remove inbox column","card-count_one": "{{count}} item","card-count_other": "{{count}} items","card-count-with-archived_one": "{{count}} active item, {{archived}} archived",diff --git a/apps/client/src/widgets/collections/board/api.ts b/apps/client/src/widgets/collections/board/api.tsindex e4cf65f5e4..a94e508be6 100644--- a/apps/client/src/widgets/collections/board/api.ts+++ b/apps/client/src/widgets/collections/board/api.ts@@ -16,7 +16,7 @@ import toast from "../../../services/toast";import { BoardColumnData, BoardViewData } from ".";import {type BoardStatusDefinition, canStoreColumnsInDefinition, DEFAULT_COLUMN_ICON, DEFAULT_GROUP_BY-} from "./columns";+, INBOX_COLUMN } from "./columns";import { ColumnMap } from "./data";/** One write's claim on a column, held until that write lands or is taken back. */@@ -167,6 +167,13 @@ export default class BoardApi {}async changeColumn(noteId: string, newColumn: string) {+ // The inbox is where the cards carrying no value stand, so filing one there takes its value+ // away rather than writing an empty one. Every path comes through here: the drag, the+ // keyboard, and the menu.+ if (newColumn === INBOX_COLUMN) {+ return this.removeFromBoard(noteId);+ }+if (this.isRelationMode) {await attributes.setRelation(noteId, this.statusAttribute, newColumn);} else {@@ -294,6 +301,15 @@ export default class BoardApi {this.updateColumn(column, { color: color ?? undefined });}+ /**+ * What a column is called on screen, which is the value its cards carry everywhere but the+ * inbox: that one stands for the cards carrying no value, so it has a name of its own and+ * cannot be renamed.+ */+ getColumnTitle(column: string) {+ return column === INBOX_COLUMN ? t("board_view.inbox") : column;+ }+/*** The icon a column heading shows, for anything else that stands in for the column.*@@ -328,6 +344,20 @@ export default class BoardApi {return this.statusDefinition?.definition.promotedAlias || t("board_view.status-header");}+ /**+ * Puts the inbox column away, which is a matter of the board's own setting rather than of the+ * column: the stored entry stays where it is, so its icon, colour and place are waiting when it+ * is switched back on.+ */+ async disableInbox() {+ await attributes.setBooleanWithInheritance(this.parentNote, "enableInboxColumn", false);+ }++ /** Whether the inbox reaches past the board's own children, down to the children of cards. */+ async setInboxNested(nested: boolean) {+ await this.updateColumn(INBOX_COLUMN, { nested });+ }+/** Whether a column is archived, which the board shows only while archived notes are shown. */isColumnArchived(column: string) {return !!this.viewConfig?.columns?.find(col => col.value === column)?.archived;@@ -520,6 +550,9 @@ export default class BoardApi {return;}+ // The definition lists the values a card can carry, and the inbox stands for carrying none.+ columns = columns.filter(column => column !== INBOX_COLUMN);+// A board showing nothing has no column list to describe and must not gain an empty// definition; one that already owns one is still emptied, since that is its last column going.if (!columns.length && !this.statusDefinition?.isOwned) {diff --git a/apps/client/src/widgets/collections/board/column.tsx b/apps/client/src/widgets/collections/board/column.tsxindex eed1ad670c..82f19c717e 100644--- a/apps/client/src/widgets/collections/board/column.tsx+++ b/apps/client/src/widgets/collections/board/column.tsx@@ -21,7 +21,7 @@ import NoteLink from "../../react/NoteLink";import { BoardActionsContext, BoardDragStateContext, TitleEditor } from ".";import BoardApi from "./api";import Card, { CARD_CLIPBOARD_TYPE, CardDragData } from "./card";-import { DEFAULT_COLUMN_ICON } from "./columns";+import { DEFAULT_COLUMN_ICON, INBOX_COLUMN } from "./columns";import { openColumnContextMenu } from "./context_menu";interface DragContext {@@ -40,6 +40,7 @@ export default function Column({icon,color,archived,+ nested,isDraggingColumn,columnItems,api,@@ -55,6 +56,8 @@ export default function Column({color?: string,/** Whether the column is archived. Only ever rendered while archived notes are shown. */archived?: boolean,+ /** Whether the inbox reaches past the board's own children. Meaningless on any other column. */+ nested?: boolean,isDraggingColumn: boolean,api: BoardApi,parentNote: FNote,@@ -85,6 +88,7 @@ export default function Column({index: columnIndex,color,archived,+ nested,onEditTitle: () => setColumnNameToEdit(column),onNewItem: () => setIsCreatingNewItem(true),onAddColumn: async (direction) => {@@ -98,7 +102,7 @@ export default function Column({}});}, [- api, column, color, archived, columns, columnIndex,+ api, column, color, archived, nested, columns, columnIndex,setColumnNameToEdit, onMoveColumn, onFocusColumn]);@@ -109,7 +113,8 @@ export default function Column({}, [ color ]);const handleTitleKeyDown = useCallback((e: KeyboardEvent) => {- if (e.key === "F2") {+ // The inbox has no name of its own to edit, its cards being the ones carrying none.+ if (e.key === "F2" && column !== INBOX_COLUMN) {setColumnNameToEdit(column);}}, [ column ]);@@ -184,13 +189,13 @@ export default function Column({className="title"// In relation mode the title is a link to the note the column stands// for, and the first of the two clicks has already followed it.- onDblClick={isInRelationMode+ onDblClick={isInRelationMode || column === INBOX_COLUMN? undefined: () => setColumnNameToEdit(column)}>{isInRelationMode? <NoteLink notePath={column} showNoteIcon />- : column}+ : api.getColumnTitle(column)}</span><div className="spacer" /><CountBadge items={columnItems} />diff --git a/apps/client/src/widgets/collections/board/columns.spec.ts b/apps/client/src/widgets/collections/board/columns.spec.tsindex 35db9672b9..784b0c847c 100644--- a/apps/client/src/widgets/collections/board/columns.spec.ts+++ b/apps/client/src/widgets/collections/board/columns.spec.ts@@ -169,3 +169,25 @@ function buildBoard(return board;}++describe("the inbox column", () => {+ /** A column is its grouping value, and the inbox stands for the cards carrying none. */+ it("is kept where the board's own list carries it", () => {+ expect(resolveBoardColumns([ "To Do" ], [ "", "To Do" ], [ "To Do" ]))+ .toEqual([ "", "To Do" ]);+ });++ it("is not made by a note carrying no value, nor by a gap in the definition", () => {+ // `options=To Do;;Done` names nothing in the middle, and an unfiled note names nothing.+ expect(resolveBoardColumns([ "To Do", "", "Done" ], [ "To Do", "Done" ], [ "", "To Do" ]))+ .toEqual([ "To Do", "Done" ]);+ });++ /** Deleting is recorded as `undefined`, which the inbox's own name must not be taken for. */+ it("is told apart from a column being deleted", () => {+ const pending = new Map([ [ "Done", undefined ] ]);++ expect(resolveBoardColumns([ "To Do", "Done" ], [ "", "To Do", "Done" ], [], pending))+ .toEqual([ "", "To Do" ]);+ });+});diff --git a/apps/client/src/widgets/collections/board/columns.ts b/apps/client/src/widgets/collections/board/columns.tsindex d90ce39eef..f0f3aae0eb 100644--- a/apps/client/src/widgets/collections/board/columns.ts+++ b/apps/client/src/widgets/collections/board/columns.ts@@ -17,6 +17,15 @@ export const DEFAULT_GROUP_BY = "status";/** The icon a column shows until one is picked for it. */export const DEFAULT_COLUMN_ICON = "bx bx-circle";+/**+ * The value the inbox column is known by: the one a card carries when it carries none.+ *+ * A column is its grouping value everywhere on the board, and what the inbox gathers is the notes+ * with no value at all, so the empty string is the value it stands for. It is told apart from a+ * column being deleted, which is recorded as `undefined` rather than as an empty name.+ */+export const INBOX_COLUMN = "";+export interface BoardStatusDefinition {/** The definition attribute, wherever it is owned. */attribute: FAttribute;@@ -73,6 +82,11 @@ export function getStatusDefinition(parentNote: FNote, groupBy: string): BoardSt* Having none at all is the ordinary case for a board created now, and the answer is yes: the* definition the board writes is its own from the start.*/+/** Whether a value names a column of its own, as against standing for the notes carrying none. */+function named(value: string) {+ return value.trim() !== INBOX_COLUMN;+}+export function canStoreColumnsInDefinition(statusDefinition: BoardStatusDefinition | undefined): boolean {if (!statusDefinition) {// Nothing defines the label yet, so a definition the board creates is its own.@@ -126,7 +140,8 @@ export function resolveBoardColumns(for (const candidate of candidates) {const trimmed = candidate.trim();const value = pendingRenames.has(trimmed) ? pendingRenames.get(trimmed) : trimmed;- if (!value || seen.has(value)) continue;+ // `undefined` is a column being deleted, which is not the same as the inbox's own name.+ if (value === undefined || seen.has(value)) continue;seen.add(value);columns.push(value);}@@ -134,7 +149,14 @@ export function resolveBoardColumns(return columns;};- const columns = resolve([ ...definitionOptions, ...persistedColumns, ...discoveredValues ]);+ // The board's own list is the only source that can bring the inbox: a note carrying no value is+ // what the inbox gathers rather than a column to make, and a definition written with a gap in+ // it (`options=To Do;;Done`) names nothing.+ const columns = resolve([+ ...definitionOptions.filter(named),+ ...persistedColumns,+ ...discoveredValues.filter(named)+ ]);const persisted = resolve(persistedColumns);// The definition leads on which columns there are, but not on the order once the board's owndiff --git a/apps/client/src/widgets/collections/board/context_menu.spec.ts b/apps/client/src/widgets/collections/board/context_menu.spec.tsindex 5b010060d7..e36138778e 100644--- a/apps/client/src/widgets/collections/board/context_menu.spec.ts+++ b/apps/client/src/widgets/collections/board/context_menu.spec.ts@@ -30,7 +30,10 @@ describe("Board column context menu", () => {function openMenu(api: BoardApi,- column: { color?: string, archived?: boolean, columns?: string[], index?: number } = {},+ column: {+ value?: string, color?: string, archived?: boolean,+ columns?: string[], index?: number, nested?: boolean+ } = {},callbacks: {onEditTitle?: () => void,onNewItem?: () => void,@@ -46,7 +49,9 @@ describe("Board column context menu", () => {pageY: 0} as ContextMenuEvent;- openColumnContextMenu(api, event, {+ // Every column menu asks what a column is called; a test says so only when that matters.+ const withDefaults = Object.assign({ getColumnTitle: (name: string) => name }, api);+ openColumnContextMenu(withDefaults, event, {value: "To Do",columns: [ "To Do" ],index: 0,@@ -109,6 +114,51 @@ describe("Board column context menu", () => {expect(api.setColumnArchived).toHaveBeenLastCalledWith("To Do", false);});+ /**+ * The inbox stands for the cards carrying no value, so it has no name to rename and nothing to+ * archive; it is put away by the board's own setting instead.+ */+ it("offers the inbox neither a rename nor an archive, and puts it away instead", () => {+ const api = {+ getColumnIcon: () => DEFAULT_COLUMN_ICON,+ getColumnColorClass: () => "",+ isColumnArchived: () => false,+ disableInbox: vi.fn(async () => {}),+ setInboxNested: vi.fn(async () => {})+ } as unknown as BoardApi;++ const items = openMenu(api, { value: "", columns: [ "", "To Do" ], index: 0 });+ const icons = items.filter(item => item && "uiIcon" in item)+ .map(item => "uiIcon" in item ? item.uiIcon : undefined);++ expect(icons).not.toContain("bx bx-edit-alt");+ expect(icons).not.toContain("bx bx-archive");++ const remove = items.find(item =>+ item && "uiIcon" in item && item.uiIcon === "bx bx-trash");+ if (!remove || !("handler" in remove)) throw new Error("expected a remove entry");+ remove.handler?.(remove, {} as never);+ expect(api.disableInbox).toHaveBeenCalled();+ });++ it("offers the inbox nesting as a state it shows, and writes the other one", () => {+ const api = {+ getColumnIcon: () => DEFAULT_COLUMN_ICON,+ getColumnColorClass: () => "",+ isColumnArchived: () => false,+ setInboxNested: vi.fn(async () => {})+ } as unknown as BoardApi;++ const items = openMenu(api, { value: "", columns: [ "", "To Do" ], index: 0 });+ const nesting = items.find(item =>+ item && "uiIcon" in item && item.uiIcon === "bx bx-subdirectory-right");+ if (!nesting || !("handler" in nesting)) throw new Error("expected a nesting entry");++ expect(nesting).toMatchObject({ checked: false });+ nesting.handler?.(nesting, {} as never);+ expect(api.setInboxNested).toHaveBeenCalledWith(true);+ });+it("orders the entries, keeping the safe way out ahead of deleting", () => {const titled = openMenu({} as BoardApi).filter(item => item && "uiIcon" in item);expect(titled.map(item => "uiIcon" in item ? item.uiIcon : undefined))@@ -355,7 +405,8 @@ describe("Board item context menu", () => {// Every item menu asks what the board calls its grouping field; a test says so only when// that is what it is about.- const withDefaults = Object.assign({ getStatusLabel: () => "Status" }, api);+ const withDefaults = Object.assign(+ { getStatusLabel: () => "Status", getColumnTitle: (name: string) => name }, api);openNoteContextMenu(withDefaults, event, buildNote({ title: "Card" }) as FNote, "branchId", column,focusCard);diff --git a/apps/client/src/widgets/collections/board/context_menu.ts b/apps/client/src/widgets/collections/board/context_menu.tsindex 7896292d94..f86ec7b5f8 100644--- a/apps/client/src/widgets/collections/board/context_menu.ts+++ b/apps/client/src/widgets/collections/board/context_menu.ts@@ -12,6 +12,7 @@ import { t } from "../../../services/i18n";import { escapeHtml } from "../../../services/utils";import ColorPicker from "../../react/ColorPicker";import Api from "./api";+import { INBOX_COLUMN } from "./columns";/** What the column menu is opened for: the column itself, and what it can be asked to do. */interface ColumnMenuTarget {@@ -22,6 +23,8 @@ interface ColumnMenuTarget {index: number;color?: string;archived?: boolean;+ /** Whether the inbox reaches past the board's own children. Meaningless on any other column. */+ nested?: boolean;/** Puts the title into its inline editor, the menu being the only way there besides F2. */onEditTitle: () => void;/** Opens the column's own new-item editor, the same one its button opens. */@@ -33,6 +36,9 @@ interface ColumnMenuTarget {}export function openColumnContextMenu(api: Api, event: ContextMenuEvent, column: ColumnMenuTarget) {+ // The inbox stands for the cards carrying no value, so it has no name to rename and nothing to+ // archive: it is put away by its own setting instead, which is what its delete entry does.+ const isInbox = column.value === INBOX_COLUMN;event.preventDefault();event.stopPropagation();@@ -41,12 +47,18 @@ export function openColumnContextMenu(api: Api, event: ContextMenuEvent, column:x: event.pageX,y: event.pageY,items: [- {+ ...(isInbox ? [] : [ {title: t("board_view.rename-column"),uiIcon: "bx bx-edit-alt",shortcut: "F2",handler: column.onEditTitle- },+ } ]),+ ...(isInbox ? [ {+ title: t("board_view.inbox-nested"),+ uiIcon: "bx bx-subdirectory-right",+ checked: !!column.nested,+ handler: () => api.setInboxNested(!column.nested)+ } ] : []),{ kind: "separator" },{title: t("board_view.add-new-item"),@@ -89,7 +101,7 @@ export function openColumnContextMenu(api: Api, event: ContextMenuEvent, column:items: buildMoveColumnItems(api, column)},{ kind: "separator" },- column.archived+ ...(isInbox ? [] : [ column.archived? {title: t("board_view.unarchive-column"),uiIcon: "bx bx-archive-out",@@ -99,13 +111,20 @@ export function openColumnContextMenu(api: Api, event: ContextMenuEvent, column:title: t("board_view.archive-column"),uiIcon: "bx bx-archive",handler: () => api.setColumnArchived(column.value, true)+ } ]),+ isInbox+ ? {+ title: t("board_view.inbox-remove"),+ uiIcon: "bx bx-trash",+ shortcut: "Delete",+ handler: () => api.disableInbox()+ }+ : {+ title: t("board_view.delete-column"),+ uiIcon: "bx bx-trash",+ shortcut: "Delete",+ handler: () => api.confirmAndRemoveColumn(column.value)},- {- title: t("board_view.delete-column"),- uiIcon: "bx bx-trash",- shortcut: "Delete",- handler: () => api.confirmAndRemoveColumn(column.value)- },{ kind: "separator" },{kind: "custom",@@ -136,11 +155,13 @@ function buildMoveColumnItems(api: Api, column: ColumnMenuTarget): MenuItem<strireturn [];}+ const title = api.getColumnTitle(name);+return [ {// Boxed the way the status list boxes its names, so a long one is cut rather than// widening the menu. What `t()` interpolates it has already escaped.title: `<span class="board-column-name">`- + `${t("board_view.move-column-after", { column: name })}</span>`,+ + `${t("board_view.move-column-after", { column: title })}</span>`,className: "board-column-item",uiIcon: api.getColumnIcon(name),iconColorClass: api.getColumnColorClass(name),@@ -191,7 +212,7 @@ function buildColumnItems(// about its width. What a crafted name would plant there is escaped into the text it is// meant to be; every other title the board builds from a name goes through `t()`, which// escapes what it interpolates.- title: `<span class="board-column-name">${escapeHtml(name)}</span>`,+ title: `<span class="board-column-name">${escapeHtml(api.getColumnTitle(name))}</span>`,uiIcon: api.getColumnIcon(name),iconColorClass: api.getColumnColorClass(name),// The one it is already under is shown rather than hidden, so the list reads as the wholediff --git a/apps/client/src/widgets/collections/board/data.spec.ts b/apps/client/src/widgets/collections/board/data.spec.tsindex 0e060d678e..faf3665e4b 100644--- a/apps/client/src/widgets/collections/board/data.spec.ts+++ b/apps/client/src/widgets/collections/board/data.spec.ts@@ -217,3 +217,98 @@ describe("Board data", () => {});});});++describe("the inbox column", () => {+ const INBOX = { columns: [ { value: "" }, { value: "To Do" } ] };++ it("gathers the cards carrying no value, where the board keeps one", async () => {+ const board = buildNote({+ title: "Board",+ children: [+ { title: "Filed", "#status": "To Do" },+ { title: "Unfiled" }+ ]+ });++ const { byColumn, columns } = await getBoardData(+ board, "status", INBOX, false, [], new Map(), true);++ expect(columns).toEqual([ "", "To Do" ]);+ expect(byColumn.get("")?.map(item => item.note.title)).toEqual([ "Unfiled" ]);+ });++ it("leaves them off a board whose inbox is switched off", async () => {+ const board = buildNote({+ title: "Board",+ children: [+ { title: "Filed", "#status": "To Do" },+ { title: "Unfiled" }+ ]+ });++ const { byColumn, columns } = await getBoardData(+ board, "status", { columns: [ { value: "To Do" } ] }, false, [], new Map(), false);++ expect(columns).toEqual([ "To Do" ]);+ expect(byColumn.has("")).toBe(false);+ });+++ /** Switching it on is what puts it on the board, at the head of it. */+ it("puts the column at the head of a board that has never had one", async () => {+ const board = buildNote({+ title: "Board",+ children: [ { title: "Filed", "#status": "To Do" }, { title: "Unfiled" } ]+ });++ const { columns, newPersistedData, byColumn } = await getBoardData(+ board, "status", { columns: [ { value: "To Do" } ] }, false, [], new Map(), true);++ expect(columns).toEqual([ "", "To Do" ]);+ expect(byColumn.get("")?.map(item => item.note.title)).toEqual([ "Unfiled" ]);+ // Written down, so what it is given from here on has somewhere to live.+ expect(newPersistedData?.columns?.map(column => column.value)).toEqual([ "", "To Do" ]);+ });++ /**+ * The toggle decides what is shown, not what is stored. Dropping the entry while the toggle is+ * off would rewrite the attachment without it, and its icon, colour and place would be gone by+ * the time it is switched back on.+ */+ it("keeps the stored entry while it gathers nothing", async () => {+ const board = buildNote({ title: "Board", children: [ { title: "Unfiled" } ] });+ const stored = { columns: [ { value: "", icon: "bx bx-inbox" }, { value: "To Do" } ] };++ const { byColumn, columns, newPersistedData } = await getBoardData(+ board, "status", stored, false, [], new Map(), false);++ // Still a column as far as the board is concerned, and empty.+ expect(columns).toEqual([ "", "To Do" ]);+ expect(byColumn.get("")).toEqual([]);+ // Nothing is rewritten, so what the entry carries is still there to come back to.+ expect(newPersistedData).toBeUndefined();+ });++ /**+ * A note below the board's own children is a card's child. The inbox reaches that far only+ * where it is told to, which is why the switch is off to begin with.+ */+ it("reaches past the board's own children only when told to", async () => {+ const board = buildNote({+ title: "Board",+ children: [+ { title: "Filed", "#status": "To Do", children: [ { title: "Deep" } ] },+ { title: "Unfiled" }+ ]+ });++ const shallow = await getBoardData(board, "status", INBOX, false, [], new Map(), true);+ expect(shallow.byColumn.get("")?.map(item => item.note.title)).toEqual([ "Unfiled" ]);++ const nested = await getBoardData(+ board, "status", { columns: [ { value: "", nested: true }, { value: "To Do" } ] },+ false, [], new Map(), true);+ expect(nested.byColumn.get("")?.map(item => item.note.title).sort())+ .toEqual([ "Deep", "Unfiled" ]);+ });+});diff --git a/apps/client/src/widgets/collections/board/data.ts b/apps/client/src/widgets/collections/board/data.tsindex 4f95acef39..3a9446085e 100644--- a/apps/client/src/widgets/collections/board/data.ts+++ b/apps/client/src/widgets/collections/board/data.ts@@ -1,6 +1,6 @@import FBranch from "../../../entities/fbranch";import FNote from "../../../entities/fnote";-import { resolveBoardColumns } from "./columns";+import { INBOX_COLUMN, resolveBoardColumns } from "./columns";import { BoardColumnData, BoardViewData } from "./index";export type ColumnMap = Map<string, {@@ -22,14 +22,30 @@ export async function getBoardData(persistedData: BoardViewData,includeArchived: boolean,definitionOptions: string[] = [],- pendingRenames: ReadonlyMap<string, string | undefined> = new Map()+ pendingRenames: ReadonlyMap<string, string | undefined> = new Map(),+ /** Whether the board is set to keep an inbox, which is what decides if one gathers anything. */+ inboxEnabled = false) {const byColumn: ColumnMap = new Map();+ const storedColumnValues = (persistedData.columns ?? []).map(c => c.value);+ // Switching the inbox on is what puts it on the board, at the head of it. From then on the+ // entry is the board's own: it keeps whatever icon, colour and place it is given, and switching+ // the inbox off leaves it there rather than taking it away.+ const persistedColumns = inboxEnabled && !storedColumnValues.includes(INBOX_COLUMN)+ ? [ INBOX_COLUMN, ...storedColumnValues ]+ : storedColumnValues;++ // Only a board that keeps an inbox has anywhere to put a note carrying no value; on any other+ // one such a note is not on the board at all, as it has always been.+ const inbox = inboxEnabled+ ? { nested: !!persistedData.columns?.find(col => col.value === INBOX_COLUMN)?.nested }+ : undefined;// First, scan all notes to find what columns actually exist- await recursiveGroupBy(parentNote.getChildBranches(), byColumn, groupByColumn, includeArchived, new Set<string>());+ await recursiveGroupBy(+ parentNote.getChildBranches(), byColumn, groupByColumn, includeArchived,+ new Set<string>(), inbox, 0);- const persistedColumns = (persistedData.columns ?? []).map(c => c.value);const discoveredValues = [ ...byColumn.keys() ];const columns = resolveBoardColumns(definitionOptions, persistedColumns, discoveredValues, pendingRenames);@@ -54,8 +70,8 @@ export async function getBoardData(// The attachment mirrors the resolved list, so a board whose columns now come from its definition// stays readable by anything still reading the attachment. Written only when it actually differs,// or every refresh would save.- const hasChanges = persistedColumns.length !== columns.length- || persistedColumns.some((value, index) => columns[index] !== value);+ const hasChanges = storedColumnValues.length !== columns.length+ || storedColumnValues.some((value, index) => columns[index] !== value);const storedColumns = indexColumnsByResolvedName(persistedData, pendingRenames);return {@@ -88,7 +104,7 @@ function indexColumnsByResolvedName(for (const column of persistedData.columns ?? []) {const { value } = column;const name = pendingRenames.has(value) ? pendingRenames.get(value) : value;- if (name) {+ if (name !== undefined) {byName.set(name, { ...column, value: name });}}@@ -110,17 +126,30 @@ function regroupRenamedCards(}}-async function recursiveGroupBy(branches: FBranch[], byColumn: ColumnMap, groupByColumn: string, includeArchived: boolean, seenNoteIds: Set<string>) {+/**+ * @param inbox where the board keeps the notes carrying no value, absent where it keeps none.+ * @param depth how far below the board the branches stand, the board's own children being 0.+ */+async function recursiveGroupBy(+ branches: FBranch[], byColumn: ColumnMap, groupByColumn: string, includeArchived: boolean,+ seenNoteIds: Set<string>, inbox: { nested: boolean } | undefined, depth: number+) {for (const branch of branches) {const note = await branch.getNote();if (!note || (!includeArchived && note.isArchived)) continue;if (note.type !== "search" && note.hasChildren()) {- await recursiveGroupBy(note.getChildBranches(), byColumn, groupByColumn, includeArchived, seenNoteIds);+ await recursiveGroupBy(+ note.getChildBranches(), byColumn, groupByColumn, includeArchived,+ seenNoteIds, inbox, depth + 1);}- const group = note.getLabelOrRelation(groupByColumn);- if (!group || seenNoteIds.has(note.noteId)) {+ // A note carrying no value goes to the inbox, where the board keeps one and is set to reach+ // this far down. Anything deeper than the board's own children is a card's child, which the+ // inbox gathers only when it is told to.+ const value = note.getLabelOrRelation(groupByColumn);+ const group = value || (inbox && (depth === 0 || inbox.nested) ? INBOX_COLUMN : undefined);+ if (group === undefined || seenNoteIds.has(note.noteId)) {continue;}diff --git a/apps/client/src/widgets/collections/board/index.tsx b/apps/client/src/widgets/collections/board/index.tsxindex 43d3e1bae7..eb7351a02c 100644--- a/apps/client/src/widgets/collections/board/index.tsx+++ b/apps/client/src/widgets/collections/board/index.tsx@@ -23,7 +23,7 @@ import { onWheelHorizontalScroll } from "../../widget_utils";import { ViewModeProps } from "../interface";import Api, { getPendingWrites, PendingColumnWrites, settleColumn } from "./api";import BoardApi from "./api";-import { DEFAULT_GROUP_BY, getStatusDefinition } from "./columns";+import { DEFAULT_GROUP_BY, getStatusDefinition, INBOX_COLUMN } from "./columns";import Column from "./column";import { ColumnMap, getBoardData } from "./data";import { useBoardKeyboard } from "./keyboard";@@ -40,6 +40,11 @@ export interface BoardColumnData {color?: string;/** Whether the column is archived, absent while it is not. */archived?: boolean;+ /**+ * Whether the inbox column gathers notes below the board's own children as well. Meaningless on+ * any other column, which stands for a value a note carries wherever it stands.+ */+ nested?: boolean;}interface CardDrag {@@ -161,6 +166,7 @@ const BOARD_HINTS: ShortcutHintDefinition = [export default function BoardView({ note: parentNote, noteIds, viewConfig, saveConfig }: ViewModeProps<BoardViewData>) {const [ statusAttributeWithPrefix ] = useNoteLabelWithDefault(parentNote, "board:groupBy", DEFAULT_GROUP_BY);const [ includeArchived ] = useNoteLabelBoolean(parentNote, "includeArchived");+ const [ inboxEnabled ] = useNoteLabelBoolean(parentNote, "enableInboxColumn");const [ byColumn, setByColumn ] = useState<ColumnMap>();const [ columns, setColumns ] = useState<string[]>();const [ isInRelationMode, setIsRelationMode ] = useState(false);@@ -197,14 +203,23 @@ export default function BoardView({ note: parentNote, noteIds, viewConfig, saveC};refreshSeqRef.current++;}+ // Resolution keeps the inbox on the strength of the config alone, so its icon, colour and place+ // survive the toggle being off; what the toggle decides is whether the board shows it and+ // offers it. Rewriting the attachment without it would be what loses those settings.+ const usableColumns = useMemo(+ () => (columns ?? []).filter(column => column !== INBOX_COLUMN || inboxEnabled),+ [ columns, inboxEnabled ]);const statusDefinition = useMemo(() => getStatusDefinition(parentNote, statusAttributeWithPrefix),[ parentNote, statusAttributeWithPrefix, definitionRevision ]);const api = useMemo(() => {return new Api(- byColumn, columns ?? [], parentNote, statusAttributeWithPrefix, viewConfig ?? {},+ byColumn, usableColumns, parentNote, statusAttributeWithPrefix, viewConfig ?? {},saveConfig, setBranchIdToEdit, pendingRenamesRef.current.writes, statusDefinition);- }, [ byColumn, columns, parentNote, statusAttributeWithPrefix, viewConfig, saveConfig, setBranchIdToEdit, statusDefinition ]);+ }, [+ byColumn, usableColumns, parentNote, statusAttributeWithPrefix, viewConfig,+ saveConfig, setBranchIdToEdit, statusDefinition+ ]);// Every member is one of useState's own setters, so this value is built once and never changes// identity -- a drag cannot reach anything that reads only this.const boardActions = useMemo<BoardActions>(() => ({@@ -228,9 +243,9 @@ export default function BoardView({ note: parentNote, noteIds, viewConfig, saveC// an archived column would be erased from the config and the definition instead of kept out of// sight. `columnDropPosition` indexes this list, so a drag places columns as they are shown.const shownColumns = useMemo(- () => (columns ?? []).filter(column =>+ () => usableColumns.filter(column =>includeArchived || !storedColumns.get(column)?.archived),- [ columns, storedColumns, includeArchived ]);+ [ usableColumns, storedColumns, includeArchived ]);const containerRef = useRef<HTMLDivElement>(null);@@ -251,7 +266,7 @@ export default function BoardView({ note: parentNote, noteIds, viewConfig, saveCgetBoardData(parentNote, statusAttributeWithPrefix, viewConfig ?? {}, includeArchived,- statusDefinition?.options ?? [], pendingRenamesRef.current.writes.renames)+ statusDefinition?.options ?? [], pendingRenamesRef.current.writes.renames, inboxEnabled).then(({ byColumn, columns, newPersistedData, isInRelationMode, settledRenames }) => {if (refreshId !== refreshSeqRef.current) return;@@ -287,7 +302,9 @@ export default function BoardView({ note: parentNote, noteIds, viewConfig, saveC});}- useEffect(refresh, [ parentNote, noteIds, viewConfig, statusAttributeWithPrefix, statusDefinition ]);+ useEffect(refresh, [+ parentNote, noteIds, viewConfig, statusAttributeWithPrefix, statusDefinition, inboxEnabled+ ]);// The drag reports where the column landed among the ones on screen, which is not where it// landed among them all once some are archived and hidden. Translated here so a reorder leaves@@ -383,6 +400,7 @@ export default function BoardView({ note: parentNote, noteIds, viewConfig, saveCicon={storedColumns.get(column)?.icon}color={storedColumns.get(column)?.color}archived={storedColumns.get(column)?.archived}+ nested={storedColumns.get(column)?.nested}columnIndex={index}columns={shownColumns}onMoveColumn={handleColumnDrop}diff --git a/apps/client/src/widgets/ribbon/collection-properties-config.tsx b/apps/client/src/widgets/ribbon/collection-properties-config.tsxindex 98093a0a7b..33dac784e1 100644--- a/apps/client/src/widgets/ribbon/collection-properties-config.tsx+++ b/apps/client/src/widgets/ribbon/collection-properties-config.tsx@@ -148,7 +148,14 @@ export const bookPropertiesConfig: Record<ViewTypeOptions, BookConfig> = {]},board: {- properties: []+ properties: [+ {+ label: t("book_properties_config.board-inbox-column"),+ type: "checkbox",+ icon: "bx bx-inbox",+ bindToLabel: "enableInboxColumn"+ }+ ]},presentation: {properties: [diff --git a/packages/commons/src/lib/builtin_attributes.ts b/packages/commons/src/lib/builtin_attributes.tsindex 37d46240b5..9e24086f20 100644--- a/packages/commons/src/lib/builtin_attributes.ts+++ b/packages/commons/src/lib/builtin_attributes.ts@@ -268,6 +268,7 @@ const BUILTIN_ATTRIBUTES = [{ type: "label", name: "isHidden", valueType: "boolean" },{ type: "label", name: "maxNestingDepth", valueType: "number", hasUserValue: true },{ type: "label", name: "includeArchived", valueType: "boolean", hasUserValue: true },+ { type: "label", name: "enableInboxColumn", valueType: "boolean", hasUserValue: true },// FullCalendar's own view names, which is what the calendar hands back when the view is switched.{ type: "label", name: "calendar:view", valueType: "select", hasUserValue: true, selectOptions: ["timeGridDay", "timeGridWeek", "dayGridMonth", "multiMonthYear", "listMonth"