File

src/app/components/graph-editor/link-form/link-form.component.ts

Description

Component for editing and deleting links (edges) of a graph.

Metadata

Index

Properties
Methods
Inputs
Outputs

Constructor

Public constructor(log: NGXLogger)
Parameters :
Name Type Optional
log NGXLogger No

Inputs

link
Type : D3Link | null

Outputs

linkDeletionRequested
Type : EventEmitter
linkUpdated
Type : EventEmitter

Methods

Public onLinkDeleted
onLinkDeleted(deletedLink: D3Link)
Parameters :
Name Type Optional
deletedLink D3Link No
Returns : void
Public onLinkUpdated
onLinkUpdated()
Returns : void
Public requestLinkDeletion
requestLinkDeletion()
Returns : void

Properties

Public Readonly functionEditorConfig
Default value : FUNCTION_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 { FUNCTION_SYMBOL_EDITOR_CONFIGURATION, RELATION_SYMBOL_EDITOR_CONFIGURATION } from 'src/app/configurations/symbol-editor.configuration';
import { D3Link } from 'src/app/model/d3/d3.link';

/**
 * Component for editing and deleting links (edges) of a graph.
 */
@Component({
  selector: 'apollo-link-form[link]',
  templateUrl: './link-form.component.html',
  styleUrls: ['./link-form.component.scss'],
})
export class LinkFormComponent {
  @Input() public link!: D3Link | null;

  @Output() public readonly linkDeletionRequested = new EventEmitter<D3Link>();
  @Output() public readonly linkUpdated = new EventEmitter();

  public readonly relationEditorConfig = RELATION_SYMBOL_EDITOR_CONFIGURATION;
  public readonly functionEditorConfig = FUNCTION_SYMBOL_EDITOR_CONFIGURATION;

  public constructor(private readonly log: NGXLogger) {}

  public requestLinkDeletion(): void {
    if (this.link !== null) {
      const link = this.link;
      this.link = null;
      this.linkDeletionRequested.emit(link);
    }
  }

  public onLinkUpdated(): void {
    this.linkUpdated.emit();
  }

  public onLinkDeleted(deletedLink: D3Link): void {
    if (this.link !== null && this.link.source.id === deletedLink.source.id && this.link.target.id === deletedLink.target.id) {
      this.log.debug(`Removing Link ${this.link.source.id}-${this.link.target.id}, because it has been deleted.`);
      this.link = null;
    }
  }
}
<mat-card class="link-form-card mat-elevation-z4">
  <ng-container *ngIf="!link">
    <mat-card-subtitle>{{ "editor.link.none-selected" | translate }}</mat-card-subtitle>
  </ng-container>
  <ng-container *ngIf="!!link">
    <mat-card-title>
      <span class="link-title">{{ "editor.link.title" | translate }} {{ link!.source.id }}<mat-icon>arrow_right_alt</mat-icon>{{ link!.target.id }}</span>
    </mat-card-title>
    <mat-card-content>
      <div>
        <apollo-symbol-editor [symbols]="link!.relations" [config]="relationEditorConfig" (symbolsUpdated)="onLinkUpdated()"></apollo-symbol-editor>
      </div>
      <div>
        <apollo-symbol-editor [symbols]="link!.functions" [config]="functionEditorConfig" (symbolsUpdated)="onLinkUpdated()"></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)="requestLinkDeletion()">
          <mat-icon>delete</mat-icon>
        </button>
      </div>
    </mat-card-actions>
  </ng-container>
</mat-card>

./link-form.component.scss

:host {
  display: block;
}

.link-form-card {
  overflow: auto;
}

.form-button-container {
  text-align: right;
}

.link-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""