mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-17 06:18:09 +00:00
Dialog for editing text created
This commit is contained in:
@ -3,9 +3,7 @@ import { Drawing } from '../../../../../cartography/models/drawing';
|
||||
import { Server } from '../../../../../models/server';
|
||||
import { MatDialog } from '@angular/material';
|
||||
import { Project } from '../../../../../models/project';
|
||||
import { TextElement } from '../../../../../cartography/models/drawings/text-element';
|
||||
import { StyleEditorDialogComponent } from '../../../drawings-editors/style-editor/style-editor.component';
|
||||
import { TextEditorDialogComponent } from '../../../drawings-editors/text-editor/text-editor.component';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -24,10 +22,6 @@ export class EditStyleActionComponent implements OnInit {
|
||||
ngOnInit() {}
|
||||
|
||||
editStyle() {
|
||||
this.drawing.element instanceof TextElement ? this.openTextEditor() : this.openStyleEditor();
|
||||
}
|
||||
|
||||
openStyleEditor() {
|
||||
const dialogRef = this.dialog.open(StyleEditorDialogComponent, {
|
||||
width: '550px',
|
||||
});
|
||||
@ -36,14 +30,4 @@ export class EditStyleActionComponent implements OnInit {
|
||||
instance.project = this.project;
|
||||
instance.drawing = this.drawing;
|
||||
}
|
||||
|
||||
openTextEditor() {
|
||||
const dialogRef = this.dialog.open(TextEditorDialogComponent, {
|
||||
width: '550px',
|
||||
});
|
||||
let instance = dialogRef.componentInstance;
|
||||
instance.server = this.server;
|
||||
instance.project = this.project;
|
||||
instance.drawing = this.drawing;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,4 @@
|
||||
<button mat-menu-item (click)="editText()">
|
||||
<mat-icon>text_format</mat-icon>
|
||||
<span>Edit text</span>
|
||||
</button>
|
@ -0,0 +1,33 @@
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { Server } from '../../../../../models/server';
|
||||
import { Project } from '../../../../../models/project';
|
||||
import { Drawing } from '../../../../../cartography/models/drawing';
|
||||
import { MatDialog } from '@angular/material';
|
||||
import { TextEditorDialogComponent } from '../../../drawings-editors/text-editor/text-editor.component';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-edit-text-action',
|
||||
templateUrl: './edit-text-action.component.html'
|
||||
})
|
||||
export class EditTextActionComponent implements OnInit {
|
||||
@Input() server: Server;
|
||||
@Input() project: Project;
|
||||
@Input() drawing: Drawing;
|
||||
|
||||
constructor(
|
||||
private dialog: MatDialog
|
||||
) {}
|
||||
|
||||
ngOnInit() {}
|
||||
|
||||
editText() {
|
||||
const dialogRef = this.dialog.open(TextEditorDialogComponent, {
|
||||
width: '550px',
|
||||
});
|
||||
let instance = dialogRef.componentInstance;
|
||||
instance.server = this.server;
|
||||
instance.project = this.project;
|
||||
instance.drawing = this.drawing;
|
||||
}
|
||||
}
|
@ -3,7 +3,8 @@
|
||||
<mat-menu #contextMenu="matMenu" class="context-menu-items">
|
||||
<app-start-node-action *ngIf="hasNodeCapabilities" [server]="server" [node]="node"></app-start-node-action>
|
||||
<app-stop-node-action *ngIf="hasNodeCapabilities" [server]="server" [node]="node"></app-stop-node-action>
|
||||
<app-edit-style-action *ngIf="hasDrawingCapabilities" [server]="server" [project]="project" [drawing]="drawing"></app-edit-style-action>
|
||||
<app-edit-style-action *ngIf="hasDrawingCapabilities && !isTextElement" [server]="server" [project]="project" [drawing]="drawing"></app-edit-style-action>
|
||||
<app-edit-text-action *ngIf="hasDrawingCapabilities && isTextElement" [server]="server" [project]="project" [drawing]="drawing"></app-edit-text-action>
|
||||
<app-move-layer-up-action *ngIf="!projectService.isReadOnly(project)" [server]="server" [node]="node" [drawing]="drawing"></app-move-layer-up-action>
|
||||
<app-move-layer-down-action *ngIf="!projectService.isReadOnly(project)" [server]="server" [node]="node" [drawing]="drawing"></app-move-layer-down-action>
|
||||
</mat-menu>
|
||||
|
@ -6,6 +6,7 @@ import { Server } from "../../../models/server";
|
||||
import { Project } from "../../../models/project";
|
||||
import { ProjectService } from "../../../services/project.service";
|
||||
import { Drawing } from '../../../cartography/models/drawing';
|
||||
import { TextElement } from '../../../cartography/models/drawings/text-element';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -25,6 +26,7 @@ export class ContextMenuComponent implements OnInit {
|
||||
drawing: Drawing;
|
||||
private hasNodeCapabilities: boolean = false;
|
||||
private hasDrawingCapabilities: boolean = false;
|
||||
private isTextElement: boolean = false;
|
||||
|
||||
constructor(
|
||||
private sanitizer: DomSanitizer,
|
||||
@ -54,6 +56,7 @@ export class ContextMenuComponent implements OnInit {
|
||||
public openMenuForDrawing(drawing: Drawing, top: number, left: number) {
|
||||
this.resetCapabilities();
|
||||
this.hasDrawingCapabilities = true;
|
||||
this.isTextElement = drawing.element instanceof TextElement;
|
||||
|
||||
this.drawing = drawing;
|
||||
this.setPosition(top, left);
|
||||
@ -66,5 +69,6 @@ export class ContextMenuComponent implements OnInit {
|
||||
this.drawing = null;
|
||||
this.hasDrawingCapabilities = false;
|
||||
this.hasNodeCapabilities = false;
|
||||
this.isTextElement = false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user