diff --git a/src/app/cartography/components/map/map.component.ts b/src/app/cartography/components/map/map.component.ts index 4fe64875..6d922ece 100644 --- a/src/app/cartography/components/map/map.component.ts +++ b/src/app/cartography/components/map/map.component.ts @@ -55,7 +55,6 @@ export class MapComponent implements OnInit, OnChanges, OnDestroy { private onChangesDetected: Subscription; private nodeDraggedSub: Subscription; private drawingDraggedSub: Subscription; - private selectionChanged: Subscription; protected settings = { 'show_interface_labels': true @@ -83,6 +82,9 @@ export class MapComponent implements OnInit, OnChanges, OnDestroy { private drawingsEventSource: DrawingsEventSource, ) { this.parentNativeElement = element.nativeElement; + + this.selectionToolWidget.setEnabled(false); + this.movingToolWidget.setEnabled(false); } @Input('show-interface-labels') @@ -157,7 +159,7 @@ export class MapComponent implements OnInit, OnChanges, OnDestroy { this.onChangesDetected.unsubscribe(); this.mapListeners.onDestroy(); this.nodeDraggedSub.unsubscribe(); - this.selectionChanged.unsubscribe(); + this.drawingDraggedSub.unsubscribe(); } public createGraph(domElement: HTMLElement) { diff --git a/src/app/cartography/listeners/selection-listener.spec.ts b/src/app/cartography/listeners/selection-listener.spec.ts index df56955c..5c8436ef 100644 --- a/src/app/cartography/listeners/selection-listener.spec.ts +++ b/src/app/cartography/listeners/selection-listener.spec.ts @@ -1,5 +1,3 @@ -import { Subject} from "rxjs"; - import { Rectangle } from "../models/rectangle"; import { InRectangleHelper } from "../helpers/in-rectangle-helper"; import { MapNode } from "../models/map/map-node"; diff --git a/src/app/cartography/tools/selection-tool.ts b/src/app/cartography/tools/selection-tool.ts index da78d63a..e5602dd4 100644 --- a/src/app/cartography/tools/selection-tool.ts +++ b/src/app/cartography/tools/selection-tool.ts @@ -23,14 +23,6 @@ export class SelectionTool { ) {} public setEnabled(enabled) { - if (this.enabled != enabled) { - if (enabled) { - this.needsActivate = true; - } - else { - this.needsDeactivate = true; - } - } this.enabled = enabled; } @@ -80,13 +72,17 @@ export class SelectionTool { .attr("visibility", "hidden"); } - if(this.needsActivate) { + const tool = canvas.select("g.selection-line-tool"); + const status = tool.attr('status'); + + + if(status !== 'activated' && this.enabled) { this.activate(selection); - this.needsActivate = false; + tool.attr('activated'); } - if(this.needsDeactivate) { + if(status !== 'deactivated' && !this.enabled) { this.deactivate(selection); - this.needsDeactivate = false; + tool.attr('deactivated'); } }