Skip to content

Commit

Permalink
Add "send to lane" menu options
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeyers committed Apr 16, 2024
1 parent 75b1f5b commit ed3f05f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
7 changes: 1 addition & 6 deletions src/DragDropApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,7 @@ export function DragDropApp({ win, plugin }: { win: Window; plugin: KanbanPlugin
);

if (inDropArea) {
const parent = getEntityFromPath(stateManager.state, dropPath);
const shouldAppend =
(stateManager.getSetting('new-card-insertion-method') || 'append') === 'append';

if (shouldAppend) dropPath.push(parent.children.length);
else dropPath.push(0);
dropPath.push(0);
}

plugin.app.workspace.trigger(
Expand Down
26 changes: 22 additions & 4 deletions src/components/Item/ItemMenu.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Menu, TFile, TFolder, getLinkpath } from 'obsidian';
import Preact from 'preact/compat';
import { Dispatch, StateUpdater } from 'preact/hooks';
import { Dispatch, StateUpdater, useCallback } from 'preact/hooks';
import { StateManager } from 'src/StateManager';
import { Path } from 'src/dnd/types';
import { moveEntity } from 'src/dnd/util/data';
import { t } from 'src/lang/helpers';

import { BoardModifiers } from '../../helpers/boardModifiers';
Expand Down Expand Up @@ -35,10 +35,10 @@ export function useItemMenu({
boardModifiers,
stateManager,
}: UseItemMenuParams) {
return Preact.useCallback(
return useCallback(
(e: MouseEvent, internalLinkPath?: string) => {
if (internalLinkPath) {
(app.workspace as any).onLinkContextMenu(
(stateManager.app.workspace as any).onLinkContextMenu(
e,
getLinkpath(internalLinkPath),
stateManager.file.path
Expand Down Expand Up @@ -296,6 +296,24 @@ export function useItemMenu({
}
}

menu.addSeparator();

const lanes = stateManager.state.children;
for (let i = 0, len = lanes.length; i < len; i++) {
menu.addItem((item) =>
item
.setIcon('lucide-square-kanban')
.setChecked(path[0] === i)
.setTitle(lanes[i].data.title)
.onClick(() => {
if (path[0] === i) return;
stateManager.setState((boardData) => {
return moveEntity(boardData, path, [i, 0]);
});
})
);
}

menu.showAtPosition(coordinates);
}
},
Expand Down

0 comments on commit ed3f05f

Please sign in to comment.