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
feat(collections/board): add option to archive note
Elian Dorana08bc79ae4a3
diff --git a/apps/client/src/entities/fnote.ts b/apps/client/src/entities/fnote.tsindex b80e8e3fbc..354a2f213f 100644--- a/apps/client/src/entities/fnote.ts+++ b/apps/client/src/entities/fnote.ts@@ -259,6 +259,8 @@ export default class FNote {async getSubtreeNoteIds() {let noteIds: (string | string[])[] = [];for (const child of await this.getChildNotes()) {+ if (child.isArchived) continue;+noteIds.push(child.noteId);noteIds.push(await child.getSubtreeNoteIds());}@@ -267,7 +269,7 @@ export default class FNote {async getSubtreeNotes() {const noteIds = await this.getSubtreeNoteIds();- return this.froca.getNotes(noteIds);+ return (await this.froca.getNotes(noteIds)).filter(note => !note.isArchived)}async getChildNotes() {diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 7e09326169..bba8036bf9 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1994,6 +1994,7 @@},"board_view": {"delete-note": "Delete Note",+ "archive-note": "Archive Note","move-to": "Move to","insert-above": "Insert above","insert-below": "Insert below",diff --git a/apps/client/src/widgets/collections/NoteList.tsx b/apps/client/src/widgets/collections/NoteList.tsxindex fe62d02543..1d642c3b25 100644--- a/apps/client/src/widgets/collections/NoteList.tsx+++ b/apps/client/src/widgets/collections/NoteList.tsx@@ -129,7 +129,9 @@ function useNoteIds(note: FNote | null | undefined, viewType: ViewTypeOptions |useTriliumEvent("entitiesReloaded", ({ loadResults }) => {if (note && loadResults.getBranchRows().some(branch =>branch.parentNoteId === note.noteId- || noteIds.includes(branch.parentNoteId ?? ""))) {+ || noteIds.includes(branch.parentNoteId ?? ""))+ || loadResults.getAttributeRows().some(attr => attr.name === "archived" && attr.noteId && noteIds.includes(attr.noteId))+ ) {refreshNoteIds();}})diff --git a/apps/client/src/widgets/collections/board/context_menu.ts b/apps/client/src/widgets/collections/board/context_menu.tsindex 303db332a9..a2489fcf2d 100644--- a/apps/client/src/widgets/collections/board/context_menu.ts+++ b/apps/client/src/widgets/collections/board/context_menu.ts@@ -1,5 +1,6 @@import contextMenu, { ContextMenuEvent } from "../../../menus/context_menu";import link_context_menu from "../../../menus/link_context_menu";+import attributes from "../../../services/attributes";import branches from "../../../services/branches";import dialog from "../../../services/dialog";import { t } from "../../../services/i18n";@@ -65,6 +66,11 @@ export function openNoteContextMenu(api: Api, event: ContextMenuEvent, noteId: stitle: t("board_view.delete-note"),uiIcon: "bx bx-trash",handler: () => branches.deleteNotes([ branchId ], false, false)+ },+ {+ title: t("board_view.archive-note"),+ uiIcon: "bx bx-archive",+ handler: () => attributes.addLabel(noteId, "archived")}],selectMenuItemHandler: ({ command }) => link_context_menu.handleLinkContextMenuItem(command, noteId),diff --git a/apps/client/src/widgets/collections/board/data.ts b/apps/client/src/widgets/collections/board/data.tsindex 2a59e82b78..9f55b26b54 100644--- a/apps/client/src/widgets/collections/board/data.ts+++ b/apps/client/src/widgets/collections/board/data.ts@@ -64,9 +64,7 @@ export async function getBoardData(parentNote: FNote, groupByColumn: string, perasync function recursiveGroupBy(branches: FBranch[], byColumn: ColumnMap, groupByColumn: string) {for (const branch of branches) {const note = await branch.getNote();- if (!note) {- continue;- }+ if (!note || note.isArchived) continue;if (note.hasChildren()) {await recursiveGroupBy(note.getChildBranches(), byColumn, groupByColumn);