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 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) {

View File

@ -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";

View File

@ -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<SVGGElement>("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');
}
}