feat: add location and branch topology with scoped navigation
This commit is contained in:
1 parent
4a8da8ad0c
commit
bffc4d0acc
30 files changed
+3172
-2491
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { floorSelection, normalizeTopology, topologyFloors } from "../topology.ts";
|
||||
// 2D editor: floors, rooms (rectangles and free shapes), snapping, undo, background template.
|
||||
|
||||
import { html, LitElement, nothing, svg, type PropertyValues, type TemplateResult } from "lit";
|
||||
@@ -1138,6 +1139,7 @@ export class NfEditor extends LitElement {
|
||||
/** Replace the document; `base` (the state before the change) goes into the undo history. */
|
||||
private setDoc(next: Building, base: Building | null = this._doc): void {
|
||||
if (base) this.history.record(base);
|
||||
if(next.topology)normalizeTopology(next);
|
||||
this._doc = next;
|
||||
this.syncHistoryButtons();
|
||||
this.dispatchEvent(new CustomEvent("building-changed", { detail: { building: next }, bubbles: true, composed: true }));
|
||||
@@ -2321,8 +2323,8 @@ export class NfEditor extends LitElement {
|
||||
|
||||
// ------------------------------------------------------------------ floors and rooms
|
||||
|
||||
private addFloor(from: HassFloor | null = null): void {
|
||||
const floor = newFloorFor(this._doc, from, { first: this.t("default_floor"), next: (n) => this.t("new_floor", { n }) });
|
||||
private addFloor(from: HassFloor | null = null, parent?: string): void {
|
||||
const floor = newFloorFor(this._doc, from, { first: this.t("default_floor"), next: (n) => this.t("new_floor", { n }) }, parent ?? this.floor?.building_id);
|
||||
const next = structuredClone(this._doc);
|
||||
next.floors = floorsWith(next.floors, floor);
|
||||
this.setDoc(next);
|
||||
@@ -2376,6 +2378,7 @@ export class NfEditor extends LitElement {
|
||||
},
|
||||
print: () => this.printPlan(),
|
||||
addFloor: (from) => this.addFloor(from),
|
||||
addFloorIn: (id) => this.addFloor(null,id),
|
||||
moveFloor: (direction) => this.moveFloor(direction),
|
||||
deleteFloor: () => this.deleteFloor(),
|
||||
duplicateFloor: (options) => this.duplicateFloor(options),
|
||||
@@ -2621,7 +2624,7 @@ export class NfEditor extends LitElement {
|
||||
}
|
||||
|
||||
private shiftScope(): Scope {
|
||||
return { floorId: this._floorId, allFloors: this.side.shiftAll };
|
||||
return { floorId: this._floorId, allFloors: this.side.shiftAll, ...(this._doc.topology&&this._floorId?{floorIds:topologyFloors(this._doc,floorSelection(this._doc,this._floorId),true).map((f)=>f.id)}:{}) };
|
||||
}
|
||||
|
||||
/** Moves everything on the floor (or on every floor) by the typed distance. */
|
||||
|
||||
Reference in new issue
Block a user