save new position after node dragged 93/11793/1
authorLvbo163 <lv.bo163@zte.com.cn>
Mon, 11 Sep 2017 11:05:45 +0000 (19:05 +0800)
committerLvbo163 <lv.bo163@zte.com.cn>
Mon, 11 Sep 2017 11:05:45 +0000 (19:05 +0800)
save the new position after a node was dragged.

Issue-ID: SDC-308

Change-Id: I647d9fc176d2495eb4031fa1c040cd379ade1156
Signed-off-by: Lvbo163 <lv.bo163@zte.com.cn>
sdc-workflow-designer-ui/src/app/components/node/node.component.ts
sdc-workflow-designer-ui/src/app/services/jsplumb.service.ts

index e78c6e8..5fe189d 100644 (file)
@@ -41,7 +41,7 @@ export class NodeComponent implements AfterViewInit, OnDestroy {
 \r
     ngAfterViewInit(): void {\r
         if(this.last) {\r
-            this.jsPlumbService.initNode('.node');\r
+            this.jsPlumbService.initNode();\r
             this.jsPlumbService.connectNodes();\r
         }\r
 \r
index dc1d800..6aa5028 100644 (file)
@@ -119,25 +119,28 @@ export class JsPlumbService {
         });\r
     }\r
 \r
-    public initNode(selectorString: string) {\r
-        const selector = this.jsplumbInstance.getSelector(selectorString);\r
-\r
-        this.jsplumbInstance.draggable(selector, {\r
-        });\r
+    public initNode() {\r
+        this.processService.getProcess().forEach(node => {\r
+            this.jsplumbInstance.draggable(node.id, {\r
+                stop: event => {\r
+                    node.position.left = event.pos[0];\r
+                    node.position.top = event.pos[1];\r
+                },\r
+            });\r
 \r
-        this.jsplumbInstance.makeTarget(selector, {\r
-            detachable: false,\r
-            isTarget: true,\r
-            maxConnections: -1,\r
-        });\r
+            this.jsplumbInstance.makeTarget(node.id, {\r
+                detachable: false,\r
+                isTarget: true,\r
+                maxConnections: -1,\r
+            });\r
 \r
-        this.jsplumbInstance.makeSource(selector, {\r
-            filter: '.anchor, .anchor *',\r
-            detachable: false,\r
-            isSource: true,\r
-            maxConnections: -1,\r
+            this.jsplumbInstance.makeSource(node.id, {\r
+                filter: '.anchor, .anchor *',\r
+                detachable: false,\r
+                isSource: true,\r
+                maxConnections: -1,\r
+            });\r
         });\r
-\r
     }\r
 \r
     public connectNodes() {\r