mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Don't show duplicates in statistics picker (#19422)
* Filter duplicates from ha-statistics-picker * use repeat
This commit is contained in:
parent
a06c9d0cc6
commit
22625a805d
@ -129,7 +129,8 @@ export class HaStatisticPicker extends LitElement {
|
||||
includeUnitClass?: string | string[],
|
||||
includeDeviceClass?: string | string[],
|
||||
entitiesOnly?: boolean,
|
||||
excludeStatistics?: string[]
|
||||
excludeStatistics?: string[],
|
||||
value?: string
|
||||
): StatisticItem[] => {
|
||||
if (!statisticIds.length) {
|
||||
return [
|
||||
@ -176,6 +177,7 @@ export class HaStatisticPicker extends LitElement {
|
||||
statisticIds.forEach((meta) => {
|
||||
if (
|
||||
excludeStatistics &&
|
||||
meta.statistic_id !== value &&
|
||||
excludeStatistics.includes(meta.statistic_id)
|
||||
) {
|
||||
return;
|
||||
@ -258,7 +260,8 @@ export class HaStatisticPicker extends LitElement {
|
||||
this.includeUnitClass,
|
||||
this.includeDeviceClass,
|
||||
this.entitiesOnly,
|
||||
this.excludeStatistics
|
||||
this.excludeStatistics,
|
||||
this.value
|
||||
);
|
||||
} else {
|
||||
this.updateComplete.then(() => {
|
||||
@ -268,7 +271,8 @@ export class HaStatisticPicker extends LitElement {
|
||||
this.includeUnitClass,
|
||||
this.includeDeviceClass,
|
||||
this.entitiesOnly,
|
||||
this.excludeStatistics
|
||||
this.excludeStatistics,
|
||||
this.value
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { repeat } from "lit/directives/repeat";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import type { ValueChangedEvent, HomeAssistant } from "../../types";
|
||||
import "./ha-statistic-picker";
|
||||
@ -81,7 +82,9 @@ class HaStatisticsPicker extends LitElement {
|
||||
: this.statisticTypes;
|
||||
|
||||
return html`
|
||||
${this._currentStatistics.map(
|
||||
${repeat(
|
||||
this._currentStatistics,
|
||||
(statisticId) => statisticId,
|
||||
(statisticId) => html`
|
||||
<div>
|
||||
<ha-statistic-picker
|
||||
@ -94,6 +97,7 @@ class HaStatisticsPicker extends LitElement {
|
||||
.statisticTypes=${includeStatisticTypesCurrent}
|
||||
.statisticIds=${this.statisticIds}
|
||||
.label=${this.pickedStatisticLabel}
|
||||
.excludeStatistics=${this.value}
|
||||
.allowCustomEntity=${this.allowCustomEntity}
|
||||
@value-changed=${this._statisticChanged}
|
||||
></ha-statistic-picker>
|
||||
@ -110,6 +114,7 @@ class HaStatisticsPicker extends LitElement {
|
||||
.statisticTypes=${this.statisticTypes}
|
||||
.statisticIds=${this.statisticIds}
|
||||
.label=${this.pickStatisticLabel}
|
||||
.excludeStatistics=${this.value}
|
||||
.allowCustomEntity=${this.allowCustomEntity}
|
||||
@value-changed=${this._addStatistic}
|
||||
></ha-statistic-picker>
|
||||
|
Loading…
x
Reference in New Issue
Block a user