Skip to content

Commit

Permalink
Annotate the product node to prevent it from instantly being dragged …
Browse files Browse the repository at this point in the history
…when switched to
  • Loading branch information
ErikVerheul committed Oct 18, 2024
1 parent 242e125 commit a179446
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions documentation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ data: {
lastCommentToHistory: doc.lastCommentToHistory,
lastChange: Date.now(), // calculated on load, updated on change of title, priority, productId, parentId, state, subtype(3x), spSize, tsSize, acceptance and description
}
tmpPreventDrag: false // a temporary state to prevent a selected product node to enter the dragging mode after selection
// temporary and private use, not stored, not synced with other on-line users
tmp: {
isHighlighted_1: boolean // light blue
Expand Down
15 changes: 7 additions & 8 deletions src/components/views/sl-vue-tree/sl-vue-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function data() {
y: 0,
},
preventDrag: false,
preventProductDrag: false,
lastClickedNode: {},
}
}
Expand Down Expand Up @@ -169,11 +170,7 @@ const methods = {
},

mouseMoveHandler(event) {
if (!this.isRoot) {
this.getRootComponent().mouseMoveHandler(event)
return
}
if (!this.isLeftMouseButtonDown || this.preventDrag || !this.lastClickedNode.isSelected) return
if (!this.isLeftMouseButtonDown || this.preventDrag || this.preventProductDrag || !this.lastClickedNode.isSelected) return
const initialDraggingState = this.isDragging
const isDraggingLocal = this.isDragging || this.lastMousePos.y !== event.clientY

Expand Down Expand Up @@ -213,6 +210,9 @@ const methods = {
// disallow selection of the root node
if (node.level === 1) return

// set preventProductDrag (true if clicked on a product node and the node is not expanded)
this.preventProductDrag = node.tmpPreventDrag && !node.isExpanded

if (!this.isDragging) {
// cursorPosition not available, so get it
const cPos = this.getCursorModelPositionFromCoords(event.clientX, event.clientY)
Expand All @@ -223,9 +223,9 @@ const methods = {
this.lastClickedNode = node
},

mouseUpLeftHandler(event) {
mouseUpLeftHandler(event, node) {
if (!this.isRoot) {
this.getRootComponent().mouseUpLeftHandler(event)
this.getRootComponent().mouseUpLeftHandler(event, node)
return
}

Expand Down Expand Up @@ -330,7 +330,6 @@ const methods = {
store.state.lastSelectCursorPosition = cursorPosition
const selNode = cursorPosition.nodeModel
if (selNode.isSelectable) {
this.preventDrag = false
const prevSelectedNode = store.state.selectedNodes.slice(-1)[0] || selNode
// ctrl-select or shift-select mode is allowed only if in professional mode and nodes have the same parent and are above PRODUCTLEVEL (epics, features and higher)
if (
Expand Down
6 changes: 3 additions & 3 deletions src/components/views/sl-vue-tree/sl-vue-tree.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- This component is an improved and extended version of the Holiber sl-vue-tree. See https://github.com/holiber/sl-vue-tree -->
<template>
<div class="sl-vue-tree" :class="{ 'sl-vue-tree-root': isRoot }">
<div class="sl-vue-tree" :class="{ 'sl-vue-tree-root': isRoot }" @mousemove="mouseMoveHandler">
<!-- traverse the filtered nodes breadth first -->
<div v-for="(node, nodeInd) in filteredNodes" :class="{
'sl-vue-tree-selected': node.isSelected,
Expand All @@ -16,8 +16,8 @@
}">
</div>

<template class="sl-vue-tree-node-item" @mousedown.left="mouseDownLeftHandler($event, node)" @mouseup.left="mouseUpLeftHandler($event)"
@contextmenu="contextMenuHandler($event, node)" @mousemove="mouseMoveHandler($event)" :path="node.pathStr">
<template class="sl-vue-tree-node-item" @mousedown.left="mouseDownLeftHandler($event, node)" @mouseup.left="mouseUpLeftHandler($event, node)"
@contextmenu="contextMenuHandler($event, node)" :path="node.pathStr">
<div :class="{
'sl-vue-tree-cursor-inside':
cursorPosition &&
Expand Down
5 changes: 4 additions & 1 deletion src/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -1328,8 +1328,11 @@ const store = createStore({
if (currentProductNode !== null && newCurrentProductNode !== null) {
// if the current product is not removed and the newly selected product exists
if (state.currentView !== 'coarseProduct') {
// collapse the current and expand the newly selected product branch
collapseNode(currentProductNode)
// select the product node to be expanded
state.helpersRef.selectNodeById(newProductId)
// prevent the product node to be set to the dragging state
newCurrentProductNode.tmpPreventDrag = true
expandNode(newCurrentProductNode)
}
// update current product id and title
Expand Down

0 comments on commit a179446

Please sign in to comment.