feat(views/board): add context menu with delete

This commit is contained in:
Elian Doran
2025-07-20 12:40:30 +03:00
parent 37c9260dca
commit e51ea1a619
3 changed files with 33 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import contextMenu from "../../../menus/context_menu.js";
import branches from "../../../services/branches.js";
import { t } from "../../../services/i18n.js";
export function showNoteContextMenu($container: JQuery<HTMLElement>) {
$container.on("contextmenu", ".board-note", (event) => {
event.preventDefault();
event.stopPropagation();
const $el = $(event.currentTarget);
const noteId = $el.data("note-id");
const branchId = $el.data("branch-id");
if (!noteId) return;
contextMenu.show({
x: event.pageX,
y: event.pageY,
items: [
{
title: t("board_view.delete-note"),
uiIcon: "bx bx-trash",
handler: () => branches.deleteNotes([ branchId ], false, false)
}
],
selectMenuItemHandler: () => {}
});
});
}

View File

@@ -7,6 +7,7 @@ import noteCreateService from "../../../services/note_create";
import appContext, { EventData } from "../../../components/app_context";
import { BoardData } from "./config";
import SpacedUpdate from "../../../services/spaced_update";
import { showNoteContextMenu } from "./context_menu";
const TPL = /*html*/`
<div class="board-view">
@@ -133,6 +134,7 @@ export default class BoardView extends ViewMode<BoardData> {
this.$root = $(TPL);
setupHorizontalScrollViaWheel(this.$root);
this.$container = this.$root.find(".board-view-container");
showNoteContextMenu(this.$container);
this.spacedUpdate = new SpacedUpdate(() => this.onSave(), 5_000);
this.persistentData = {
columns: []