diff --git a/client/src/components/Workflow/Editor/Connector.vue b/client/src/components/Workflow/Editor/Connector.vue index 2bfeeed6b53..7e7a4e5c65a 100644 --- a/client/src/components/Workflow/Editor/Connector.vue +++ b/client/src/components/Workflow/Editor/Connector.vue @@ -13,17 +13,9 @@ export default { type: String, required: false, }, - startX: { - type: Number, - }, - startY: { - type: Number, - }, - endX: { - type: Number, - }, - endY: { - type: Number, + position: { + type: Object, + required: true, }, }, data() { @@ -36,12 +28,6 @@ export default { // this.terminal.destroy(); }, computed: { - left() { - return Math.min(this.startX, this.endX); - }, - top() { - return Math.max(this.startY, this.endY); - }, offsetStart() { return 0; }, @@ -50,10 +36,10 @@ export default { }, lineData() { const data = [ - { x: this.startX, y: this.startY + this.offsetStart }, - { x: this.startX + this.lineShift, y: this.startY + this.offsetStart }, - { x: this.endX - this.lineShift, y: this.endY + this.offsetEnd }, - { x: this.endX, y: this.endY + this.offsetEnd }, + { x: this.position.startX, y: this.position.startY + this.offsetStart }, + { x: this.position.startX + this.lineShift, y: this.position.startY + this.offsetStart }, + { x: this.position.endX - this.lineShift, y: this.position.endY + this.offsetEnd }, + { x: this.position.endX, y: this.position.endY + this.offsetEnd }, ]; return data; }, diff --git a/client/src/components/Workflow/Editor/Draggable.vue b/client/src/components/Workflow/Editor/Draggable.vue index 6d95a894e38..133c74a2c9f 100644 --- a/client/src/components/Workflow/Editor/Draggable.vue +++ b/client/src/components/Workflow/Editor/Draggable.vue @@ -3,7 +3,7 @@ :draggable-options="draggableOptions" @start="onDragStart" @move="move" - :stop="stopPropagation" + :stop="onStopDragging" :start="stopPropagation" :drag="stopPropagation" v-on="$listeners"> @@ -55,6 +55,11 @@ export default { console.log("mousedown", e); this.$emit("mousedown", e); }, + onStopDragging(e) { + console.log("stopDragging"); + e.stopPropagation(); + this.$emit("stopDragging"); + }, stopPropagation(e) { e.stopPropagation(); }, @@ -62,22 +67,6 @@ export default { console.log("moveEvent", e); e.event.stopPropagation(); }, - // onMouseDown(e) { - // this.mouseDown = { offsetX: e.offsetX, offsetY: e.offsetY }; - // if (!this.position) { - // const { top, left } = this.$refs.drag.getBoundingClientRect(); - // this._localPosition = { top: top + window.scrollY, left: left + window.scrollX }; - // } - // }, - // onDrag(e) { - // const left = this.localPosition.left + (e.offsetX - this.mouseDown.offsetX) / this.zoom; - // const top = this.localPosition.top + (e.offsetY - this.mouseDown.offsetY) / this.zoom; - // this.$emit("updatePosition", { left, top }); - // }, - // onDragEnd(e) { - // // this.onDrag(e); - // this.$emit("dragEnd"); - // }, }, }; diff --git a/client/src/components/Workflow/Editor/Index.vue b/client/src/components/Workflow/Editor/Index.vue index b0a32628253..d22b8fb139c 100644 --- a/client/src/components/Workflow/Editor/Index.vue +++ b/client/src/components/Workflow/Editor/Index.vue @@ -341,7 +341,8 @@ export default { } }, steps(newSteps, oldSteps) { - this.hasChanges = true; + console.log("steps watch triggered"); + // this.hasChanges = true; this.nodeIndex = Math.max(...Object.keys(newSteps).map((k) => parseInt(k))) + 1; }, nodes(newNodes, oldNodes) { @@ -368,7 +369,7 @@ export default { }, onUpdateStepPosition(stepId, position) { console.log("updating step position"); - // this.steps[stepId].position = position; + this.steps[stepId].position = position; }, onDisconnect(nodeId, inputName) { delete this.steps[nodeId].input_connections[inputName]; @@ -541,7 +542,7 @@ export default { }, onAttributes() { this._ensureParametersSet(); - this.onDeactivate(); + this.$store.commit("workflowState/setActiveNode", null); this.showInPanel = "attributes"; }, onAnnotation(nodeId, newAnnotation) { diff --git a/client/src/components/Workflow/Editor/Node.vue b/client/src/components/Workflow/Editor/Node.vue index 97d1258e95a..ab0c8f72bbb 100644 --- a/client/src/components/Workflow/Editor/Node.vue +++ b/client/src/components/Workflow/Editor/Node.vue @@ -86,7 +86,7 @@ :offset-x="offset.x" :offset-y="offset.y" v-on="$listeners" - @stop="onStop" + @stopDragging="onStopDragging" @onAdd="onAddOutput" @onRemove="onRemoveOutput" @onToggle="onToggleOutput" @@ -268,8 +268,9 @@ export default { left: this.step.position.left + deltaX, }); }, - onStop() { - console.log("onStop called"); + onStopDragging() { + console.log("onStopDragging called"); + this.$emit("stopDragging"); }, onUpdatePosition(position) { this.$emit("onUpdateStepPosition", this.step.id, position); diff --git a/client/src/components/Workflow/Editor/NodeInput.vue b/client/src/components/Workflow/Editor/NodeInput.vue index eb6b3d555b5..8f353d9261a 100644 --- a/client/src/components/Workflow/Editor/NodeInput.vue +++ b/client/src/components/Workflow/Editor/NodeInput.vue @@ -46,8 +46,12 @@ export default { isMultiple: false, initX: 0, initY: 0, + nodeId: null, }; }, + created() { + this.nodeId = this.getNode().id; + }, mounted() { const rect = this.$refs.terminal.getBoundingClientRect(); this.initX = rect.left + rect.width / 2 - this.rootOffset.left; @@ -75,7 +79,7 @@ export default { return this.initY + this.offsetY; }, position() { - return { endX: this.startX, endY: this.startY }; + return Object.freeze({ endX: this.startX, endY: this.startY }); }, }, beforeDestroy() { @@ -84,9 +88,13 @@ export default { }, watch: { position(position) { - console.log(position); + console.log({ + stepId: this.nodeId, + inputName: this.input.name, + position, + }); this.$store.commit("workflowState/setInputTerminalPosition", { - stepId: this.getNode().id, + stepId: this.nodeId, inputName: this.input.name, position, }); @@ -102,6 +110,7 @@ export default { }, mouseOver(e) { console.log("mousOver"); + // } }, mouseLeave() { this.showRemove = false; diff --git a/client/src/components/Workflow/Editor/NodeOutput.vue b/client/src/components/Workflow/Editor/NodeOutput.vue index 1292c2244ab..0aba1e96b35 100644 --- a/client/src/components/Workflow/Editor/NodeOutput.vue +++ b/client/src/components/Workflow/Editor/NodeOutput.vue @@ -14,9 +14,8 @@ :class="terminalClass" :output-name="output.name" @start="isDragging = true" - @stop="onStopDragging" - @move="onMove" - v-on="$listeners"> + @stopDragging="onStopDragging" + @move="onMove">
@@ -79,7 +78,7 @@ export default { }, computed: { position() { - return { startX: this.startX, startY: this.startY }; + return Object.freeze({ startX: this.startX, startY: this.startY }); }, startX() { const newX = this.initX + this.offsetX; @@ -156,6 +155,7 @@ export default { console.log("is dragging ?", this.isDragging); }, dragPosition() { + console.log("dragPosition", this.endX); if (this.isDragging) { this.$emit("onDragConnector", this.dragPosition); } @@ -180,6 +180,7 @@ export default { this.isDragging = false; this.deltaX = 0; this.deltaY = 0; + this.$emit("stopDragging"); }, inputDragStart(e) { console.log("inputDragStart", e); @@ -195,7 +196,8 @@ export default { }, onChange() { // this.isMultiple = this.terminal.isMappedOver(); - this.$emit("onChange"); + console.log("onChange"); + // this.$emit("onChange"); }, onToggle() { this.$emit("onToggle", this.output.name); diff --git a/client/src/components/Workflow/Editor/TerminalConnector.vue b/client/src/components/Workflow/Editor/TerminalConnector.vue new file mode 100644 index 00000000000..6808c59292f --- /dev/null +++ b/client/src/components/Workflow/Editor/TerminalConnector.vue @@ -0,0 +1,38 @@ + +