From 21f49756dc9232b42b90ba63b274d2f0c29d64e1 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sat, 22 Apr 2023 22:59:28 -0500 Subject: [PATCH] Move selecting action logic inside the board component --- src/features/boards/Board.vue | 10 ++++++++++ src/features/boards/BoardNode.vue | 2 ++ src/features/boards/BoardNodeAction.vue | 13 +++++++------ src/features/boards/board.ts | 2 +- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/features/boards/Board.vue b/src/features/boards/Board.vue index 2605aaa..7d50aa4 100644 --- a/src/features/boards/Board.vue +++ b/src/features/boards/Board.vue @@ -44,6 +44,7 @@ :selectedAction="unref(selectedAction)" @mouseDown="mouseDown" @endDragging="endDragging" + @clickAction="actionId => clickAction(node, actionId)" /> @@ -240,6 +241,15 @@ function endDragging(nodeID: number | null) { props.state.value.selectedAction = null; } } + +function clickAction(node: BoardNode, actionId: string) { + if (props.state.value.selectedAction === actionId) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + unref(props.selectedAction)!.onClick(unref(props.selectedNode)!); + } else { + props.state.value = { ...props.state.value, selectedAction: actionId }; + } +}