[271] Umbau-Panel im Dock: Zeichen-Status, Umbaufilter mit Vorschau, Status der Auswahl, Etappen; schmale Selektoren beheben 45 Renders je Wand-Änderung
check / check (push) Has been cancelled
check / licenses (push) Has been cancelled
check / e2e (push) Has been cancelled
macos / native (push) Has been cancelled

This commit is contained in:
Claude committed 2026-11-17 12:38:02 +00:00
1 parent 1a31bc9aad
commit 84e0fc0528
19 files changed
+984 -56

No files matched your search

+47 -1
View File
@@ -4,7 +4,10 @@
import { describe, expect, it } from "vitest";
import { applyOps } from "../core/ops";
import { documentFor } from "../core/document";
import { commonRenovation, renovationFilterList, renovationForNew, setPhasesOps, setRenovationOps } from "./renovation";
import {
commonRenovation, idsByRenovationStatus, phaseUsage, renovationCounts, renovationFilterList, renovationFilterShows, renovationForNew, renovationStyleOf, RENOVATION_STATUSES,
setPhasesOps, setRenovationOps,
} from "./renovation";
import { buildUmbauSampleProject } from "./sampleProjectUmbau";
import { sampleProject } from "./sampleProject";
import { generatePlan } from "../plan/generatePlan";
@@ -74,4 +77,47 @@ describe("[271] Umbau", () => {
// Vorgabe Bestand: ohne Feld.
expect(added(req)[0]).not.toHaveProperty("renovation");
});
// ── Panel „Umbau“ ──
it("Panel: Vorschau je Filter stimmt mit dem Grundriss des Kerns überein (Override = Farbe da, Hide/Show = keine)", () => {
const p = buildUmbauSampleProject();
const colour = { existing: "#a6a6a6", demolish: "#ffd800", new: "#e3001b" } as const;
for (const f of renovationFilterList(p)) {
const shows = renovationFilterShows(p, f.id)!;
const got = fills(p, f.id);
for (const st of RENOVATION_STATUSES) {
expect(renovationStyleOf(p, st).fill).toBe(colour[st]);
expect(got.includes(colour[st]), `${f.id}/${st}`).toBe(shows[st] === "override");
}
}
expect(renovationFilterShows(p, "gibtsnicht")).toBeNull();
const own = { ...p, renovation: { ...p.renovation, filters: [{ id: "x", name: "X", existing: "hide" as const, demolish: "show" as const, new: "override" as const }], styles: { new: { fill: "#00ff00" } } } };
expect(renovationFilterShows(own, "x")).toEqual({ existing: "hide", demolish: "show", new: "override" });
expect(renovationStyleOf(own, "new").fill).toBe("#00ff00");
expect(renovationStyleOf(own, "new").dashed).toBe(false);
});
it("Panel: Auswahl nach Status (Öffnung folgt der Wand), Geschoss- und Etappenfilter, Zählung", () => {
const p = buildUmbauSampleProject();
const dem = idsByRenovationStatus(p, "demolish");
expect(dem.walls).toContain("W9");
expect(dem.openings).toContain("O2");
// Öffnung ohne eigenen Status: der Status ihrer Wand.
const o = p.openings!.find((x) => !x.renovation)!;
const host = p.walls.find((w) => w.id === o.hostWallId)!;
expect(idsByRenovationStatus(p, host.renovation?.status ?? "existing").openings).toContain(o.id);
expect(idsByRenovationStatus(p, "demolish", { floorId: "og-gibts-nicht" })).toEqual({});
expect(idsByRenovationStatus(p, "demolish", { phase: "etappe-1" }).walls).toContain("W9");
expect(idsByRenovationStatus(p, "demolish", { phase: "etappe-2" }).walls ?? []).not.toContain("W9");
const n = renovationCounts(p);
expect(n.demolish).toBeGreaterThan(0);
expect(n.new).toBeGreaterThan(0);
expect(n.existing + n.demolish + n.new).toBe(Object.values(idsByRenovationStatus(p, "existing")).flat().length + n.demolish + n.new);
});
it("Panel: Etappen-Nutzung für die Rückfrage beim Löschen", () => {
const p = buildUmbauSampleProject();
expect(phaseUsage(p, "etappe-1")).toBeGreaterThan(0);
expect(phaseUsage(p, "nix")).toBe(0);
});
});
+81 -1
View File
@@ -4,7 +4,7 @@
import type { CoreOp } from "../core/ops";
import { documentFor } from "../core/document";
import { patchItems, setField } from "../core/opsBuild";
import type { Project, Renovation, RenovationPhase, RenovationStatus } from "./types";
import type { Project, Renovation, RenovationPhase, RenovationShow, RenovationStatus } from "./types";
/** Eingebaute Umbaufilter (Ids; Namen über `t("renovation.filter.<id>")`). */
export const BUILTIN_RENOVATION_FILTERS = ["bestand", "abbruch", "neubau", "umbauplan", "endzustand"] as const;
@@ -145,3 +145,83 @@ export function newPhaseId(project: Project): string {
while (used.has(`etappe-${i}`)) i++;
return `etappe-${i}`;
}
// ── Panel „Umbau“ (Dock): Filter-Vorschau, Auswahl nach Status ─────────────────────────────────────────────
/** Eingebaute Filter: Darstellung je Status (Spiegel von `renovation::builtin` im Kern; `renovation.test.ts` prüft ihn gegen den Plan). */
const BUILTIN_FILTER_SHOWS: Record<string, Record<RenovationStatus, RenovationShow>> = {
bestand: { existing: "show", demolish: "show", new: "hide" },
abbruch: { existing: "show", demolish: "override", new: "hide" },
neubau: { existing: "show", demolish: "hide", new: "override" },
umbauplan: { existing: "override", demolish: "override", new: "override" },
endzustand: { existing: "show", demolish: "hide", new: "show" },
};
/** Darstellung je Status im Filter `id` (eingebaut oder eigen); `null` bei unbekanntem Filter. */
export function renovationFilterShows(project: Project, id: string): Record<RenovationStatus, RenovationShow> | null {
const own = project.renovation?.filters?.find((f) => f.id === id);
if (own) return { existing: own.existing, demolish: own.demolish, new: own.new };
return BUILTIN_FILTER_SHOWS[id] ?? null;
}
/** Umbau-Farbe eines Status (Projekt-Vorgabe über SIA-400-Vorgabe). */
export function renovationStyleOf(project: Project, status: RenovationStatus): { fill: string; line?: string; dashed: boolean } {
const d = DEFAULT_RENOVATION_STYLES[status];
const o = project.renovation?.styles?.[status];
return { fill: o?.fill ?? d.fill, line: o?.line ?? d.line, dashed: o?.dashed ?? d.dashed };
}
/** Auswahl-Art je Liste (`extrudedSolids` heissen in der Auswahl `solids`). */
const SELECTION_KEY: Record<RenovationCollection, string> = {
walls: "walls",
openings: "openings",
ceilings: "ceilings",
roofs: "roofs",
stairs: "stairs",
columns: "columns",
extrudedSolids: "solids",
rooms: "rooms",
};
/**
* Ids aller Elemente mit Status `status` (Öffnung ohne eigenen Status: der der Wand), je Auswahl-Art.
* `floorId`: nur dieses Geschoss (Öffnungen über ihre Wand); `phase`: nur diese Etappe (`""` = ohne Etappe).
*/
export function idsByRenovationStatus(
project: Project,
status: RenovationStatus,
opts: { floorId?: string | null; phase?: string } = {},
): Record<string, string[]> {
const out: Record<string, string[]> = {};
const wallOf = new Map(project.walls.map((w) => [w.id, w]));
for (const c of RENOVATION_COLLECTIONS) {
const ids: string[] = [];
for (const e of (project[c] ?? []) as { id: string; floorId?: string; hostWallId?: string; renovation?: Renovation }[]) {
const wall = c === "openings" && e.hostWallId ? wallOf.get(e.hostWallId) : undefined;
const floor = e.floorId ?? wall?.floorId;
if (opts.floorId && floor && floor !== opts.floorId) continue;
const r = e.renovation ?? wall?.renovation;
if (renovationStatus(r) !== status) continue;
if (opts.phase !== undefined && (r?.phase ?? "") !== opts.phase) continue;
ids.push(e.id);
}
if (ids.length) out[SELECTION_KEY[c]] = ids;
}
return out;
}
/** Zahl der Elemente je Status (Öffnungen ohne eigenen Status zählen mit dem der Wand). */
export function renovationCounts(project: Project, floorId?: string | null): Record<RenovationStatus, number> {
const n: Record<RenovationStatus, number> = { existing: 0, demolish: 0, new: 0 };
for (const s of RENOVATION_STATUSES) n[s] = Object.values(idsByRenovationStatus(project, s, { floorId })).reduce((a, v) => a + v.length, 0);
return n;
}
/** Zahl der Elemente, die Etappe `phaseId` tragen (für die Rückfrage beim Löschen). */
export function phaseUsage(project: Project, phaseId: string): number {
let n = 0;
for (const c of RENOVATION_COLLECTIONS) {
for (const e of (project[c] ?? []) as { renovation?: Renovation }[]) if (e.renovation?.phase === phaseId) n++;
}
return n;
}