Locking items added

This commit is contained in:
Piotr Pekala
2019-06-24 06:24:38 -07:00
parent ba478d4894
commit b4bbd97a40
6 changed files with 132 additions and 100 deletions

View File

@ -186,6 +186,7 @@ import { DefaultConsoleService } from './services/settings/default-console.servi
import { NodeCreatedLabelStylesFixer } from './components/project-map/helpers/node-created-label-styles-fixer';
import { NonNegativeValidator } from './validators/non-negative-validator';
import { RotationValidator } from './validators/rotation-validator';
import { MapSettingService } from './services/mapsettings.service';
if (environment.production) {
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
@ -378,7 +379,8 @@ if (environment.production) {
DefaultConsoleService,
NodeCreatedLabelStylesFixer,
NonNegativeValidator,
RotationValidator
RotationValidator,
MapSettingService
],
entryComponents: [
AddServerDialogComponent,

View File

@ -21,6 +21,7 @@ import { MapLabel } from '../../models/map/map-label';
import { MapLinkNode } from '../../models/map/map-link-node';
import { select } from 'd3-selection';
import { MapLink } from '../../models/map/map-link';
import { MapSettingService } from '../../../services/mapsettings.service';
describe('DraggableSelectionComponent', () => {
let component: DraggableSelectionComponent;
@ -121,7 +122,8 @@ describe('DraggableSelectionComponent', () => {
{ provide: NodesEventSource, useValue: nodesEventSourceStub },
{ provide: DrawingsEventSource, useValue: drawingsEventSourceStub },
{ provide: GraphDataManager, useValue: mockedGraphDataManager },
{ provide: LinksEventSource, useValue: linksEventSourceStub }
{ provide: LinksEventSource, useValue: linksEventSourceStub },
{ provide: MapSettingService, useClass: MapSettingService }
],
declarations: [DraggableSelectionComponent]
}).compileComponents();

View File

@ -17,6 +17,7 @@ import { LabelWidget } from '../../widgets/label';
import { InterfaceLabelWidget } from '../../widgets/interface-label';
import { MapLinkNode } from '../../models/map/map-link-node';
import { LinksEventSource } from '../../events/links-event-source';
import { MapSettingService } from '../../../services/mapsettings.service';
@Component({
selector: 'app-draggable-selection',
@ -27,6 +28,8 @@ export class DraggableSelectionComponent implements OnInit, OnDestroy {
private start: Subscription;
private drag: Subscription;
private end: Subscription;
private mapSettingsSubscription: Subscription;
private isMapLocked: boolean = false;
@Input('svg') svg: SVGSVGElement;
@ -40,12 +43,17 @@ export class DraggableSelectionComponent implements OnInit, OnDestroy {
private nodesEventSource: NodesEventSource,
private drawingsEventSource: DrawingsEventSource,
private graphDataManager: GraphDataManager,
private linksEventSource: LinksEventSource
private linksEventSource: LinksEventSource,
private mapSettingsService: MapSettingService
) {}
ngOnInit() {
const svg = select(this.svg);
this.mapSettingsService.isMapLocked.subscribe((value) => {
this.isMapLocked = value;
});
this.start = merge(
this.nodesWidget.draggable.start,
this.drawingsWidget.draggable.start,
@ -84,6 +92,7 @@ export class DraggableSelectionComponent implements OnInit, OnDestroy {
this.labelWidget.draggable.drag,
this.interfaceWidget.draggable.drag
).subscribe((evt: DraggableDrag<any>) => {
if (!this.isMapLocked) {
const selected = this.selectionManager.getSelected();
const selectedNodes = selected.filter(item => item instanceof MapNode);
// update nodes
@ -153,6 +162,7 @@ export class DraggableSelectionComponent implements OnInit, OnDestroy {
this.linksWidget.redrawLink(svg, link);
});
}
});
this.end = merge(
@ -161,6 +171,7 @@ export class DraggableSelectionComponent implements OnInit, OnDestroy {
this.labelWidget.draggable.end,
this.interfaceWidget.draggable.end
).subscribe((evt: DraggableEnd<any>) => {
if (!this.isMapLocked) {
const selected = this.selectionManager.getSelected();
const selectedNodes = selected.filter(item => item instanceof MapNode);
@ -194,6 +205,7 @@ export class DraggableSelectionComponent implements OnInit, OnDestroy {
}
this.linksEventSource.interfaceDragged.emit(new DraggedDataEvent<MapLinkNode>(label, evt.dx, evt.dy));
});
}
});
}
@ -201,5 +213,6 @@ export class DraggableSelectionComponent implements OnInit, OnDestroy {
this.start.unsubscribe();
this.drag.unsubscribe();
this.end.unsubscribe();
this.mapSettingsSubscription.unsubscribe();
}
}

View File

@ -43,6 +43,7 @@ import { Project } from '../../models/project';
import { CapturingSettings } from '../../models/capturingSettings';
import { LinkWidget } from '../../cartography/widgets/link';
import { NodeCreatedLabelStylesFixer } from './helpers/node-created-label-styles-fixer';
import { MapSettingService } from '../../services/mapsettings.service';
export class MockedProgressService {
public activate() {}
@ -220,7 +221,8 @@ describe('ProjectMapComponent', () => {
provide: RecentlyOpenedProjectService,
useClass: RecentlyOpenedProjectService
},
{ provide: NodeCreatedLabelStylesFixer, useValue: nodeCreatedLabelStylesFixer}
{ provide: NodeCreatedLabelStylesFixer, useValue: nodeCreatedLabelStylesFixer},
{ provide: MapSettingService }
],
declarations: [ProjectMapComponent, D3MapComponent, ...ANGULAR_MAP_DECLARATIONS],
schemas: [NO_ERRORS_SCHEMA]

View File

@ -44,7 +44,7 @@ import { MapLink } from '../../cartography/models/map/map-link';
import { MapLinkToLinkConverter } from '../../cartography/converters/map/map-link-to-link-converter';
import { LinkWidget } from '../../cartography/widgets/link';
import { NodeCreatedLabelStylesFixer } from './helpers/node-created-label-styles-fixer';
import { MovingTool } from '../../cartography/tools/moving-tool';
import { MapSettingService } from '../../services/mapsettings.service';
@Component({
@ -111,9 +111,9 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
private toolsService: ToolsService,
private selectionManager: SelectionManager,
private selectionTool: SelectionTool,
private movingTool: MovingTool,
private recentlyOpenedProjectService: RecentlyOpenedProjectService,
private nodeCreatedLabelStylesFixer: NodeCreatedLabelStylesFixer
private nodeCreatedLabelStylesFixer: NodeCreatedLabelStylesFixer,
private mapSettingsService: MapSettingService
) {}
ngOnInit() {
@ -400,7 +400,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
public changeLockValue() {
this.isLocked = !this.isLocked;
this.movingTool.setEnabled(this.isLocked);
this.mapSettingsService.changeMapLockValue(this.isLocked);
}
public ngOnDestroy() {

View File

@ -0,0 +1,13 @@
import { Injectable } from "@angular/core";
import { Subject } from 'rxjs';
@Injectable()
export class MapSettingService {
public isMapLocked = new Subject<boolean>();
constructor() {}
changeMapLockValue(value: boolean) {
this.isMapLocked.next(value);
}
}