mirror of
https://github.com/zadam/trilium.git
synced 2025-10-21 07:38:53 +02:00
feat(collections/board): add option to archive note
This commit is contained in:
parent
8ad00084e1
commit
a08bc79ae4
@ -259,6 +259,8 @@ export default class FNote {
|
|||||||
async getSubtreeNoteIds() {
|
async getSubtreeNoteIds() {
|
||||||
let noteIds: (string | string[])[] = [];
|
let noteIds: (string | string[])[] = [];
|
||||||
for (const child of await this.getChildNotes()) {
|
for (const child of await this.getChildNotes()) {
|
||||||
|
if (child.isArchived) continue;
|
||||||
|
|
||||||
noteIds.push(child.noteId);
|
noteIds.push(child.noteId);
|
||||||
noteIds.push(await child.getSubtreeNoteIds());
|
noteIds.push(await child.getSubtreeNoteIds());
|
||||||
}
|
}
|
||||||
@ -267,7 +269,7 @@ export default class FNote {
|
|||||||
|
|
||||||
async getSubtreeNotes() {
|
async getSubtreeNotes() {
|
||||||
const noteIds = await this.getSubtreeNoteIds();
|
const noteIds = await this.getSubtreeNoteIds();
|
||||||
return this.froca.getNotes(noteIds);
|
return (await this.froca.getNotes(noteIds)).filter(note => !note.isArchived)
|
||||||
}
|
}
|
||||||
|
|
||||||
async getChildNotes() {
|
async getChildNotes() {
|
||||||
|
@ -1994,6 +1994,7 @@
|
|||||||
},
|
},
|
||||||
"board_view": {
|
"board_view": {
|
||||||
"delete-note": "Delete Note",
|
"delete-note": "Delete Note",
|
||||||
|
"archive-note": "Archive Note",
|
||||||
"move-to": "Move to",
|
"move-to": "Move to",
|
||||||
"insert-above": "Insert above",
|
"insert-above": "Insert above",
|
||||||
"insert-below": "Insert below",
|
"insert-below": "Insert below",
|
||||||
|
@ -129,7 +129,9 @@ function useNoteIds(note: FNote | null | undefined, viewType: ViewTypeOptions |
|
|||||||
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
|
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
|
||||||
if (note && loadResults.getBranchRows().some(branch =>
|
if (note && loadResults.getBranchRows().some(branch =>
|
||||||
branch.parentNoteId === note.noteId
|
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();
|
refreshNoteIds();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import contextMenu, { ContextMenuEvent } from "../../../menus/context_menu";
|
import contextMenu, { ContextMenuEvent } from "../../../menus/context_menu";
|
||||||
import link_context_menu from "../../../menus/link_context_menu";
|
import link_context_menu from "../../../menus/link_context_menu";
|
||||||
|
import attributes from "../../../services/attributes";
|
||||||
import branches from "../../../services/branches";
|
import branches from "../../../services/branches";
|
||||||
import dialog from "../../../services/dialog";
|
import dialog from "../../../services/dialog";
|
||||||
import { t } from "../../../services/i18n";
|
import { t } from "../../../services/i18n";
|
||||||
@ -65,6 +66,11 @@ export function openNoteContextMenu(api: Api, event: ContextMenuEvent, noteId: s
|
|||||||
title: t("board_view.delete-note"),
|
title: t("board_view.delete-note"),
|
||||||
uiIcon: "bx bx-trash",
|
uiIcon: "bx bx-trash",
|
||||||
handler: () => branches.deleteNotes([ branchId ], false, false)
|
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),
|
selectMenuItemHandler: ({ command }) => link_context_menu.handleLinkContextMenuItem(command, noteId),
|
||||||
|
@ -64,9 +64,7 @@ export async function getBoardData(parentNote: FNote, groupByColumn: string, per
|
|||||||
async function recursiveGroupBy(branches: FBranch[], byColumn: ColumnMap, groupByColumn: string) {
|
async function recursiveGroupBy(branches: FBranch[], byColumn: ColumnMap, groupByColumn: string) {
|
||||||
for (const branch of branches) {
|
for (const branch of branches) {
|
||||||
const note = await branch.getNote();
|
const note = await branch.getNote();
|
||||||
if (!note) {
|
if (!note || note.isArchived) continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (note.hasChildren()) {
|
if (note.hasChildren()) {
|
||||||
await recursiveGroupBy(note.getChildBranches(), byColumn, groupByColumn);
|
await recursiveGroupBy(note.getChildBranches(), byColumn, groupByColumn);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user