Merge pull request #5772 from ArtemDzhereleiko/bug-fix/show-hide-legend

[3.3.3] UI: Show legend fieldset only in timeseries and latest widget
This commit is contained in:
Igor Kulikov 2022-01-12 16:45:50 +02:00 committed by GitHub
commit 4d27a69bce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 6 deletions

View File

@ -60,11 +60,13 @@ export class LegendComponent implements OnInit {
} }
legendKeys(): LegendKey[] { legendKeys(): LegendKey[] {
let keys = this.legendData.keys; try {
if (this.legendConfig.sortDataKeys) { let keys = this.legendData.keys;
keys = this.legendData.keys.sort((key1, key2) => key1.dataKey.label.localeCompare(key2.dataKey.label)); if (this.legendConfig.sortDataKeys) {
} keys = this.legendData.keys.sort((key1, key2) => key1.dataKey.label.localeCompare(key2.dataKey.label));
return keys.filter(legendKey => this.legendData.keys[legendKey.dataIndex].dataKey.inLegend); }
return keys.filter(legendKey => this.legendData.keys[legendKey.dataIndex].dataKey.inLegend);
} catch (e) {}
} }
} }

View File

@ -425,7 +425,7 @@
</ng-template> </ng-template>
</mat-expansion-panel> </mat-expansion-panel>
</fieldset> </fieldset>
<fieldset class="fields-group fields-group-slider"> <fieldset class="fields-group fields-group-slider" *ngIf="showLegendFieldset">
<legend class="group-title" translate>widget-config.legend</legend> <legend class="group-title" translate>widget-config.legend</legend>
<mat-expansion-panel class="tb-settings"> <mat-expansion-panel class="tb-settings">
<mat-expansion-panel-header fxLayout="row wrap"> <mat-expansion-panel-header fxLayout="row wrap">

View File

@ -159,6 +159,8 @@ export class WidgetConfigComponent extends PageComponent implements OnInit, Cont
modelValue: WidgetConfigComponentData; modelValue: WidgetConfigComponentData;
showLegendFieldset = true;
private propagateChange = null; private propagateChange = null;
public dataSettings: FormGroup; public dataSettings: FormGroup;
@ -323,6 +325,7 @@ export class WidgetConfigComponent extends PageComponent implements OnInit, Cont
this.datasourceTypes.push(DatasourceType.entityCount); this.datasourceTypes.push(DatasourceType.entityCount);
} }
} }
this.dataSettings = this.fb.group({}); this.dataSettings = this.fb.group({});
this.targetDeviceSettings = this.fb.group({}); this.targetDeviceSettings = this.fb.group({});
this.alarmSourceSettings = this.fb.group({}); this.alarmSourceSettings = this.fb.group({});
@ -386,6 +389,7 @@ export class WidgetConfigComponent extends PageComponent implements OnInit, Cont
if (this.modelValue) { if (this.modelValue) {
if (this.widgetType !== this.modelValue.widgetType) { if (this.widgetType !== this.modelValue.widgetType) {
this.widgetType = this.modelValue.widgetType; this.widgetType = this.modelValue.widgetType;
this.showLegendFieldset = (this.widgetType === widgetType.timeseries || this.widgetType === widgetType.latest);
this.buildForms(); this.buildForms();
} }
const config = this.modelValue.config; const config = this.modelValue.config;