diff options
author | Lvbo163 <lv.bo163@zte.com.cn> | 2017-09-08 15:08:50 +0800 |
---|---|---|
committer | Lvbo163 <lv.bo163@zte.com.cn> | 2017-09-08 15:08:50 +0800 |
commit | 5a25850bf3006f17690bf999f6c58d27eb97e0b7 (patch) | |
tree | b883c64e54770aa9f1a6c016f8d29ec4008c039a /sdc-workflow-designer-ui/src/app/components/node/node.component.ts | |
parent | c705c43cceafb81434d6eee4ced0da7024c9c008 (diff) |
delete node and connection by keyboard
support delete selected node or connection by 'delete' key
Issue-ID: SDC-295
Change-Id: If4506331ad054b102c2ff70138adf2fc5e739e76
Signed-off-by: Lvbo163 <lv.bo163@zte.com.cn>
Diffstat (limited to 'sdc-workflow-designer-ui/src/app/components/node/node.component.ts')
-rw-r--r-- | sdc-workflow-designer-ui/src/app/components/node/node.component.ts | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/sdc-workflow-designer-ui/src/app/components/node/node.component.ts b/sdc-workflow-designer-ui/src/app/components/node/node.component.ts index c6a95961..7a48e5dc 100644 --- a/sdc-workflow-designer-ui/src/app/components/node/node.component.ts +++ b/sdc-workflow-designer-ui/src/app/components/node/node.component.ts @@ -10,11 +10,12 @@ * ZTE - initial API and implementation and/or initial documentation
*/
-import { Component, AfterViewInit, Input } from '@angular/core';
+import { Component, AfterViewInit, Input, OnDestroy } from '@angular/core';
import { JsPlumbService } from '../../services/jsplumb.service';
import { BroadcastService } from "../../services/broadcast.service";
import { WorkflowNode } from "../../model/workflow/workflow-node";
+import { Subscription } from "rxjs/Subscription";
/**
* workflow node component
@@ -24,11 +25,15 @@ import { WorkflowNode } from "../../model/workflow/workflow-node"; styleUrls: ['./node.component.css'],
templateUrl: 'node.component.html',
})
-export class NodeComponent implements AfterViewInit {
+export class NodeComponent implements AfterViewInit, OnDestroy {
@Input() public node: WorkflowNode;
@Input() public last: boolean;
+ public active = false;
+ private currentTypeSubscription: Subscription;
+ private currentWorkflowSubscription: Subscription;
+
constructor(private broadcastService: BroadcastService,
private jsPlumbService: JsPlumbService) {
@@ -38,6 +43,25 @@ export class NodeComponent implements AfterViewInit { if(this.last) {
this.jsPlumbService.initNode('.node');
}
+
+ this.currentTypeSubscription = this.broadcastService.currentType$.subscribe(type => {
+ if (type === 'SequenceFlow') {
+ this.active = false;
+ }
+ });
+
+ this.currentWorkflowSubscription = this.broadcastService.currentWorkflowNode$.subscribe(activeNode => {
+ if (activeNode.id === this.node.id) {
+ this.active = true;
+ } else {
+ this.active = false;
+ }
+ });
+ }
+
+ public ngOnDestroy() {
+ this.currentTypeSubscription.unsubscribe();
+ this.currentWorkflowSubscription.unsubscribe();
}
public showProperties() {
@@ -53,4 +77,9 @@ export class NodeComponent implements AfterViewInit { }
}
+ public onSelected() {
+ this.broadcastService.broadcast(this.broadcastService.currentWorkflowNode, this.node);
+ this.broadcastService.broadcast(this.broadcastService.currentType, 'WorkflowNode');
+ }
+
}
|