Fix for selecting issue

This commit is contained in:
Piotr Pekala 2019-07-02 04:45:23 -07:00
parent 02f42c6681
commit 3a1111c82d
3 changed files with 27 additions and 24 deletions

View File

@ -14,7 +14,10 @@
[drawing]="drawings[0]"
></app-edit-style-action>
<app-edit-text-action
*ngIf="!projectService.isReadOnly(project) && drawings.length===1 && hasTextCapabilities || labels.length===1 || linkNodes.length===1"
*ngIf="!projectService.isReadOnly(project) &&
(drawings.length===1 && hasTextCapabilities && labels.length===0 && linkNodes.length===0 ||
labels.length===1 && linkNodes.length===0 && drawings.length===0 ||
linkNodes.length===1 && labels.length===0 && drawings.length===0)"
[server]="server"
[project]="project"
[drawing]="drawings[0]"
@ -64,7 +67,7 @@
[link]="links[0]"
></app-suspend-link-action>
<app-delete-action
*ngIf="!projectService.isReadOnly(project) && (drawings.length>0 || nodes.length>0 || links.length>0) && linkNodes.length === 0 && labels.length===0"
*ngIf="!projectService.isReadOnly(project) && (drawings.length>0 || nodes.length>0 || links.length>0) && linkNodes.length === 0"
[server]="server"
[nodes]="nodes"
[drawings]="drawings"

View File

@ -61,11 +61,7 @@ export class TextEditorDialogComponent implements OnInit {
rotation: new FormControl('', [Validators.required, this.rotationValidator.get])
});
if (this.drawing) {
this.isTextEditable = true;
this.rotation = this.drawing.rotation.toString();
this.element = this.drawing.element as TextElement;
} else if (this.label && this.node) {
if (this.label && this.node) {
this.isTextEditable = false;
this.rotation = this.label.rotation.toString();
this.element = this.getTextElementFromLabel();
@ -74,7 +70,11 @@ export class TextEditorDialogComponent implements OnInit {
this.label = this.link.nodes.find(n => n.node_id === this.linkNode.node_id).label;
this.rotation = this.label.rotation.toString();
this.element = this.getTextElementFromLabel();
}
} else if (this.drawing) {
this.isTextEditable = true;
this.rotation = this.drawing.rotation.toString();
this.element = this.drawing.element as TextElement;
};
this.formGroup.controls['rotation'].setValue(this.rotation);
this.renderer.setStyle(this.textArea.nativeElement, 'color', this.element.fill);
@ -116,20 +116,7 @@ export class TextEditorDialogComponent implements OnInit {
if (this.formGroup.valid) {
this.rotation = this.formGroup.get('rotation').value;
if (this.drawing) {
this.drawing.rotation = +this.rotation;
this.drawing.element = this.element;
let mapDrawing = this.drawingToMapDrawingConverter.convert(this.drawing);
mapDrawing.element = this.drawing.element;
this.drawing.svg = this.mapDrawingToSvgConverter.convert(mapDrawing);
this.drawingService.update(this.server, this.drawing).subscribe((serverDrawing: Drawing) => {
this.drawingsDataSource.update(serverDrawing);
this.dialogRef.close();
});
} else if (this.label && this.node) {
if (this.label && this.node) {
this.node.label.style = this.getStyleFromTextElement();
this.node.label.rotation = +this.rotation;
@ -146,7 +133,20 @@ export class TextEditorDialogComponent implements OnInit {
this.linksDataSource.update(link);
this.dialogRef.close();
});
}
} else if (this.drawing) {
this.drawing.rotation = +this.rotation;
this.drawing.element = this.element;
let mapDrawing = this.drawingToMapDrawingConverter.convert(this.drawing);
mapDrawing.element = this.drawing.element;
this.drawing.svg = this.mapDrawingToSvgConverter.convert(mapDrawing);
this.drawingService.update(this.server, this.drawing).subscribe((serverDrawing: Drawing) => {
this.drawingsDataSource.update(serverDrawing);
this.dialogRef.close();
});
};
} else {
this.toasterService.error(`Entered data is incorrect`);
}

View File

@ -267,7 +267,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
const onContextMenu = this.selectionTool.contextMenuOpened.subscribe((event) => {
const selectedItems = this.selectionManager.getSelected();
if (selectedItems.length === 0 || !(event instanceof MouseEvent)) return;
if (selectedItems.length < 2 || !(event instanceof MouseEvent)) return;
let drawings: Drawing[] = [];
let nodes: Node[] = [];