diff --git a/static/js/app.mjs b/static/js/app.mjs index 8fc43df..c556341 100644 --- a/static/js/app.mjs +++ b/static/js/app.mjs @@ -370,7 +370,7 @@ class N2DragIcon extends CustomHTMLElement { this.style.top = `${e.clientY}px` }) - this.dragTarget = null + this.dragSource = null }// }}} start() {// {{{ this.style.display = 'block' @@ -383,11 +383,11 @@ class N2DragIcon extends CustomHTMLElement { name = '_' + name this.elIcon.setAttribute('src', `/images/${_VERSION}/icon_drag${name}.svg`) }// }}} - setTarget(t) {// {{{ - this.dragTarget = t + setSource(s) {// {{{ + this.dragSource = s }// }}} - getTarget() {// {{{ - return this.dragTarget + getSource() {// {{{ + return this.dragSource }// }}} } diff --git a/static/js/sidebar.mjs b/static/js/sidebar.mjs index 561de8d..63c4ddc 100644 --- a/static/js/sidebar.mjs +++ b/static/js/sidebar.mjs @@ -585,6 +585,7 @@ export class N2TreeNode extends CustomHTMLElement { e.dataTransfer.setDragImage(blankPixel, 0, 0) e.dataTransfer.allowedEffects = 'none' e.stopPropagation() + _app.dragIcon.setSource(this) _app.dragIcon.start() }// }}} dragEnd(e) {// {{{ @@ -598,13 +599,12 @@ export class N2TreeNode extends CustomHTMLElement { }// }}} async dragDrop(e) {// {{{ e.stopPropagation() - const moveToNode = _app.dragIcon.getTarget() - await _app.moveNode(this.node, moveToNode.node.UUID) - return + const sourceNode = _app.dragIcon.getSource() + await _app.moveNode(sourceNode.node, this.node.UUID) - _app.sidebar.setNodeExpanded(moveToNode, true) + _app.sidebar.setNodeExpanded(this, true) await this.render(true, true) - await moveToNode.render(true, true) + await sourceNode.render(true, true) this.dragLeave(e) }// }}} @@ -615,8 +615,6 @@ export class N2TreeNode extends CustomHTMLElement { e.stopPropagation() _app.dragIcon.icon('ok') this.classList.add('drag-target') - - _app.dragIcon.setTarget(this) }// }}} dragLeave(e) {// {{{ e.stopPropagation() @@ -624,8 +622,6 @@ export class N2TreeNode extends CustomHTMLElement { e.dataTransfer.setDragImage(N2TreeNode.DRAG_ICON, -16, 8) _app.dragIcon.icon('') this.classList.remove('drag-target') - - _app.dragIcon.setTarget(null) }// }}} async fetchChildren(force_fetch) {//{{{ if (this.children_populated && !force_fetch)