support set condition for gateway 93/10993/1
authorLvbo163 <lv.bo163@zte.com.cn>
Fri, 8 Sep 2017 03:36:53 +0000 (11:36 +0800)
committerLvbo163 <lv.bo163@zte.com.cn>
Fri, 8 Sep 2017 03:36:53 +0000 (11:36 +0800)
support set condition for gateway(exclusive gateway)

Issue-ID: SDC-119

Change-Id: I479ed99eb45928d90bf7361de0208eef4b113776
Signed-off-by: Lvbo163 <lv.bo163@zte.com.cn>
sdc-workflow-designer-ui/src/app/app.component.html
sdc-workflow-designer-ui/src/app/app.module.ts
sdc-workflow-designer-ui/src/app/components/canvas/canvas.component.ts
sdc-workflow-designer-ui/src/app/components/sequence-flow/sequence-flow.component.css [new file with mode: 0644]
sdc-workflow-designer-ui/src/app/components/sequence-flow/sequence-flow.component.html [new file with mode: 0644]
sdc-workflow-designer-ui/src/app/components/sequence-flow/sequence-flow.component.ts [new file with mode: 0644]
sdc-workflow-designer-ui/src/app/services/broadcast.service.ts
sdc-workflow-designer-ui/src/app/services/jsplumb.service.ts
sdc-workflow-designer-ui/src/app/services/workflow-process.service.ts

index 856e52b..1917b83 100644 (file)
@@ -19,4 +19,5 @@
         <b4t-canvas></b4t-canvas>
     </div>
     <b4t-properties></b4t-properties>
+    <b4t-sequence-flow></b4t-sequence-flow>
 </div>
index 6fa65af..e2d36a3 100644 (file)
@@ -44,6 +44,7 @@ import { EditablePropertyComponent } from "./components/editable-property/editab
 import { SwaggerTreeConverterService } from "./services/swagger-tree-converter.service";
 import { WorkflowProcessService } from "./services/workflow-process.service";
 import { IntermediateCatchEventComponent } from "./components/property/intermediate-catch-event/intermediate-catch-event.component";
+import { SequenceFlowComponent } from "./components/sequence-flow/sequence-flow.component";
 
 @NgModule({
     declarations: [
@@ -61,6 +62,7 @@ import { IntermediateCatchEventComponent } from "./components/property/intermedi
         PropertiesComponent,
         RestTaskComponent,
         RestTaskParametersComponent,
+        SequenceFlowComponent,
         StartEventParametersComponent,
         ToolbarComponent,
     ],
index ee00296..f4c0e21 100644 (file)
@@ -53,6 +53,7 @@ export class CanvasComponent implements AfterViewInit {
 
     public canvasClick() {
         this.broadcastService.broadcast(this.broadcastService.showProperty, false);
+        this.broadcastService.broadcast(this.broadcastService.showSequenceFlow, false);
     }
 
 
diff --git a/sdc-workflow-designer-ui/src/app/components/sequence-flow/sequence-flow.component.css b/sdc-workflow-designer-ui/src/app/components/sequence-flow/sequence-flow.component.css
new file mode 100644 (file)
index 0000000..a2d481d
--- /dev/null
@@ -0,0 +1,43 @@
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ *     ZTE - initial API and implementation and/or initial documentation
+ */
+
+.wm-sequence-flow-wrapper {
+    background-color: white;
+    position: fixed;
+    width: 500px;
+    height: 100%;
+    border-left: 1px solid #00aaff;
+    z-index: 2000;
+    right: 0;
+    top: 0;
+    bottom: 0;
+    padding-left: 20px;
+    margin-bottom: 0;
+    padding-right: 20px;
+    padding-top: 40px;
+    -webkit-box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
+    box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
+    border-radius: 0;
+    overflow-y: scroll;
+}
+
+.edit {
+    display: none;
+}
+
+.editing .view {
+    display: none;
+}
+
+.editing .edit {
+    display: block;
+}
diff --git a/sdc-workflow-designer-ui/src/app/components/sequence-flow/sequence-flow.component.html b/sdc-workflow-designer-ui/src/app/components/sequence-flow/sequence-flow.component.html
new file mode 100644 (file)
index 0000000..3a4c663
--- /dev/null
@@ -0,0 +1,53 @@
+<!--
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ *     ZTE - initial API and implementation and/or initial documentation
+ */
+ -->
+
+<div class="wm-sequence-flow-wrapper" *ngIf="show">
+    <div class="form-group row">
+        <div class="col-md-10"></div>
+        <div class="col-md-2 float-right">
+            <button (click)="delete()" type="button" class="btn btn-danger">
+                <i class="fa fa-trash" style="margin-right: 5px;"></i>
+            </button>
+        </div>
+    </div>
+
+    <div class="form-group row">
+        <label class="col-md-3 form-control-label text-md-right">Name</label>
+        <div class="col-md-9">
+            <input class="form-control" type="text" [(ngModel)]="sequenceFlow.name">
+        </div>
+    </div>
+
+    <div class="form-group row">
+        <label class="col-md-3 form-control-label text-md-right">Source</label>
+        <div class="col-md-9">
+            <input class="form-control" disabled type="text" [(ngModel)]="sequenceFlow.sourceRef">
+        </div>
+    </div>
+
+    <div class="form-group row">
+        <label class="col-md-3 form-control-label text-md-right">Target</label>
+        <div class="col-md-9">
+            <input class="form-control" disabled type="text" [(ngModel)]="sequenceFlow.targetRef">
+        </div>
+    </div>
+
+    <div class="form-group row">
+        <label class="col-md-3 form-control-label text-md-right">Condition</label>
+        <div class="col-md-9">
+            <input class="form-control" type="text" [ngModel]="sequenceFlow.condition"
+                   (ngModelChange)="conditionChanged($event)">
+        </div>
+    </div>
+</div>
diff --git a/sdc-workflow-designer-ui/src/app/components/sequence-flow/sequence-flow.component.ts b/sdc-workflow-designer-ui/src/app/components/sequence-flow/sequence-flow.component.ts
new file mode 100644 (file)
index 0000000..0109e27
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ *     ZTE - initial API and implementation and/or initial documentation
+ */
+
+import { AfterViewInit, Component } from '@angular/core';
+import { TreeNode } from 'primeng/primeng';
+
+import { SequenceFlow } from '../../model/workflow/sequence-flow';
+import { BroadcastService } from '../../services/broadcast.service';
+import { JsPlumbService } from '../../services/jsplumb.service';
+import { WorkflowProcessService } from '../../services/workflow-process.service';
+
+/**
+ * property component presents information of a workflow node.
+ * the presented information can be edit in this component.
+ * it may load information dynamically. the content may be different for different node type.
+ */
+@Component({
+    selector: 'b4t-sequence-flow',
+    styleUrls: ['./sequence-flow.component.css'],
+    templateUrl: 'sequence-flow.component.html',
+})
+export class SequenceFlowComponent implements AfterViewInit {
+    public sequenceFlow: SequenceFlow;
+    public show = false;
+
+    constructor(private broadcastService: BroadcastService,
+                private processService: WorkflowProcessService,
+                private jsPlumbService: JsPlumbService) {
+
+    }
+
+    public ngAfterViewInit() {
+        this.broadcastService.showSequenceFlow$.subscribe(show => this.show = show);
+        this.broadcastService.sequenceFlow$.subscribe(tmp => this.sequenceFlow = tmp);
+    }
+
+    public conditionChanged(condition: string) {
+        this.sequenceFlow.condition = condition;
+        this.jsPlumbService.setLabel(this.sequenceFlow.sourceRef, this.sequenceFlow.targetRef, condition);
+    }
+
+    public delete() {
+        this.show = false;
+
+        this.processService.deleteSequenceFlow(this.sequenceFlow.sourceRef, this.sequenceFlow.targetRef);
+        this.jsPlumbService.deleteConnect(this.sequenceFlow.sourceRef, this.sequenceFlow.targetRef);
+    }
+}
index eb87ba0..7726eae 100644 (file)
@@ -13,6 +13,7 @@ import { Injectable } from '@angular/core';
 import { Subject } from 'rxjs/Subject';
 
 import { WorkflowNode } from '../model/workflow/workflow-node';
+import { SequenceFlow } from "../model/workflow/sequence-flow";
 
 /**
  * BroadcastService
@@ -37,6 +38,12 @@ export class BroadcastService {
     public nodeTaskChange = new Subject<WorkflowNode>();
     public nodeTaskChange$ = this.nodeTaskChange.asObservable();
 
+    public showSequenceFlow = new Subject<boolean>();
+    public showSequenceFlow$ = this.showSequenceFlow.asObservable();
+
+    public sequenceFlow = new Subject<SequenceFlow>();
+    public sequenceFlow$ = this.sequenceFlow.asObservable();
+
     /**
      * broadcast datas
      * this method will catch the exceptions for the broadcast
index 543b09f..e4a9f38 100644 (file)
@@ -13,6 +13,7 @@
 import { Injectable } from '@angular/core';\r
 import * as jsp from 'jsplumb';\r
 import { WorkflowProcessService } from "./workflow-process.service";\r
+import { BroadcastService } from "./broadcast.service";\r
 \r
 /**\r
  * JsPlumbService\r
@@ -22,7 +23,7 @@ import { WorkflowProcessService } from "./workflow-process.service";
 export class JsPlumbService {\r
     public jsplumbInstance;\r
 \r
-    constructor(private processService: WorkflowProcessService) {\r
+    constructor(private processService: WorkflowProcessService, private broadcastService: BroadcastService) {\r
         this.initJsPlumbInstance();\r
     }\r
 \r
@@ -60,9 +61,15 @@ export class JsPlumbService {
         this.jsplumbInstance.bind('connection', info => {\r
             this.processService.addSequenceFlow(info.connection.sourceId, info.connection.targetId);\r
 \r
-            info.connection.bind('click', connection => {\r
-                this.jsplumbInstance.select({ connections: [connection] }).delete();\r
-                this.processService.deleteSequenceFlow(connection.sourceId, connection.targetId);\r
+            // info.connection.bind('click', connection => {\r
+            //     this.jsplumbInstance.select({ connections: [connection] }).delete();\r
+            //     this.processService.deleteSequenceFlow(connection.sourceId, connection.targetId);\r
+            // });\r
+\r
+            info.connection.bind('dblclick', connection => {\r
+                const sequenceFlow = this.processService.getSequenceFlow(connection.sourceId, connection.targetId);\r
+                this.broadcastService.broadcast(this.broadcastService.sequenceFlow, sequenceFlow);\r
+                this.broadcastService.broadcast(this.broadcastService.showSequenceFlow, true);\r
             });\r
         });\r
 \r
@@ -93,6 +100,18 @@ export class JsPlumbService {
 \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
+        connections.setLabel(label);\r
+    }\r
+\r
+    public deleteConnect(sourceId: string, targetId: string) {\r
+        const sourceNode = this.processService.getNodeById(sourceId);\r
+        const connectionSelection = this.jsplumbInstance.select({ source: sourceId, target: targetId });\r
+        connectionSelection.delete();\r
+    }\r
+\r
     public remove(nodeId: string) {\r
         this.jsplumbInstance.remove(nodeId);\r
     }\r
index 963a10b..7f56c4a 100644 (file)
@@ -95,6 +95,16 @@ export class WorkflowProcessService {
         }\r
     }\r
 \r
+    public getSequenceFlow(sourceRef: string, targetRef: string): SequenceFlow {\r
+        const node = this.getNodeById(sourceRef);\r
+        if (node) {\r
+            const sequenceFlow = node.sequenceFlows.find(tmp => tmp.targetRef === targetRef);\r
+            return sequenceFlow;\r
+        } else {\r
+            return undefined;\r
+        }\r
+    }\r
+\r
     public getPlanParameters(nodeId: string): PlanTreeviewItem[] {\r
         const preNodeList = new Array<WorkflowNode>();\r
         this.getPreNodes(nodeId, preNodeList);\r