add sequence flow after page refreshed 45/11645/1
authorLvbo163 <lv.bo163@zte.com.cn>
Mon, 11 Sep 2017 09:02:30 +0000 (17:02 +0800)
committerLvbo163 <lv.bo163@zte.com.cn>
Mon, 11 Sep 2017 09:02:30 +0000 (17:02 +0800)
fix the issue of sequence flow error after page refresh.

Issue-ID: SDC-307

Change-Id: I068ff91850fe1e917d0d896afdaa617aea0e9fee
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
sdc-workflow-designer-ui/src/app/services/workflow.service.ts

index 7a48e5d..e78c6e8 100644 (file)
@@ -42,6 +42,7 @@ export class NodeComponent implements AfterViewInit, OnDestroy {
     ngAfterViewInit(): void {\r
         if(this.last) {\r
             this.jsPlumbService.initNode('.node');\r
+            this.jsPlumbService.connectNodes();\r
         }\r
 \r
         this.currentTypeSubscription = this.broadcastService.currentType$.subscribe(type => {\r
index 06cb2b0..dc1d800 100644 (file)
@@ -15,6 +15,7 @@ import * as jsp from 'jsplumb';
 import { WorkflowProcessService } from "./workflow-process.service";\r
 import { BroadcastService } from "./broadcast.service";\r
 import { Subscription } from 'rxjs/Subscription';\r
+import { WorkflowNode } from "../model/workflow/workflow-node";\r
 \r
 /**\r
  * JsPlumbService\r
@@ -139,6 +140,23 @@ export class JsPlumbService {
 \r
     }\r
 \r
+    public connectNodes() {\r
+        const nodes: WorkflowNode[] = this.processService.getProcess();\r
+        nodes.forEach(node => this.connect4OneNode(node));\r
+    }\r
+\r
+    public connect4OneNode(node: WorkflowNode) {\r
+        node.sequenceFlows.forEach(sequenceFlow => {\r
+            const connection = this.jsplumbInstance.connect({\r
+                source: sequenceFlow.sourceRef,\r
+                target: sequenceFlow.targetRef,\r
+            });\r
+            if (sequenceFlow.condition) {\r
+                connection.setLabel(sequenceFlow.condition);\r
+            }\r
+        });\r
+    }\r
+\r
     public setLabel(sourceId: string, targetId: string, label: string) {\r
         const sourceNode = this.processService.getNodeById(sourceId);\r
         const connections = this.jsplumbInstance.select({ source: sourceId, target: targetId });\r
index 7d75192..c1eed4a 100644 (file)
@@ -30,6 +30,7 @@ export class WorkflowService {
 \r
     public save(): Observable<boolean> {\r
         console.log(this.workflow);\r
+        console.log(JSON.stringify(this.workflow));\r
         return this.dataAccessService.catalogService.saveWorkflow(this.workflow);\r
     }\r
 }\r