fix: separate hierarchy management from selected building editing

This commit is contained in:
jhartworks committed 2026-11-19 09:46:31 +01:00
1 parent bffc4d0acc
commit 382d6e04f2
18 files changed
+2103 -1648

No files matched your search

+8 -2
View File
@@ -16,6 +16,7 @@ import { countsAsLiving, roomArea } from "../../../geometry/living-area.ts";
import { roomSpeaker } from "../../../live/announce.ts";
import { isSymcon } from "../../../entities/symcon-values.ts";
import { renderSymconRoomMeters } from "../symcon-fields.ts";
import { floorTopologyPath } from "../../../topology.ts";
/** What the room form makes the editor do, and the parts of it that the editor still draws itself. */
export interface RoomActions {
@@ -46,7 +47,10 @@ export function renderRoomList(host: EditorHost, floor: Floor, actions: Pick<Roo
return html`<section>
<h3>${host.t("rooms")}</h3>
<div class="nf-room-list">
${floor.rooms.map(
${isSymcon(host.hass)?[...new Set(floor.rooms.map((r)=>r.area_id??""))].map((id)=>html`<div class="nf-room-area-group" data-area-id=${id}>
<h4>${id?areaLeafName(host.hass,id)||host.hass?.areas?.[id]?.name||"Verknüpfter Bereich":"Ohne verknüpften Bereich"}</h4>
${floor.rooms.filter((r)=>(r.area_id??"")===id).map((room)=>html`<button class="nf-row" @click=${()=>actions.select(room.id)}><span>${room.name}</span><span class="nf-muted">${formatArea(host.hass,polygonArea(room.points))}</span></button>`)}
</div>`):floor.rooms.map(
(room) => html`<button class="nf-row" @click=${() => actions.select(room.id)}>
<span>${room.name}</span><span class="nf-muted">${formatArea(host.hass, polygonArea(room.points))}</span>
</button>`,
@@ -159,9 +163,11 @@ export function renderRoomForm(host: EditorHost, state: SideState, room: Room, a
html`<button class="nf-btn" @click=${() => actions.applyPackage(pkg)}><b>${t(`pkg_${pkg}` as I18nKey)}</b><span>${t(`pkg_${pkg}_desc` as I18nKey)}</span></button>`;
return html`<section>
<div class="nf-h3row"><h3>${t("room")}</h3>${actions.lockButton}</div>
${host.doc.topology&&host.floor?html`<div class="nf-room-context" title=${floorTopologyPath(host.doc,host.floor)}>${floorTopologyPath(host.doc,host.floor)}</div>`:nothing}
<div class="nf-form">
${textField(host, t("room_name"), room.name, (v) => actions.patch({ name: v }), { wide: true })}
${selectField(host, t("area"), room.area_id ?? "", areaChoices, (id) => actions.setArea(id), { wide: true })}
${selectField(host, isSymcon(host.hass)?"Bereich (Symcon)":t("area"), room.area_id ?? "", areaChoices, (id) => actions.setArea(id), { wide: true })}
${isSymcon(host.hass)?hint("Der Raum gehört zur oben gewählten Etage und damit zu deren Gebäude. Hier verknüpfst du seine Symcon-Bereichskategorie. Mehrere Räume derselben Etage können dieselbe Kategorie verwenden. Der Objektbaum und der Raumname werden dadurch nicht verändert.","nf-wide"):nothing}
${isSymcon(host.hass) && room.area_id ? html`<button type="button" class="nf-btn nf-wide nf-take-area-name" ?disabled=${!host.admin || !areaLeafName(host.hass, room.area_id)} @click=${() => actions.patch({ name: areaLeafName(host.hass, room.area_id!) })}>Bereichsnamen übernehmen</button>` : nothing}
${(room.sub_areas ?? []).map((a) => html`<span class="nf-chip nf-wide">${host.hass?.areas?.[a]?.name ?? a} <button class="nf-btn nf-field-btn" ?disabled=${!host.admin} title=${t("delete")} @click=${() => actions.patch({ sub_areas: (room.sub_areas ?? []).filter((x) => x !== a).length ? (room.sub_areas ?? []).filter((x) => x !== a) : null })}>✕</button></span>`)}
${room.area_id