File
Description
Component for editing and deleting nodes of a graph.
Index
Properties
|
|
Methods
|
|
Inputs
|
|
Outputs
|
|
Constructor
Public
constructor(log: NGXLogger)
|
|
Parameters :
Name |
Type |
Optional |
log |
NGXLogger
|
No
|
|
Outputs
nodeDeletionRequested
|
Type : EventEmitter
|
|
nodeUpdated
|
Type : EventEmitter
|
|
Methods
Public
onNodeDeleted
|
onNodeDeleted(deletedNode: D3Node)
|
|
Parameters :
Name |
Type |
Optional |
deletedNode |
D3Node
|
No
|
|
Public
onNodeUpdated
|
onNodeUpdated()
|
|
|
Public
requestNodeDeletion
|
requestNodeDeletion()
|
|
|
Public
Readonly
constantEditorConfig
|
Default value : CONSTANT_SYMBOL_EDITOR_CONFIGURATION
|
|
Public
Readonly
relationEditorConfig
|
Default value : RELATION_SYMBOL_EDITOR_CONFIGURATION
|
|
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { NGXLogger } from 'ngx-logger';
import { CONSTANT_SYMBOL_EDITOR_CONFIGURATION, RELATION_SYMBOL_EDITOR_CONFIGURATION } from 'src/app/configurations/symbol-editor.configuration';
import { D3Node } from 'src/app/model/d3/d3.node';
/**
* Component for editing and deleting nodes of a graph.
*/
@Component({
selector: 'apollo-node-form[node]',
templateUrl: './node-form.component.html',
styleUrls: ['./node-form.component.scss'],
})
export class NodeFormComponent {
@Input() public node!: D3Node | null;
@Output() public readonly nodeDeletionRequested = new EventEmitter<D3Node>();
@Output() public readonly nodeUpdated = new EventEmitter();
public readonly relationEditorConfig = RELATION_SYMBOL_EDITOR_CONFIGURATION;
public readonly constantEditorConfig = CONSTANT_SYMBOL_EDITOR_CONFIGURATION;
public constructor(private readonly log: NGXLogger) {}
public requestNodeDeletion(): void {
if (this.node !== null) {
const node = this.node;
this.node = null;
this.nodeDeletionRequested.emit(node);
}
}
public onNodeUpdated(): void {
this.nodeUpdated.emit();
}
public onNodeDeleted(deletedNode: D3Node): void {
if (this.node !== null && this.node.id === deletedNode.id) {
this.log.debug(`Removing Node ${this.node.id}, because it has been deleted.`);
this.node = null;
}
}
}
<mat-card class="node-form-card mat-elevation-z4">
<ng-container *ngIf="!node">
<mat-card-subtitle>{{ "editor.node.none-selected" | translate }}</mat-card-subtitle>
</ng-container>
<ng-container *ngIf="!!node">
<mat-card-title>{{ "editor.node.title" | translate }} {{ node!.id }}</mat-card-title>
<mat-card-content>
<div>
<apollo-symbol-editor [symbols]="node!.relations" [config]="relationEditorConfig" (symbolsUpdated)="onNodeUpdated()"></apollo-symbol-editor>
</div>
<div>
<apollo-symbol-editor [symbols]="node!.constants" [config]="constantEditorConfig" (symbolsUpdated)="onNodeUpdated()"></apollo-symbol-editor>
</div>
</mat-card-content>
<mat-card-actions>
<div class="form-button-container">
<button type="button" mat-icon-button [matTooltip]="'actions.delete' | translate" color="warn" (click)="requestNodeDeletion()">
<mat-icon>delete</mat-icon>
</button>
</div>
</mat-card-actions>
</ng-container>
</mat-card>
:host {
display: block;
}
.node-form-card {
overflow: auto;
}
.form-button-container {
text-align: right;
}
Legend
Html element with directive