diff --git a/src/app/components/network/network-legend/network-legend.component.html b/src/app/components/network/network-legend/network-legend.component.html index 9958f3dd231d50464f6746f0d017d7d664634f03..c758036ef1d03bc81f152f98aaf97ad7a3a33fb8 100644 --- a/src/app/components/network/network-legend/network-legend.component.html +++ b/src/app/components/network/network-legend/network-legend.component.html @@ -1,13 +1,13 @@ <div class="legend" - [class.right]="this.config.legendPos === 'right'" + [class.right]="config.legendPos === 'right'" [ngClass]="{ 'legend-small': drugstoneConfig.smallStyle }" > <div class="legend-background"></div> <!-- default legend in html --> - <table *ngIf="!this.config.legendUrl.length" class="legend-table"> - <ng-container *ngIf="this.config.showLegendNodes"> - <ng-container *ngFor="let nodeGroup of this.config.nodeGroups | keyvalue"> + <table *ngIf="!config.legendUrl.length" class="legend-table"> + <ng-container *ngIf="config.showLegendNodes"> + <ng-container *ngFor="let nodeGroup of config.nodeGroups | keyvalue"> <tr class="list-item" *ngIf="nodeGroup.key && checkNodeGroupContext(nodeGroup.key)" @@ -86,9 +86,9 @@ </ng-container> </ng-container> - <ng-container *ngIf="this.config.showLegendEdges"> + <ng-container *ngIf="config.showLegendEdges && _emptyEdgeConfig"> <tr - *ngFor="let edgeGroup of this.config.edgeGroups | keyvalue" + *ngFor="let edgeGroup of config.edgeGroups | keyvalue" class="list-item" > <ng-container @@ -114,8 +114,8 @@ <!-- custom legend image if url given by user --> <img - *ngIf="this.config.legendUrl.length" - [src]="this.config.legendUrl" - [ngClass]="this.config.legendClass" + *ngIf="config.legendUrl.length" + [src]="config.legendUrl" + [ngClass]="config.legendClass" /> </div> diff --git a/src/app/components/network/network-legend/network-legend.component.ts b/src/app/components/network/network-legend/network-legend.component.ts index 8c8c89b514bc870ecca3bc9ecce9066b3dc91e15..faa8c53f1d583a64b6ea08cc11fb9f5a6c56c9bb 100644 --- a/src/app/components/network/network-legend/network-legend.component.ts +++ b/src/app/components/network/network-legend/network-legend.component.ts @@ -10,7 +10,12 @@ import {IConfig} from '../../../config'; }) export class NetworkLegendComponent implements OnInit { - @Input() context: LegendContext; + _context = 'explorer'; + _emptyEdgeConfig = false; + @Input() set context (value: LegendContext) { + this._context = value; + this._emptyEdgeConfig = this.checkIfEdgeConfigEmpty(); + }; @Input() config: IConfig; private contextNodeGroupsToDelete = { @@ -40,11 +45,15 @@ export class NetworkLegendComponent implements OnInit { // selected node is not supposed to appear in legend return false; } - return !this.contextNodeGroupsToDelete[this.context].includes(nodeGroupKey); + return !this.contextNodeGroupsToDelete[this._context].includes(nodeGroupKey); } public checkEdgeGroupContext(edgeGroupKey) { - return !this.contextEdgeGroupsToDelete[this.context].includes(edgeGroupKey); + return !this.contextEdgeGroupsToDelete[this._context].includes(edgeGroupKey); + } + + public checkIfEdgeConfigEmpty() { + return Object.keys(this.config.edgeGroups).some(key => this.checkEdgeGroupContext(key)); } constructor(public drugstoneConfig: DrugstoneConfigService) { }