diff --git a/src/plugins/condition/components/Condition.vue b/src/plugins/condition/components/Condition.vue index 59e93794ea..3d93f5d9f0 100644 --- a/src/plugins/condition/components/Condition.vue +++ b/src/plugins/condition/components/Condition.vue @@ -21,159 +21,167 @@ *****************************************************************************/ @@ -207,6 +215,14 @@ export default { type: Array, required: true, default: () => [] + }, + isDragging: { + type: Boolean, + default: false + }, + moveIndex: { + type: Number, + default: 0 } }, data() { @@ -217,8 +233,8 @@ export default { selectedOutputSelection: '', outputOptions: ['false', 'true', 'string'], criterionIndex: 0, - selectedTelemetryName: '', - selectedFieldName: '' + draggingOver: false, + isDefault: this.condition.isDefault }; }, computed: { @@ -286,11 +302,39 @@ export default { dragStart(e) { e.dataTransfer.setData('dragging', e.target); // required for FF to initiate drag e.dataTransfer.effectAllowed = "copyMove"; - e.dataTransfer.setDragImage(e.target.closest('.js-condition-drag-wrapper'), 0, 0); + e.dataTransfer.setDragImage(e.target.closest('.c-condition-h'), 0, 0); this.$emit('setMoveIndex', this.conditionIndex); }, - dragStop(e) { - e.dataTransfer.clearData(); + dragEnd(event) { + this.dragStarted = false; + event.dataTransfer.clearData(); + this.$emit('dragComplete'); + }, + dropCondition(event, targetIndex) { + if (!this.isDragging) { return } + if (targetIndex > this.moveIndex) { targetIndex-- } // for 'downward' move + if (this.isValidTarget(targetIndex)) { + this.dragElement = undefined; + this.draggingOver = false; + this.$emit('dropCondition', targetIndex); + } + }, + dragEnter(event, targetIndex) { + if (!this.isDragging) { return } + if (targetIndex > this.moveIndex) { targetIndex-- } // for 'downward' move + if (this.isValidTarget(targetIndex)) { + this.dragElement = event.target.parentElement; + this.draggingOver = true; + } + }, + dragLeave(event) { + if (event.target.parentElement === this.dragElement) { + this.draggingOver = false; + this.dragElement = undefined; + } + }, + isValidTarget(targetIndex) { + return this.moveIndex !== targetIndex; }, destroy() { }, diff --git a/src/plugins/condition/components/ConditionCollection.vue b/src/plugins/condition/components/ConditionCollection.vue index f3c290c7b6..ea5f601e40 100644 --- a/src/plugins/condition/components/ConditionCollection.vue +++ b/src/plugins/condition/components/ConditionCollection.vue @@ -52,28 +52,24 @@ Add Condition -
-
-
- -
+
+
@@ -108,9 +104,10 @@ export default { conditionResults: {}, conditions: [], telemetryObjs: [], - moveIndex: Number, + moveIndex: undefined, isDragging: false, - defaultOutput: undefined + defaultOutput: undefined, + dragCounter: 0 }; }, watch: { @@ -165,9 +162,7 @@ export default { this.moveIndex = index; this.isDragging = true; }, - dropCondition(e) { - let targetIndex = Array.from(document.querySelectorAll('.c-c__drag-ghost')).indexOf(e.target); - if (targetIndex > this.moveIndex) { targetIndex-- } // for 'downward' move + dropCondition(targetIndex) { const oldIndexArr = Object.keys(this.conditionCollection); const move = function (arr, old_index, new_index) { while (old_index < 0) { @@ -193,20 +188,10 @@ export default { } this.reorder(reorderPlan); - - e.target.classList.remove("dragging"); + }, + dragComplete() { this.isDragging = false; }, - dragEnter(e) { - if (!this.isDragging) { return } - let targetIndex = Array.from(document.querySelectorAll('.c-c__drag-ghost')).indexOf(e.target); - if (targetIndex > this.moveIndex) { targetIndex-- } // for 'downward' move - if (this.moveIndex === targetIndex) { return } - e.target.classList.add("dragging"); - }, - dragLeave(e) { - e.target.classList.remove("dragging"); - }, addTelemetryObject(domainObject) { this.telemetryObjs.push(domainObject); this.$emit('telemetryUpdated', this.telemetryObjs); diff --git a/src/plugins/condition/components/TestData.vue b/src/plugins/condition/components/TestData.vue index 233fdaf1d5..7f1628f65c 100644 --- a/src/plugins/condition/components/TestData.vue +++ b/src/plugins/condition/components/TestData.vue @@ -36,7 +36,7 @@
-