feat(collections/board): unarchive note

This commit is contained in:
Elian Doran 2025-09-12 22:08:32 +03:00
parent 6703b78457
commit 3175b75192
No known key found for this signature in database
3 changed files with 25 additions and 9 deletions

View File

@ -1998,6 +1998,7 @@
"board_view": { "board_view": {
"delete-note": "Delete Note", "delete-note": "Delete Note",
"archive-note": "Archive Note", "archive-note": "Archive Note",
"unarchive-note": "Unarchive 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",

View File

@ -43,7 +43,7 @@ export default function Card({
}, [note.noteId, branch.branchId, column, index]); }, [note.noteId, branch.branchId, column, index]);
const handleContextMenu = useCallback((e: ContextMenuEvent) => { const handleContextMenu = useCallback((e: ContextMenuEvent) => {
openNoteContextMenu(api, e, note.noteId, branch.branchId, column); openNoteContextMenu(api, e, note, branch.branchId, column);
}, [ api, note, branch, column ]); }, [ api, note, branch, column ]);
const handleOpen = useCallback(() => { const handleOpen = useCallback(() => {

View File

@ -1,3 +1,4 @@
import FNote from "../../../entities/fnote";
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 attributes from "../../../services/attributes";
@ -31,7 +32,7 @@ export function openColumnContextMenu(api: Api, event: ContextMenuEvent, column:
}); });
} }
export function openNoteContextMenu(api: Api, event: ContextMenuEvent, noteId: string, branchId: string, column: string) { export function openNoteContextMenu(api: Api, event: ContextMenuEvent, note: FNote, branchId: string, column: string) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
@ -47,7 +48,7 @@ export function openNoteContextMenu(api: Api, event: ContextMenuEvent, noteId: s
items: api.columns.map(columnToMoveTo => ({ items: api.columns.map(columnToMoveTo => ({
title: columnToMoveTo, title: columnToMoveTo,
enabled: columnToMoveTo !== column, enabled: columnToMoveTo !== column,
handler: () => api.changeColumn(noteId, columnToMoveTo) handler: () => api.changeColumn(note.noteId, columnToMoveTo)
})) }))
}, },
{ title: "----" }, { title: "----" },
@ -67,12 +68,26 @@ export function openNoteContextMenu(api: Api, event: ContextMenuEvent, noteId: s
uiIcon: "bx bx-trash", uiIcon: "bx bx-trash",
handler: () => branches.deleteNotes([ branchId ], false, false) handler: () => branches.deleteNotes([ branchId ], false, false)
}, },
{ getArchiveMenuItem(note)
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, note.noteId),
}); });
} }
function getArchiveMenuItem(note: FNote) {
if (!note.isArchived) {
return {
title: t("board_view.archive-note"),
uiIcon: "bx bx-archive",
handler: () => attributes.addLabel(note.noteId, "archived")
}
} else {
return {
title: t("board_view.unarchive-note"),
uiIcon: "bx bx-archive-out",
handler: async () => {
attributes.removeOwnedLabelByName(note, "archived")
}
}
}
}