Disable/enable selection

This commit is contained in:
ziajka 2018-11-15 10:12:53 +01:00
parent 320ce4a827
commit e174de142c
3 changed files with 12 additions and 16 deletions

View File

@ -55,7 +55,6 @@ export class MapComponent implements OnInit, OnChanges, OnDestroy {
private onChangesDetected: Subscription; private onChangesDetected: Subscription;
private nodeDraggedSub: Subscription; private nodeDraggedSub: Subscription;
private drawingDraggedSub: Subscription; private drawingDraggedSub: Subscription;
private selectionChanged: Subscription;
protected settings = { protected settings = {
'show_interface_labels': true 'show_interface_labels': true
@ -83,6 +82,9 @@ export class MapComponent implements OnInit, OnChanges, OnDestroy {
private drawingsEventSource: DrawingsEventSource, private drawingsEventSource: DrawingsEventSource,
) { ) {
this.parentNativeElement = element.nativeElement; this.parentNativeElement = element.nativeElement;
this.selectionToolWidget.setEnabled(false);
this.movingToolWidget.setEnabled(false);
} }
@Input('show-interface-labels') @Input('show-interface-labels')
@ -157,7 +159,7 @@ export class MapComponent implements OnInit, OnChanges, OnDestroy {
this.onChangesDetected.unsubscribe(); this.onChangesDetected.unsubscribe();
this.mapListeners.onDestroy(); this.mapListeners.onDestroy();
this.nodeDraggedSub.unsubscribe(); this.nodeDraggedSub.unsubscribe();
this.selectionChanged.unsubscribe(); this.drawingDraggedSub.unsubscribe();
} }
public createGraph(domElement: HTMLElement) { public createGraph(domElement: HTMLElement) {

View File

@ -1,5 +1,3 @@
import { Subject} from "rxjs";
import { Rectangle } from "../models/rectangle"; import { Rectangle } from "../models/rectangle";
import { InRectangleHelper } from "../helpers/in-rectangle-helper"; import { InRectangleHelper } from "../helpers/in-rectangle-helper";
import { MapNode } from "../models/map/map-node"; import { MapNode } from "../models/map/map-node";

View File

@ -23,14 +23,6 @@ export class SelectionTool {
) {} ) {}
public setEnabled(enabled) { public setEnabled(enabled) {
if (this.enabled != enabled) {
if (enabled) {
this.needsActivate = true;
}
else {
this.needsDeactivate = true;
}
}
this.enabled = enabled; this.enabled = enabled;
} }
@ -80,13 +72,17 @@ export class SelectionTool {
.attr("visibility", "hidden"); .attr("visibility", "hidden");
} }
if(this.needsActivate) { const tool = canvas.select<SVGGElement>("g.selection-line-tool");
const status = tool.attr('status');
if(status !== 'activated' && this.enabled) {
this.activate(selection); this.activate(selection);
this.needsActivate = false; tool.attr('activated');
} }
if(this.needsDeactivate) { if(status !== 'deactivated' && !this.enabled) {
this.deactivate(selection); this.deactivate(selection);
this.needsDeactivate = false; tool.attr('deactivated');
} }
} }