diff --git a/src/app/cartography/shared/managers/selection-manager.spec.ts b/src/app/cartography/shared/managers/selection-manager.spec.ts index eb86e310..4be36928 100644 --- a/src/app/cartography/shared/managers/selection-manager.spec.ts +++ b/src/app/cartography/shared/managers/selection-manager.spec.ts @@ -2,6 +2,7 @@ import { Subject} from "rxjs/Subject"; import { Node } from "../models/node"; import { Link } from "../models/link"; +import { Drawing } from "../models/drawing"; import { Rectangle } from "../models/rectangle"; import { SelectionManager } from "./selection-manager"; import { NodesDataSource } from "../datasources/nodes-datasource"; @@ -75,4 +76,20 @@ describe('SelectionManager', () => { manager.setSelectedLinks([link]); expect(manager.getSelectedLinks().length).toEqual(1); }); + + it('items should be cleared', () => { + const link = new Link(); + link.link_id = "test1"; + const node = new Node(); + node.node_id = "test1"; + const drawing = new Drawing(); + drawing.drawing_id = "test1" + manager.setSelectedLinks([link]); + manager.setSelectedNodes([node]); + manager.setSelectedDrawings([drawing]); + manager.clearSelection(); + expect(manager.getSelectedLinks().length).toEqual(0); + expect(manager.getSelectedDrawings().length).toEqual(0); + expect(manager.getSelectedNodes().length).toEqual(0); + }); }); diff --git a/src/app/cartography/shared/managers/selection-manager.ts b/src/app/cartography/shared/managers/selection-manager.ts index df0980bd..0b9413e2 100644 --- a/src/app/cartography/shared/managers/selection-manager.ts +++ b/src/app/cartography/shared/managers/selection-manager.ts @@ -76,6 +76,12 @@ export class SelectionManager { }); } + public clearSelection() { + this.setSelectedDrawings([]); + this.setSelectedLinks([]); + this.setSelectedNodes([]); + } + private getSelectedItemsInRectangle(dataSource: DataSource, rectangle: Rectangle) { return this.setSelectedItems(dataSource, (item: T) => { return this.inRectangleHelper.inRectangle(rectangle, item.x, item.y); diff --git a/src/app/project-map/project-map.component.ts b/src/app/project-map/project-map.component.ts index 499491f1..0645df2c 100644 --- a/src/app/project-map/project-map.component.ts +++ b/src/app/project-map/project-map.component.ts @@ -199,6 +199,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { }); this.mapChild.graphLayout.getNodesWidget().setOnNodeClickedCallback((event: any, node: Node) => { + this.selectionManager.clearSelection(); this.selectionManager.setSelectedNodes([node]); if (this.drawLineMode) { this.nodeSelectInterfaceMenu.open(node, event.clientY, event.clientX);