pull/25627/merge
Aidan Timson 2025-06-16 10:09:07 +02:00 committed by GitHub
commit 8920e0cb03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 41 additions and 1 deletions

View File

@ -23,6 +23,7 @@ export interface AreasDashboardStrategyConfig {
order?: string[]; order?: string[];
}; };
areas_options?: Record<string, AreaOptions>; areas_options?: Record<string, AreaOptions>;
show_icons?: boolean;
} }
@customElement("areas-dashboard-strategy") @customElement("areas-dashboard-strategy")
@ -65,6 +66,7 @@ export class AreasDashboardStrategy extends ReactiveElement {
return { return {
title: area.name, title: area.name,
icon: config.show_icons && area.icon ? area.icon : undefined,
path: path, path: path,
strategy: { strategy: {
type: "area", type: "area",

View File

@ -22,6 +22,19 @@ import {
type AreaRegistryEntry, type AreaRegistryEntry,
} from "../../../../../data/area_registry"; } from "../../../../../data/area_registry";
import { buttonLinkStyle } from "../../../../../resources/styles"; import { buttonLinkStyle } from "../../../../../resources/styles";
import type {
HaFormSchema,
SchemaUnion,
} from "../../../../../components/ha-form/types";
const SCHEMA = [
{
name: "show_icons",
selector: {
boolean: {},
},
},
] as const satisfies readonly HaFormSchema[];
@customElement("hui-areas-dashboard-strategy-editor") @customElement("hui-areas-dashboard-strategy-editor")
export class HuiAreasDashboardStrategyEditor export class HuiAreasDashboardStrategyEditor
@ -133,6 +146,13 @@ export class HuiAreasDashboardStrategyEditor
show-navigation-button show-navigation-button
@item-display-navigate-clicked=${this._handleAreaNavigate} @item-display-navigate-clicked=${this._handleAreaNavigate}
></ha-areas-display-editor> ></ha-areas-display-editor>
<ha-form
.hass=${this.hass}
.data=${this._config}
.schema=${SCHEMA}
.computeLabel=${this._computeFormLabelCallback}
@value-changed=${this._formValueChanged}
></ha-form>
`; `;
} }
@ -186,11 +206,28 @@ export class HuiAreasDashboardStrategyEditor
}, },
}, },
}, },
show_icons: this._config!.show_icons,
}; };
fireEvent(this, "config-changed", { config: newConfig }); fireEvent(this, "config-changed", { config: newConfig });
} }
private _formValueChanged(ev: CustomEvent): void {
const data = ev.detail.value;
fireEvent(this, "config-changed", { config: data });
}
private _computeFormLabelCallback = (schema: SchemaUnion<typeof SCHEMA>) => {
switch (schema.name) {
case "show_icons":
return this.hass?.localize(
`ui.panel.lovelace.editor.strategy.areas.show_icons`
);
default:
return "";
}
};
static get styles() { static get styles() {
return [ return [
buttonLinkStyle, buttonLinkStyle,

View File

@ -7846,7 +7846,8 @@
}, },
"areas": { "areas": {
"areas_display": "Areas to display", "areas_display": "Areas to display",
"no_entities": "No entities in this group, the section will not be displayed" "no_entities": "No entities in this group, the section will not be displayed",
"show_icons": "Display area icons"
} }
}, },
"view": { "view": {