mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 03:46:37 +01:00
feat(views/board): add move to in context menu
This commit is contained in:
@@ -1970,6 +1970,7 @@
|
|||||||
"delete_row": "Delete row"
|
"delete_row": "Delete row"
|
||||||
},
|
},
|
||||||
"board_view": {
|
"board_view": {
|
||||||
"delete-note": "Delete Note"
|
"delete-note": "Delete Note",
|
||||||
|
"move-to": "Move to"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
apps/client/src/widgets/view_widgets/board_view/api.ts
Normal file
12
apps/client/src/widgets/view_widgets/board_view/api.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import attributes from "../../../services/attributes";
|
||||||
|
|
||||||
|
export default class BoardApi {
|
||||||
|
|
||||||
|
constructor(public columns: string[]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
async changeColumn(noteId: string, newColumn: string) {
|
||||||
|
await attributes.setLabel(noteId, "status", newColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
interface BoardColumnData {
|
export interface BoardColumnData {
|
||||||
value: string;
|
value: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,14 @@ import contextMenu from "../../../menus/context_menu.js";
|
|||||||
import link_context_menu from "../../../menus/link_context_menu.js";
|
import link_context_menu from "../../../menus/link_context_menu.js";
|
||||||
import branches from "../../../services/branches.js";
|
import branches from "../../../services/branches.js";
|
||||||
import { t } from "../../../services/i18n.js";
|
import { t } from "../../../services/i18n.js";
|
||||||
|
import BoardApi from "./api.js";
|
||||||
|
|
||||||
export function showNoteContextMenu($container: JQuery<HTMLElement>) {
|
interface ShowNoteContextMenuArgs {
|
||||||
|
$container: JQuery<HTMLElement>;
|
||||||
|
api: BoardApi;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function showNoteContextMenu({ $container, api }: ShowNoteContextMenuArgs) {
|
||||||
$container.on("contextmenu", ".board-note", (event) => {
|
$container.on("contextmenu", ".board-note", (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
@@ -19,6 +25,15 @@ export function showNoteContextMenu($container: JQuery<HTMLElement>) {
|
|||||||
items: [
|
items: [
|
||||||
...link_context_menu.getItems(),
|
...link_context_menu.getItems(),
|
||||||
{ title: "----" },
|
{ title: "----" },
|
||||||
|
{
|
||||||
|
title: t("board_view.move-to"),
|
||||||
|
uiIcon: "bx bx-transfer",
|
||||||
|
items: api.columns.map(column => ({
|
||||||
|
title: column,
|
||||||
|
handler: () => api.changeColumn(noteId, column)
|
||||||
|
}))
|
||||||
|
},
|
||||||
|
{ title: "----" },
|
||||||
{
|
{
|
||||||
title: t("board_view.delete-note"),
|
title: t("board_view.delete-note"),
|
||||||
uiIcon: "bx bx-trash",
|
uiIcon: "bx bx-trash",
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import appContext, { EventData } from "../../../components/app_context";
|
|||||||
import { BoardData } from "./config";
|
import { BoardData } from "./config";
|
||||||
import SpacedUpdate from "../../../services/spaced_update";
|
import SpacedUpdate from "../../../services/spaced_update";
|
||||||
import { showNoteContextMenu } from "./context_menu";
|
import { showNoteContextMenu } from "./context_menu";
|
||||||
|
import BoardApi from "./api";
|
||||||
|
|
||||||
const TPL = /*html*/`
|
const TPL = /*html*/`
|
||||||
<div class="board-view">
|
<div class="board-view">
|
||||||
@@ -127,6 +128,7 @@ export default class BoardView extends ViewMode<BoardData> {
|
|||||||
private draggedBranch: any = null;
|
private draggedBranch: any = null;
|
||||||
private draggedNoteElement: JQuery<HTMLElement> | null = null;
|
private draggedNoteElement: JQuery<HTMLElement> | null = null;
|
||||||
private persistentData: BoardData;
|
private persistentData: BoardData;
|
||||||
|
private api?: BoardApi;
|
||||||
|
|
||||||
constructor(args: ViewModeArgs) {
|
constructor(args: ViewModeArgs) {
|
||||||
super(args, "board");
|
super(args, "board");
|
||||||
@@ -134,7 +136,6 @@ export default class BoardView extends ViewMode<BoardData> {
|
|||||||
this.$root = $(TPL);
|
this.$root = $(TPL);
|
||||||
setupHorizontalScrollViaWheel(this.$root);
|
setupHorizontalScrollViaWheel(this.$root);
|
||||||
this.$container = this.$root.find(".board-view-container");
|
this.$container = this.$root.find(".board-view-container");
|
||||||
showNoteContextMenu(this.$container);
|
|
||||||
this.spacedUpdate = new SpacedUpdate(() => this.onSave(), 5_000);
|
this.spacedUpdate = new SpacedUpdate(() => this.onSave(), 5_000);
|
||||||
this.persistentData = {
|
this.persistentData = {
|
||||||
columns: []
|
columns: []
|
||||||
@@ -155,6 +156,12 @@ export default class BoardView extends ViewMode<BoardData> {
|
|||||||
this.persistentData = persistedData;
|
this.persistentData = persistedData;
|
||||||
|
|
||||||
const data = await getBoardData(this.parentNote, "status", persistedData);
|
const data = await getBoardData(this.parentNote, "status", persistedData);
|
||||||
|
const columns = Array.from(data.byColumn.keys()) || [];
|
||||||
|
this.api = new BoardApi(columns);
|
||||||
|
showNoteContextMenu({
|
||||||
|
$container: this.$container,
|
||||||
|
api: this.api
|
||||||
|
});
|
||||||
|
|
||||||
if (data.newPersistedData) {
|
if (data.newPersistedData) {
|
||||||
this.persistentData = data.newPersistedData;
|
this.persistentData = data.newPersistedData;
|
||||||
@@ -317,7 +324,7 @@ export default class BoardView extends ViewMode<BoardData> {
|
|||||||
try {
|
try {
|
||||||
// Handle column change
|
// Handle column change
|
||||||
if (currentColumn !== column) {
|
if (currentColumn !== column) {
|
||||||
await attributeService.setLabel(draggedNote.noteId, "status", column);
|
await this.api?.changeColumn(draggedNote.noteId, column);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle position change (works for both same column and different column moves)
|
// Handle position change (works for both same column and different column moves)
|
||||||
|
|||||||
Reference in New Issue
Block a user