mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-04-08 02:54:16 +00:00
Disable dragging on readonly mode
This commit is contained in:
parent
69163e7b6d
commit
b89e9f1434
@ -25,6 +25,7 @@ import { MapListeners } from '../../listeners/map-listeners';
|
||||
import { DraggedDataEvent } from '../../events/event-source';
|
||||
import { NodesEventSource } from '../../events/nodes-event-source';
|
||||
import { DrawingsEventSource } from '../../events/drawings-event-source';
|
||||
import { DrawingsWidget } from '../../widgets/drawings';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -63,6 +64,7 @@ export class MapComponent implements OnInit, OnChanges, OnDestroy {
|
||||
protected nodesWidget: NodesWidget,
|
||||
protected nodeWidget: NodeWidget,
|
||||
protected linksWidget: LinksWidget,
|
||||
protected drawingsWidget: DrawingsWidget,
|
||||
protected interfaceLabelWidget: InterfaceLabelWidget,
|
||||
protected selectionToolWidget: SelectionTool,
|
||||
protected movingToolWidget: MovingTool,
|
||||
@ -95,6 +97,11 @@ export class MapComponent implements OnInit, OnChanges, OnDestroy {
|
||||
}
|
||||
|
||||
@Input('draw-link-tool') drawLinkTool: boolean;
|
||||
|
||||
@Input('readonly') set readonly(value) {
|
||||
this.nodesWidget.draggingEnabled = !value;
|
||||
this.drawingsWidget.draggingEnabled == !value;
|
||||
}
|
||||
|
||||
ngOnChanges(changes: { [propKey: string]: SimpleChange }) {
|
||||
if (
|
||||
|
@ -12,6 +12,7 @@ import { DrawingWidget } from "./drawing";
|
||||
@Injectable()
|
||||
export class DrawingsWidget implements Widget {
|
||||
public draggable = new Draggable<SVGGElement, Drawing>();
|
||||
public draggingEnabled = false;
|
||||
|
||||
// public onContextMenu = new EventEmitter<NodeContextMenu>();
|
||||
// public onDrawingClicked = new EventEmitter<NodeClicked>();
|
||||
@ -58,7 +59,9 @@ export class DrawingsWidget implements Widget {
|
||||
.exit()
|
||||
.remove();
|
||||
|
||||
this.draggable.call(merge);
|
||||
if (this.draggingEnabled) {
|
||||
this.draggable.call(merge);
|
||||
}
|
||||
}
|
||||
|
||||
private selectDrawing(view: SVGSelection, drawing: Drawing) {
|
||||
|
@ -21,7 +21,6 @@ export class NodeWidget implements Widget {
|
||||
public onNodeDragging = new EventEmitter<NodeDragging>();
|
||||
|
||||
private symbols: Symbol[] = [];
|
||||
private draggingEnabled = false;
|
||||
|
||||
constructor(
|
||||
private cssFixer: CssFixer,
|
||||
@ -32,10 +31,6 @@ export class NodeWidget implements Widget {
|
||||
this.symbols = symbols;
|
||||
}
|
||||
|
||||
public setDraggingEnabled(enabled: boolean) {
|
||||
this.draggingEnabled = enabled;
|
||||
}
|
||||
|
||||
public draw(view: SVGSelection) {
|
||||
const self = this;
|
||||
|
||||
|
@ -13,7 +13,8 @@ export class NodesWidget implements Widget {
|
||||
static NODE_LABEL_MARGIN = 3;
|
||||
|
||||
public draggable = new Draggable<SVGGElement, Node>();
|
||||
|
||||
public draggingEnabled = false;
|
||||
|
||||
constructor(
|
||||
private nodeWidget: NodeWidget
|
||||
) {
|
||||
@ -48,7 +49,9 @@ export class NodesWidget implements Widget {
|
||||
.exit()
|
||||
.remove();
|
||||
|
||||
this.draggable.call(merge);
|
||||
if (this.draggingEnabled) {
|
||||
this.draggable.call(merge);
|
||||
}
|
||||
}
|
||||
|
||||
private selectNode(view: SVGSelection, node: Node) {
|
||||
|
@ -10,6 +10,7 @@
|
||||
[selection-tool]="tools.selection"
|
||||
[moving-tool]="tools.moving"
|
||||
[draw-link-tool]="tools.draw_link"
|
||||
[readonly]="inReadOnlyMode"
|
||||
(nodeDragged)="onNodeDragged($event)"
|
||||
(drawingDragged)="onDrawingDragged($event)"
|
||||
(onLinkCreated)="onLinkCreated($event)"
|
||||
|
@ -23,11 +23,10 @@ import { NodesDataSource } from "../../cartography/datasources/nodes-datasource"
|
||||
import { LinksDataSource } from "../../cartography/datasources/links-datasource";
|
||||
import { ProjectWebServiceHandler } from "../../handlers/project-web-service-handler";
|
||||
import { SelectionManager } from "../../cartography/managers/selection-manager";
|
||||
import { InRectangleHelper } from "../../cartography/helpers/in-rectangle-helper";
|
||||
import { DrawingsDataSource } from "../../cartography/datasources/drawings-datasource";
|
||||
import { ProgressService } from "../../common/progress/progress.service";
|
||||
import { MapChangeDetectorRef } from '../../cartography/services/map-change-detector-ref';
|
||||
import { NodeContextMenu, NodeDragged } from '../../cartography/events/nodes';
|
||||
import { NodeContextMenu } from '../../cartography/events/nodes';
|
||||
import { LinkCreated } from '../../cartography/events/links';
|
||||
import { NodeWidget } from '../../cartography/widgets/node';
|
||||
import { DraggedDataEvent } from '../../cartography/events/event-source';
|
||||
@ -187,8 +186,6 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
setUpMapCallbacks(project: Project) {
|
||||
this.nodeWidget.setDraggingEnabled(!this.readonly);
|
||||
|
||||
const onContextMenu = this.nodeWidget.onContextMenu.subscribe((eventNode: NodeContextMenu) => {
|
||||
this.nodeContextMenu.open(
|
||||
eventNode.node,
|
||||
|
Loading…
x
Reference in New Issue
Block a user