mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 17:26:42 +00:00
Feedbacks
This commit is contained in:
parent
b890ef2b01
commit
8617d7e77a
@ -44,32 +44,7 @@ export class HaAreasFloorsDisplayEditor extends LitElement {
|
|||||||
public showNavigationButton = false;
|
public showNavigationButton = false;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
const compare = areaCompare(this.hass.areas);
|
const groupedItems = this._groupedItems(this.hass.areas, this.hass.floors);
|
||||||
|
|
||||||
const areas = Object.values(this.hass.areas).sort((areaA, areaB) =>
|
|
||||||
compare(areaA.area_id, areaB.area_id)
|
|
||||||
);
|
|
||||||
|
|
||||||
const groupedItems: Record<string, DisplayItem[]> = areas.reduce(
|
|
||||||
(acc, area) => {
|
|
||||||
const { floor } = getAreaContext(area, this.hass!);
|
|
||||||
const floorId = floor?.floor_id ?? UNASSIGNED_FLOOR;
|
|
||||||
|
|
||||||
if (!acc[floorId]) {
|
|
||||||
acc[floorId] = [];
|
|
||||||
}
|
|
||||||
acc[floorId].push({
|
|
||||||
value: area.area_id,
|
|
||||||
label: area.name,
|
|
||||||
icon: area.icon ?? undefined,
|
|
||||||
iconPath: mdiTextureBox,
|
|
||||||
description: floor?.name,
|
|
||||||
});
|
|
||||||
|
|
||||||
return acc;
|
|
||||||
},
|
|
||||||
{} as Record<string, DisplayItem[]>
|
|
||||||
);
|
|
||||||
|
|
||||||
const filteredFloors = this._sortedFloors(this.hass.floors).filter(
|
const filteredFloors = this._sortedFloors(this.hass.floors).filter(
|
||||||
(floor) =>
|
(floor) =>
|
||||||
@ -113,6 +88,41 @@ export class HaAreasFloorsDisplayEditor extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _groupedItems = memoizeOne(
|
||||||
|
(
|
||||||
|
hassAreas: HomeAssistant["areas"],
|
||||||
|
// update items if floors change
|
||||||
|
_hassFloors: HomeAssistant["floors"]
|
||||||
|
): Record<string, DisplayItem[]> => {
|
||||||
|
const compare = areaCompare(hassAreas);
|
||||||
|
|
||||||
|
const areas = Object.values(hassAreas).sort((areaA, areaB) =>
|
||||||
|
compare(areaA.area_id, areaB.area_id)
|
||||||
|
);
|
||||||
|
const groupedItems: Record<string, DisplayItem[]> = areas.reduce(
|
||||||
|
(acc, area) => {
|
||||||
|
const { floor } = getAreaContext(area, this.hass!);
|
||||||
|
const floorId = floor?.floor_id ?? UNASSIGNED_FLOOR;
|
||||||
|
|
||||||
|
if (!acc[floorId]) {
|
||||||
|
acc[floorId] = [];
|
||||||
|
}
|
||||||
|
acc[floorId].push({
|
||||||
|
value: area.area_id,
|
||||||
|
label: area.name,
|
||||||
|
icon: area.icon ?? undefined,
|
||||||
|
iconPath: mdiTextureBox,
|
||||||
|
description: floor?.name,
|
||||||
|
});
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
},
|
||||||
|
{} as Record<string, DisplayItem[]>
|
||||||
|
);
|
||||||
|
return groupedItems;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
private _sortedFloors = memoizeOne(
|
private _sortedFloors = memoizeOne(
|
||||||
(hassFloors: HomeAssistant["floors"]): FloorRegistryEntry[] => {
|
(hassFloors: HomeAssistant["floors"]): FloorRegistryEntry[] => {
|
||||||
const floors = Object.values(hassFloors).sort((floorA, floorB) => {
|
const floors = Object.values(hassFloors).sort((floorA, floorB) => {
|
||||||
@ -182,28 +192,24 @@ export class HaAreasFloorsDisplayEditor extends LitElement {
|
|||||||
fireEvent(this, "value-changed", { value: newValue });
|
fireEvent(this, "value-changed", { value: newValue });
|
||||||
}
|
}
|
||||||
|
|
||||||
static get styles() {
|
static styles = css`
|
||||||
return [
|
.floor .header p {
|
||||||
css`
|
margin: 0;
|
||||||
.floor .header p {
|
overflow: hidden;
|
||||||
margin: 0;
|
text-overflow: ellipsis;
|
||||||
overflow: hidden;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
overflow: hidden;
|
||||||
white-space: nowrap;
|
flex: 1:
|
||||||
overflow: hidden;
|
}
|
||||||
flex: 1:
|
.floor .header {
|
||||||
}
|
margin: 16px 0 8px 0;
|
||||||
.floor .header {
|
padding: 0 8px;
|
||||||
margin: 16px 0 8px 0;
|
display: flex;
|
||||||
padding: 0 8px;
|
flex-direction: row;
|
||||||
display: flex;
|
align-items: center;
|
||||||
flex-direction: row;
|
gap: 8px;
|
||||||
align-items: center;
|
}
|
||||||
gap: 8px;
|
`;
|
||||||
}
|
|
||||||
`,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user