hierarchy edit dialog component added
This commit is contained in:
+6
@@ -0,0 +1,6 @@
|
||||
<button
|
||||
mat-icon-button
|
||||
(click)="openDialog()"
|
||||
matTooltip="Hierarchie bearbeiten">
|
||||
<mat-icon color="primary">edit </mat-icon>
|
||||
</button>
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
import { Component, EventEmitter, Output, inject, input } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
||||
|
||||
import { HierarchyTreeEditorComponent } from '../hierarchy-tree-editor/hierarchy-tree-editor.component';
|
||||
import type { RawNode } from '../hierarchy-chart.component';
|
||||
|
||||
export interface HierarchyEditorDialogData {
|
||||
tree: RawNode | null;
|
||||
numberOfSuggestions: number;
|
||||
}
|
||||
@Component({
|
||||
selector: 'app-hierarchy-edit-dialog',
|
||||
standalone: true,
|
||||
imports: [MatButtonModule, MatIconModule, MatTooltipModule, MatDialogModule],
|
||||
templateUrl: './hierarchy-edit-dialog.component.html',
|
||||
})
|
||||
export class HierarchyEditDialogComponent {
|
||||
private readonly dialog = inject(MatDialog);
|
||||
numberOfSuggestions = input<number>(0);
|
||||
data = input.required<RawNode | null>();
|
||||
|
||||
@Output() saved = new EventEmitter<RawNode>();
|
||||
|
||||
openDialog(): void {
|
||||
const dialogRef = this.dialog.open<
|
||||
HierarchyTreeEditorComponent,
|
||||
HierarchyEditorDialogData,
|
||||
RawNode
|
||||
>(HierarchyTreeEditorComponent, {
|
||||
data: {
|
||||
tree: this.data(),
|
||||
numberOfSuggestions: this.numberOfSuggestions(),
|
||||
},
|
||||
width: '65%',
|
||||
maxWidth: '95vw',
|
||||
maxHeight: '90vh',
|
||||
panelClass: 'hierarchy-edit-dialog-panel',
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
if (result) {
|
||||
this.saved.emit(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user