mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +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[],
|
includeUnitClass?: string | string[],
|
||||||
includeDeviceClass?: string | string[],
|
includeDeviceClass?: string | string[],
|
||||||
entitiesOnly?: boolean,
|
entitiesOnly?: boolean,
|
||||||
excludeStatistics?: string[]
|
excludeStatistics?: string[],
|
||||||
|
value?: string
|
||||||
): StatisticItem[] => {
|
): StatisticItem[] => {
|
||||||
if (!statisticIds.length) {
|
if (!statisticIds.length) {
|
||||||
return [
|
return [
|
||||||
@ -176,6 +177,7 @@ export class HaStatisticPicker extends LitElement {
|
|||||||
statisticIds.forEach((meta) => {
|
statisticIds.forEach((meta) => {
|
||||||
if (
|
if (
|
||||||
excludeStatistics &&
|
excludeStatistics &&
|
||||||
|
meta.statistic_id !== value &&
|
||||||
excludeStatistics.includes(meta.statistic_id)
|
excludeStatistics.includes(meta.statistic_id)
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
@ -258,7 +260,8 @@ export class HaStatisticPicker extends LitElement {
|
|||||||
this.includeUnitClass,
|
this.includeUnitClass,
|
||||||
this.includeDeviceClass,
|
this.includeDeviceClass,
|
||||||
this.entitiesOnly,
|
this.entitiesOnly,
|
||||||
this.excludeStatistics
|
this.excludeStatistics,
|
||||||
|
this.value
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.updateComplete.then(() => {
|
this.updateComplete.then(() => {
|
||||||
@ -268,7 +271,8 @@ export class HaStatisticPicker extends LitElement {
|
|||||||
this.includeUnitClass,
|
this.includeUnitClass,
|
||||||
this.includeDeviceClass,
|
this.includeDeviceClass,
|
||||||
this.entitiesOnly,
|
this.entitiesOnly,
|
||||||
this.excludeStatistics
|
this.excludeStatistics,
|
||||||
|
this.value
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
|
import { repeat } from "lit/directives/repeat";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import type { ValueChangedEvent, HomeAssistant } from "../../types";
|
import type { ValueChangedEvent, HomeAssistant } from "../../types";
|
||||||
import "./ha-statistic-picker";
|
import "./ha-statistic-picker";
|
||||||
@ -81,7 +82,9 @@ class HaStatisticsPicker extends LitElement {
|
|||||||
: this.statisticTypes;
|
: this.statisticTypes;
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
${this._currentStatistics.map(
|
${repeat(
|
||||||
|
this._currentStatistics,
|
||||||
|
(statisticId) => statisticId,
|
||||||
(statisticId) => html`
|
(statisticId) => html`
|
||||||
<div>
|
<div>
|
||||||
<ha-statistic-picker
|
<ha-statistic-picker
|
||||||
@ -94,6 +97,7 @@ class HaStatisticsPicker extends LitElement {
|
|||||||
.statisticTypes=${includeStatisticTypesCurrent}
|
.statisticTypes=${includeStatisticTypesCurrent}
|
||||||
.statisticIds=${this.statisticIds}
|
.statisticIds=${this.statisticIds}
|
||||||
.label=${this.pickedStatisticLabel}
|
.label=${this.pickedStatisticLabel}
|
||||||
|
.excludeStatistics=${this.value}
|
||||||
.allowCustomEntity=${this.allowCustomEntity}
|
.allowCustomEntity=${this.allowCustomEntity}
|
||||||
@value-changed=${this._statisticChanged}
|
@value-changed=${this._statisticChanged}
|
||||||
></ha-statistic-picker>
|
></ha-statistic-picker>
|
||||||
@ -110,6 +114,7 @@ class HaStatisticsPicker extends LitElement {
|
|||||||
.statisticTypes=${this.statisticTypes}
|
.statisticTypes=${this.statisticTypes}
|
||||||
.statisticIds=${this.statisticIds}
|
.statisticIds=${this.statisticIds}
|
||||||
.label=${this.pickStatisticLabel}
|
.label=${this.pickStatisticLabel}
|
||||||
|
.excludeStatistics=${this.value}
|
||||||
.allowCustomEntity=${this.allowCustomEntity}
|
.allowCustomEntity=${this.allowCustomEntity}
|
||||||
@value-changed=${this._addStatistic}
|
@value-changed=${this._addStatistic}
|
||||||
></ha-statistic-picker>
|
></ha-statistic-picker>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user