[274] Umbau je Schicht: Sanierung auch für Decken und Dächer, Status je Schicht im IFC
Gleicher Kern-Code wie bei den Wänden (Trait build_up::Layered für Wand-, Decken- und Dachtyp; type_pair_in, look_core; ceiling_look/roof_look in Resolved::slabs, Umstellen in swap_build_ups). CeilingType/RoofType mit renovationTarget/Side/Old/New; Bezugsseite Decke unten/oben, Dach: Dachhaut hebt sich. Schnitt je Schicht, 3D je Deckenschicht, Grundriss-Linien/Ansicht/Axo in der Farbe der obersten Schicht. Objekt-Info und Umbau-Panel „Sanierung“ für Decken und Dächer; Abfragen mit kind. IFC: Dossier_Umbau.SchichtenBestand/SchichtenSanierung. Beispiel :umbau: Decke C1 und Dach RF1 saniert (Schnitt C). Bild doc/review-274/07-decke-dach.png.
This commit is contained in:
20 files changed
+955
-180
No files matched your search
@@ -136,8 +136,10 @@ export type { RenovationStyleView, RenovationStyleSet, ResolvedRenovationStyles
|
||||
export {
|
||||
wallBuildUp, buildUpKey, parseBuildUpKey, setBuildUpOps, commonBuildUp, renovateAllOfTypeOps, createRenovationTypeOps, setTypePairOps,
|
||||
renovationPair, renovationPairs,
|
||||
renovationTypes, hostTypeId, RENOVATION_HOSTS,
|
||||
} from "../model/renovation";
|
||||
export type { RenovationBuildUp, RenovationPair, RenovationPairLayer, RenovationStripPiece, RenovationPairsInfo } from "../model/renovation";
|
||||
export type { RenovationHost, LayeredType } from "../model/renovation";
|
||||
export { buildUmbauSampleProject } from "../model/sampleProjectUmbau";
|
||||
// [272] Varianten: Sätze, Kombinationen, Zuweisen/Kopieren/Übernehmen (Regeln im Kern `design_options.rs`, Sichtbarkeit `renovation.rs`)
|
||||
export {
|
||||
|
||||
+12
-1
@@ -4809,7 +4809,7 @@ export const de = {
|
||||
"renovation.strip.result": "Ergebnis",
|
||||
"renovation.panel.sanierung.title": "Sanierung",
|
||||
"renovation.panel.sanierung.count": "Sanierte Bauteile: {n}",
|
||||
"renovation.panel.sanierung.empty": "Noch kein Sanierungstyp. Wandtyp wählen und „Sanierungstyp anlegen …“.",
|
||||
"renovation.panel.sanierung.empty": "Noch kein Sanierungstyp. Wand-, Decken- oder Dachtyp wählen und „Sanierungstyp anlegen …“.",
|
||||
"renovation.panel.sanierung.walls": "{r} von {n} Wänden saniert",
|
||||
"renovation.panel.sanierung.renovateAll": "Alle Wände vom Typ sanieren",
|
||||
"renovation.panel.sanierung.create": "Sanierungstyp anlegen …",
|
||||
@@ -4825,6 +4825,17 @@ export const de = {
|
||||
"renovation.panel.sanierung.reset": "Automatisch zuordnen",
|
||||
"renovation.panel.sanierung.remove": "Sanierungstyp entfernen",
|
||||
"renovation.panel.sanierung.editLayers": "Schichten in den Ressourcen …",
|
||||
"renovation.panel.sanierung.host.wall": "Wände",
|
||||
"renovation.panel.sanierung.host.ceiling": "Decken",
|
||||
"renovation.panel.sanierung.host.roof": "Dächer",
|
||||
"renovation.panel.sanierung.ceilings": "{r} von {n} Decken saniert",
|
||||
"renovation.panel.sanierung.roofs": "{r} von {n} Dächern saniert",
|
||||
"renovation.panel.sanierung.renovateAll.ceiling": "Alle Decken vom Typ sanieren",
|
||||
"renovation.panel.sanierung.renovateAll.roof": "Alle Dächer vom Typ sanieren",
|
||||
"renovation.panel.sanierung.side.ceiling.inside": "unten (Rohdecke bleibt)",
|
||||
"renovation.panel.sanierung.side.ceiling.outside": "oben (Oberkante bleibt)",
|
||||
"renovation.panel.sanierung.side.roof.inside": "innen (Tragwerk bleibt)",
|
||||
"renovation.panel.sanierung.side.roof.outside": "aussen (Dachhaut bleibt)",
|
||||
"renovation.fate.auto": "automatisch",
|
||||
"renovation.fate.kept": "Bestand",
|
||||
"renovation.fate.demolish": "Abbruch",
|
||||
|
||||
+12
-1
@@ -4795,7 +4795,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"renovation.strip.result": "Result",
|
||||
"renovation.panel.sanierung.title": "Refurbishment",
|
||||
"renovation.panel.sanierung.count": "Refurbished elements: {n}",
|
||||
"renovation.panel.sanierung.empty": "No refurbishment type yet. Pick a wall type and “Create refurbishment type …”.",
|
||||
"renovation.panel.sanierung.empty": "No refurbishment type yet. Pick a wall, slab or roof type and “Create refurbishment type …”.",
|
||||
"renovation.panel.sanierung.walls": "{r} of {n} walls refurbished",
|
||||
"renovation.panel.sanierung.renovateAll": "Refurbish all walls of this type",
|
||||
"renovation.panel.sanierung.create": "Create refurbishment type …",
|
||||
@@ -4811,6 +4811,17 @@ export const en: Record<TranslationKey, string> = {
|
||||
"renovation.panel.sanierung.reset": "Map automatically",
|
||||
"renovation.panel.sanierung.remove": "Remove refurbishment type",
|
||||
"renovation.panel.sanierung.editLayers": "Layers in the resources …",
|
||||
"renovation.panel.sanierung.host.wall": "Walls",
|
||||
"renovation.panel.sanierung.host.ceiling": "Slabs",
|
||||
"renovation.panel.sanierung.host.roof": "Roofs",
|
||||
"renovation.panel.sanierung.ceilings": "{r} of {n} slabs refurbished",
|
||||
"renovation.panel.sanierung.roofs": "{r} of {n} roofs refurbished",
|
||||
"renovation.panel.sanierung.renovateAll.ceiling": "Refurbish all slabs of this type",
|
||||
"renovation.panel.sanierung.renovateAll.roof": "Refurbish all roofs of this type",
|
||||
"renovation.panel.sanierung.side.ceiling.inside": "bottom (structural slab stays)",
|
||||
"renovation.panel.sanierung.side.ceiling.outside": "top (top level stays)",
|
||||
"renovation.panel.sanierung.side.roof.inside": "inside (structure stays)",
|
||||
"renovation.panel.sanierung.side.roof.outside": "outside (roof skin stays)",
|
||||
"renovation.fate.auto": "automatic",
|
||||
"renovation.fate.kept": "Existing",
|
||||
"renovation.fate.demolish": "Demolish",
|
||||
|
||||
+63
-30
@@ -327,7 +327,7 @@ export function phaseUsage(project: Project, phaseId: string): number {
|
||||
/** Neuer Aufbau einer Wand: keiner, der Sanierungstyp ihres Wandtyps oder ein anderer Wandtyp (Ausnahme). */
|
||||
export type RenovationBuildUp = { kind: "none" } | { kind: "type" } | { kind: "other"; typeId: string };
|
||||
|
||||
/** Neuer Aufbau einer Wand aus ihren Umbau-Angaben. */
|
||||
/** Neuer Aufbau eines Bauteils (Wand, Decke, Dach) aus seinen Umbau-Angaben. */
|
||||
export function wallBuildUp(r: Renovation | undefined | null): RenovationBuildUp {
|
||||
if (r?.newTypeId) return { kind: "other", typeId: r.newTypeId };
|
||||
return r?.renovated ? { kind: "type" } : { kind: "none" };
|
||||
@@ -358,22 +358,52 @@ function withBuildUp(r: Renovation | undefined, b: RenovationBuildUp): Renovatio
|
||||
return plain ? undefined : base;
|
||||
}
|
||||
|
||||
/** Ops: neuer Aufbau für die Wände `ids` (ein Undo-Schritt); Status/Etappe bleiben. */
|
||||
export function setBuildUpOps(project: Project, ids: Iterable<string>, b: RenovationBuildUp): CoreOp[] {
|
||||
/** [274] Bauteilart einer Sanierung je Schicht: Wand, Decke oder Dach (je mit eigenem Typ-Katalog). */
|
||||
export type RenovationHost = "wall" | "ceiling" | "roof";
|
||||
export const RENOVATION_HOSTS: readonly RenovationHost[] = ["wall", "ceiling", "roof"];
|
||||
|
||||
/** Element-Liste, Typ-Liste und Typ-Feld je Bauteilart. */
|
||||
const HOST = {
|
||||
wall: { items: "walls", types: "wallTypes", typeKey: "wallTypeId" },
|
||||
ceiling: { items: "ceilings", types: "ceilingTypes", typeKey: "ceilingTypeId" },
|
||||
roof: { items: "roofs", types: "roofTypes", typeKey: "roofTypeId" },
|
||||
} as const;
|
||||
|
||||
/** Mehrschichtiger Typ mit Sanierungs-Angaben (Wand-, Decken- oder Dachtyp). */
|
||||
export type LayeredType = Pick<WallType, "id" | "name" | "layers" | "renovationTarget" | "renovationSide" | "renovationOld" | "renovationNew">;
|
||||
type HostItem = { id: string; renovation?: Renovation } & Record<string, unknown>;
|
||||
|
||||
/** Typen einer Bauteilart (Wandtypen, Deckentypen, Dachtypen). */
|
||||
export function renovationTypes(project: Project, host: RenovationHost = "wall"): readonly LayeredType[] {
|
||||
return ((project as unknown as Record<string, unknown>)[HOST[host].types] as LayeredType[] | undefined) ?? [];
|
||||
}
|
||||
|
||||
function hostItems(project: Project, host: RenovationHost): readonly HostItem[] {
|
||||
return ((project as unknown as Record<string, unknown>)[HOST[host].items] as HostItem[] | undefined) ?? [];
|
||||
}
|
||||
|
||||
/** Typ-Id eines Elements (Wand-, Decken-, Dachtyp; Decke/Dach ohne Typ: `undefined`). */
|
||||
export function hostTypeId(e: unknown, host: RenovationHost = "wall"): string | undefined {
|
||||
return ((e as Record<string, unknown>)[HOST[host].typeKey] as string | undefined) || undefined;
|
||||
}
|
||||
|
||||
/** Ops: neuer Aufbau für die Elemente `ids` der Bauteilart `host` (ein Undo-Schritt); Status/Etappe bleiben. */
|
||||
export function setBuildUpOps(project: Project, ids: Iterable<string>, b: RenovationBuildUp, host: RenovationHost = "wall"): CoreOp[] {
|
||||
const set = new Set(ids);
|
||||
return patchItems(project, "walls", set, (w) => {
|
||||
const fn = (w: HostItem): HostItem => {
|
||||
const next = withBuildUp(w.renovation, b);
|
||||
const { renovation: _drop, ...rest } = w;
|
||||
void _drop;
|
||||
return next ? { ...rest, renovation: next } : rest;
|
||||
});
|
||||
};
|
||||
return patchItems(project, HOST[host].items, set, fn as never);
|
||||
}
|
||||
|
||||
/** Gemeinsamer Aufbau-Schlüssel ({@link buildUpKey}) der Wände `ids`: `"mixed"` bei verschiedenen, `null` ohne Wände. */
|
||||
export function commonBuildUp(project: Project, ids: Iterable<string>): string | null {
|
||||
/** Gemeinsamer Aufbau-Schlüssel ({@link buildUpKey}) der Elemente `ids`: `"mixed"` bei verschiedenen, `null` ohne. */
|
||||
export function commonBuildUp(project: Project, ids: Iterable<string>, host: RenovationHost = "wall"): string | null {
|
||||
const set = new Set(ids);
|
||||
let out: string | null = null;
|
||||
for (const w of project.walls) {
|
||||
for (const w of hostItems(project, host)) {
|
||||
if (!set.has(w.id)) continue;
|
||||
const k = buildUpKey(wallBuildUp(w.renovation));
|
||||
if (out === null) out = k;
|
||||
@@ -382,30 +412,30 @@ export function commonBuildUp(project: Project, ids: Iterable<string>): string |
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Ops: alle Wände des Bestandstyps `typeId` sanieren (Sanierungstyp des Typs; ein Undo-Schritt). */
|
||||
export function renovateAllOfTypeOps(project: Project, typeId: string): CoreOp[] {
|
||||
const ids = project.walls.filter((w) => w.wallTypeId === typeId && renovationStatus(w.renovation) === "existing").map((w) => w.id);
|
||||
return setBuildUpOps(project, ids, { kind: "type" });
|
||||
/** Ops: alle Elemente des Bestandstyps `typeId` sanieren (Sanierungstyp des Typs; ein Undo-Schritt). */
|
||||
export function renovateAllOfTypeOps(project: Project, typeId: string, host: RenovationHost = "wall"): CoreOp[] {
|
||||
const ids = hostItems(project, host).filter((w) => hostTypeId(w, host) === typeId && renovationStatus(w.renovation) === "existing").map((w) => w.id);
|
||||
return setBuildUpOps(project, ids, { kind: "type" }, host);
|
||||
}
|
||||
|
||||
/** Nächste freie Wandtyp-Id mit Präfix. */
|
||||
function freeTypeId(project: Project, base: string): string {
|
||||
const used = new Set(project.wallTypes.map((t) => t.id));
|
||||
/** Nächste freie Typ-Id mit Präfix. */
|
||||
function freeTypeId(project: Project, base: string, host: RenovationHost): string {
|
||||
const used = new Set(renovationTypes(project, host).map((t) => t.id));
|
||||
let i = 1;
|
||||
while (used.has(`${base}-${i}`)) i++;
|
||||
return `${base}-${i}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ops: „Sanierungstyp anlegen …“ — Kopie des Bestandstyps `typeId` als neuer Wandtyp `name` (zum Anpassen der Schichten)
|
||||
* Ops: „Sanierungstyp anlegen …“ — Kopie des Bestandstyps `typeId` als neuer Typ `name` (zum Anpassen der Schichten)
|
||||
* und als Sanierungstyp des Bestandstyps eingetragen. Liefert die Ops und die neue Id.
|
||||
*/
|
||||
export function createRenovationTypeOps(project: Project, typeId: string, name: string): { ops: CoreOp[]; id: string } {
|
||||
const src = project.wallTypes.find((t) => t.id === typeId);
|
||||
export function createRenovationTypeOps(project: Project, typeId: string, name: string, host: RenovationHost = "wall"): { ops: CoreOp[]; id: string } {
|
||||
const src = renovationTypes(project, host).find((t) => t.id === typeId);
|
||||
if (!src) return { ops: [], id: "" };
|
||||
const id = freeTypeId(project, `${typeId}-saniert`);
|
||||
const copy: WallType = { id, name, layers: src.layers.map((l) => ({ ...l })) };
|
||||
return { ops: [...addItems("wallTypes", [copy]), ...setTypePairOps(project, typeId, { target: id, old: null, new: null })], id };
|
||||
const id = freeTypeId(project, `${typeId}-saniert`, host);
|
||||
const copy: LayeredType = { id, name, layers: src.layers.map((l) => ({ ...l })) };
|
||||
return { ops: [...addItems(HOST[host].types, [copy] as never), ...setTypePairOps(project, typeId, { target: id, old: null, new: null }, host)], id };
|
||||
}
|
||||
|
||||
/** Ops: Typ-Paar am Bestandstyp ändern (Sanierungstyp, Bezugsseite, manuelle Zuordnung; `null` entfernt). */
|
||||
@@ -413,10 +443,11 @@ export function setTypePairOps(
|
||||
project: Project,
|
||||
typeId: string,
|
||||
patch: { target?: string | null; side?: RenovationSide | null; old?: LayerRenovation[] | null; new?: LayerRenovation[] | null },
|
||||
host: RenovationHost = "wall",
|
||||
): CoreOp[] {
|
||||
return patchItem(project, "wallTypes", typeId, (t) => {
|
||||
const next: WallType = { ...t };
|
||||
const put = <K extends keyof WallType>(k: K, v: WallType[K] | null | undefined) => {
|
||||
return patchItem(project, HOST[host].types, typeId, ((t: LayeredType) => {
|
||||
const next: LayeredType = { ...t };
|
||||
const put = <K extends keyof LayeredType>(k: K, v: LayeredType[K] | null | undefined) => {
|
||||
if (v === undefined) return;
|
||||
if (v === null || (Array.isArray(v) && v.every((x) => x === "auto"))) delete next[k];
|
||||
else next[k] = v;
|
||||
@@ -426,7 +457,7 @@ export function setTypePairOps(
|
||||
put("renovationOld", patch.old);
|
||||
put("renovationNew", patch.new);
|
||||
return next;
|
||||
});
|
||||
}) as never);
|
||||
}
|
||||
|
||||
/** Schicht eines Typ-Paars (Kern-Abfrage `renovationPair`). */
|
||||
@@ -444,6 +475,7 @@ export interface RenovationStripPiece {
|
||||
fill: string;
|
||||
}
|
||||
export interface RenovationPair {
|
||||
kind: RenovationHost;
|
||||
type: string;
|
||||
target: string;
|
||||
side: RenovationSide;
|
||||
@@ -452,21 +484,22 @@ export interface RenovationPair {
|
||||
oldStrip: RenovationStripPiece[];
|
||||
newStrip: RenovationStripPiece[];
|
||||
result: RenovationStripPiece[];
|
||||
walls: number;
|
||||
/** Elemente des Bestandstyps bzw. davon mit diesem Sanierungstyp saniert. */
|
||||
elements: number;
|
||||
renovated: number;
|
||||
}
|
||||
|
||||
/** Typ-Paar Bestandstyp → Sanierungstyp (`target` fehlt = eingetragener); `null` ohne gültiges Paar. */
|
||||
export function renovationPair(project: Project, typeId: string, target?: string): RenovationPair | null {
|
||||
return documentFor(project).query<RenovationPair | null>("renovationPair", [], JSON.stringify({ type: typeId, target: target ?? "" }));
|
||||
export function renovationPair(project: Project, typeId: string, target?: string, host: RenovationHost = "wall"): RenovationPair | null {
|
||||
return documentFor(project).query<RenovationPair | null>("renovationPair", [], JSON.stringify({ type: typeId, target: target ?? "", kind: host }));
|
||||
}
|
||||
|
||||
export interface RenovationPairsInfo {
|
||||
pairs: { type: string; name: string; target: string; targetName: string | null; walls: number; renovated: number }[];
|
||||
pairs: { kind: RenovationHost; type: string; name: string; target: string; targetName: string | null; elements: number; renovated: number }[];
|
||||
renovated: number;
|
||||
}
|
||||
|
||||
/** Alle Typ-Paare mit Zählern (Umbau-Panel „Sanierung“). */
|
||||
/** Alle Typ-Paare (Wände, Decken, Dächer) mit Zählern (Umbau-Panel „Sanierung“). */
|
||||
export function renovationPairs(project: Project): RenovationPairsInfo {
|
||||
return documentFor(project).query<RenovationPairsInfo>("renovationPairs");
|
||||
}
|
||||
@@ -78,7 +78,7 @@ describe("[274] Sanierung je Schicht", () => {
|
||||
// Alles „automatisch“: Feld weg.
|
||||
const u = applyOps(s, setTypePairOps(s, "aw", { old: ["auto", "auto"] }));
|
||||
expect(u.wallTypes.find((t) => t.id === "aw")).not.toHaveProperty("renovationOld");
|
||||
expect(renovationPairs(u).pairs.map((x) => x.type).sort()).toEqual(["aw", "aw-bestand"]);
|
||||
expect(renovationPairs(u).pairs.filter((x) => x.kind === "wall").map((x) => x.type).sort()).toEqual(["aw", "aw-bestand"]);
|
||||
});
|
||||
|
||||
it("Beispiel Umbau: Typ-Paar der Südwand, Zähler, Grundriss und GF je Filter", () => {
|
||||
@@ -87,7 +87,8 @@ describe("[274] Sanierung je Schicht", () => {
|
||||
expect(pr?.old.map((l) => l.fate)).toEqual(["demolish", "demolish", "kept"]);
|
||||
expect(pr?.new.map((l) => l.fate)).toEqual(["new", "new", "kept"]);
|
||||
expect(pr?.result.map((q) => q.kind)).toEqual(["new", "new", "newOverDemolish", "newOverDemolish", "kept"]);
|
||||
expect(renovationPairs(p).renovated).toBe(1);
|
||||
// Südwand W1, Decke C1, Dach RF1.
|
||||
expect(renovationPairs(p).renovated).toBe(3);
|
||||
// Grundriss: Abbruch gelb, Umbauplan mit gelber gestrichelter Kontur über Rot.
|
||||
const dashedYellow = (prims: ReturnType<typeof plan>) => prims.some((x) => x.kind === "line" && !!x.dash && x.color === "#e8c35a");
|
||||
expect(dashedYellow(plan(p, "umbauplan"))).toBe(true);
|
||||
@@ -99,4 +100,37 @@ describe("[274] Sanierung je Schicht", () => {
|
||||
const gfB = (q: Project) => computeAreaTable(q, "bestand").total.gf;
|
||||
expect(gfB(p)).toBeCloseTo(gfB(unsaniert), 9);
|
||||
});
|
||||
|
||||
it("Decken und Dächer: Typ-Paare, Ops je Bauteilart, Bezugsseite unten", () => {
|
||||
const p = buildUmbauSampleProject();
|
||||
const kinds = renovationPairs(p).pairs.map((x) => `${x.kind}:${x.type}:${x.renovated}/${x.elements}`).sort();
|
||||
expect(kinds).toEqual(["ceiling:decke-bestand:1/1", "roof:dach-bestand:1/1", "wall:aw-bestand:1/1"]);
|
||||
// Decke: Rohdecke bleibt (Bezugsseite unten = „inside“), darüber alles neu.
|
||||
const pc = renovationPair(p, "decke-bestand", undefined, "ceiling");
|
||||
expect(pc?.kind).toBe("ceiling");
|
||||
expect(pc?.side).toBe("inside");
|
||||
expect(pc?.old.map((l) => l.fate)).toEqual(["demolish", "demolish", "demolish", "kept"]);
|
||||
expect(pc?.new.map((l) => l.fate)).toEqual(["new", "new", "new", "kept"]);
|
||||
// Dach: Sparren und Verkleidung bleiben, Ziegel ab, Dämmung und Ziegel neu.
|
||||
const pr = renovationPair(p, "dach-bestand", undefined, "roof");
|
||||
expect(pr?.old.map((l) => l.fate)).toEqual(["demolish", "kept", "kept"]);
|
||||
expect(pr?.new.map((l) => l.fate)).toEqual(["new", "new", "kept", "kept"]);
|
||||
// Bezugsseite oben (gleiche Gesamtdicke: die Rohdecke liegt auch von oben her gleich und bleibt).
|
||||
const q = applyOps(p, setTypePairOps(p, "decke-bestand", { side: "outside" }, "ceiling"));
|
||||
expect(q.ceilingTypes?.find((t) => t.id === "decke-bestand")?.renovationSide).toBe("outside");
|
||||
expect(renovationPair(q, "decke-bestand", undefined, "ceiling")?.side).toBe("outside");
|
||||
expect(renovationPair(q, "decke-bestand", undefined, "ceiling")?.old.map((l) => l.fate)).toEqual(["demolish", "demolish", "demolish", "kept"]);
|
||||
// Ops je Art: keiner / wie Typ, gemeinsamer Wert, Sanierungstyp anlegen, alle sanieren.
|
||||
const none = applyOps(p, setBuildUpOps(p, ["C1"], { kind: "none" }, "ceiling"));
|
||||
expect(none.ceilings?.find((c) => c.id === "C1")?.renovation).toEqual({ status: "existing", phase: "etappe-1" });
|
||||
expect(commonBuildUp(p, ["C1"], "ceiling")).toBe("type");
|
||||
expect(commonBuildUp(p, ["RF1"], "roof")).toBe("type");
|
||||
expect(commonBuildUp(p, ["W1"], "ceiling")).toBeNull();
|
||||
const { ops, id } = createRenovationTypeOps(p, "dg-massiv", "Decke saniert", "ceiling");
|
||||
const r = applyOps(p, ops);
|
||||
expect(r.ceilingTypes?.find((t) => t.id === "dg-massiv")?.renovationTarget).toBe(id);
|
||||
const s = applyOps(r, renovateAllOfTypeOps(r, "dg-massiv", "ceiling"));
|
||||
// C2 (Anbau) ist neu: nicht saniert; sonst trägt keine Decke „dg-massiv“.
|
||||
expect((s.ceilings ?? []).filter((c) => c.renovation?.renovated).map((c) => c.id)).toEqual(["C1"]);
|
||||
});
|
||||
});
|
||||
@@ -11,9 +11,13 @@
|
||||
// [274] Sanierung je Schicht: die Südwand W1 ist eine Aussenwand „Beton 20 + Dämmung 10 + Aussenputz“ (Bestandstyp
|
||||
// „aw-bestand“) mit dem Sanierungstyp „aw-saniert“ (Beton bleibt, Dämmung und Putz werden abgebrochen, neue Dämmung 20 +
|
||||
// neuer Putz), saniert in Etappe 1: Kern bleibt an seiner Stelle, die Fassade rückt 10 cm nach aussen.
|
||||
// Ebenso je Schicht saniert (Etappe 1): die Geschossdecke C1 über dem EG (Rohdecke bleibt; Linoleum, Unterlagsboden und
|
||||
// Trittschall werden abgebrochen, neu Parkett + Unterlagsboden + dickerer Trittschall, gleiche Gesamtdicke) und das Dach
|
||||
// RF1 (Sparren und Verkleidung bleiben; Ziegel ab, neu 12 cm Aufsparrendämmung + Ziegel: die Dachhaut hebt sich). Schnitt C
|
||||
// (x = 2) schneidet Wand, Decke und Dach.
|
||||
// Nur Modellfelder, keine Kern-Befehle: das Modul ist ohne geladenen Kern auswertbar.
|
||||
|
||||
import type { Ceiling, Drawing2D, DrawingLevel, Opening, Project, Renovation, Room, Tree, Wall, WallType } from "./types";
|
||||
import type { Ceiling, CeilingType, Component, Drawing2D, DrawingLevel, Opening, Project, Renovation, Roof, RoofType, Room, Tree, Wall, WallType } from "./types";
|
||||
import { sampleProject } from "./sampleProject";
|
||||
|
||||
const E1: Renovation = { status: "new", phase: "etappe-1" };
|
||||
@@ -87,10 +91,67 @@ export function buildUmbauSampleProject(): Project {
|
||||
// Fenster des Anbaus: ohne eigenen Status, folgt der neuen Wand.
|
||||
win("O5", "W11", 0.9, 1.2),
|
||||
);
|
||||
const c1 = (base.ceilings ?? [])[0];
|
||||
// [274] Decke und Dach je Schicht saniert (Typ-Paare oben → unten bzw. aussen → innen).
|
||||
const components: Component[] = [
|
||||
...base.components,
|
||||
{ id: "linoleum", name: "Linoleum", color: "#9c8f6e", hatchId: "none", joinPriority: 5 },
|
||||
{ id: "parquet", name: "Parkett", color: "#c49a6c", hatchId: "none", joinPriority: 5 },
|
||||
{ id: "timber", name: "Sparren (Holz)", color: "#c8a26b", hatchId: "diagonal", joinPriority: 40 },
|
||||
];
|
||||
const ceilingTypes: CeilingType[] = [
|
||||
...(base.ceilingTypes ?? []),
|
||||
{
|
||||
id: "decke-bestand",
|
||||
name: "Geschossdecke Linoleum (Bestand)",
|
||||
layers: [
|
||||
{ componentId: "linoleum", thickness: 0.005 },
|
||||
{ componentId: "screed", thickness: 0.055 },
|
||||
{ componentId: "insulation", thickness: 0.02 },
|
||||
{ componentId: "concrete", thickness: 0.2 },
|
||||
],
|
||||
renovationTarget: "decke-saniert",
|
||||
},
|
||||
{
|
||||
id: "decke-saniert",
|
||||
name: "Geschossdecke Parkett (saniert)",
|
||||
layers: [
|
||||
{ componentId: "parquet", thickness: 0.01 },
|
||||
{ componentId: "screed", thickness: 0.04 },
|
||||
{ componentId: "insulation", thickness: 0.03 },
|
||||
{ componentId: "concrete", thickness: 0.2 },
|
||||
],
|
||||
},
|
||||
];
|
||||
const roofTypes: RoofType[] = [
|
||||
...(base.roofTypes ?? []),
|
||||
{
|
||||
id: "dach-bestand",
|
||||
name: "Steildach Sparren (Bestand)",
|
||||
layers: [
|
||||
{ componentId: "roof-tiles", thickness: 0.04 },
|
||||
{ componentId: "timber", thickness: 0.16 },
|
||||
{ componentId: "render-int", thickness: 0.0125 },
|
||||
],
|
||||
renovationTarget: "dach-saniert",
|
||||
},
|
||||
{
|
||||
id: "dach-saniert",
|
||||
name: "Steildach Aufsparrendämmung (saniert)",
|
||||
layers: [
|
||||
{ componentId: "roof-tiles", thickness: 0.04 },
|
||||
{ componentId: "insulation", thickness: 0.12 },
|
||||
{ componentId: "timber", thickness: 0.16 },
|
||||
{ componentId: "render-int", thickness: 0.0125 },
|
||||
],
|
||||
},
|
||||
];
|
||||
const R1: Renovation = { status: "existing", phase: "etappe-1", renovated: true };
|
||||
const roofs: Roof[] = (base.roofs ?? []).map((r) => (r.id === "RF1" ? { ...r, roofTypeId: "dach-bestand", renovation: R1 } : r));
|
||||
const c1: Ceiling = { ...(base.ceilings ?? [])[0], ceilingTypeId: "decke-bestand", renovation: R1 };
|
||||
const ceilings: Ceiling[] = [
|
||||
...(base.ceilings ?? []),
|
||||
{ ...c1, id: "C2", outline: [{ x: 0, y: 4 }, { x: 3, y: 4 }, { x: 3, y: 7 }, { x: 0, y: 7 }], renovation: E2 },
|
||||
c1,
|
||||
...(base.ceilings ?? []).slice(1),
|
||||
{ ...c1, ceilingTypeId: (base.ceilings ?? [])[0].ceilingTypeId, id: "C2", outline: [{ x: 0, y: 4 }, { x: 3, y: 4 }, { x: 3, y: 7 }, { x: 0, y: 7 }], renovation: E2 },
|
||||
];
|
||||
const r1 = (base.rooms ?? [])[0];
|
||||
const h = 0.1725;
|
||||
@@ -117,6 +178,10 @@ export function buildUmbauSampleProject(): Project {
|
||||
name: "Beispiel Umbau",
|
||||
drawingLevels: levels,
|
||||
wallTypes,
|
||||
components,
|
||||
ceilingTypes,
|
||||
roofTypes,
|
||||
roofs,
|
||||
walls,
|
||||
openings,
|
||||
ceilings,
|
||||
|
||||
@@ -237,7 +237,23 @@ export type Ceiling = {
|
||||
* damit Fuge/Schraffur-Auflösung identisch zur Wand bleiben. Eine „einschichtige"
|
||||
* Decke (SOLID) ist einfach ein Deckentyp mit genau einer Schicht.
|
||||
*/
|
||||
export type CeilingType = { id: string; name: string; layers: Array<Layer> };
|
||||
export type CeilingType = {
|
||||
id: string;
|
||||
name: string;
|
||||
layers: Array<Layer>;
|
||||
/**
|
||||
* [274] Sanierungstyp (Deckentyp-Id): neuer Aufbau aller als „saniert“ markierten Decken dieses (Bestands-)Typs.
|
||||
*/
|
||||
renovationTarget?: string;
|
||||
/**
|
||||
* [274] Bezugsseite der Sanierung (fehlt ⇒ innen); bei Decken: innen = unten (Rohdecke bleibt, die Oberkante verschiebt sich), aussen = oben (Oberkante bleibt).
|
||||
*/
|
||||
renovationSide?: RenovationSide;
|
||||
/** [274] Manuelle Zuordnung je Schicht dieses Bestandstyps (wie `WallType.renovationOld`). */
|
||||
renovationOld?: Array<LayerRenovation>;
|
||||
/** [274] Manuelle Zuordnung je Schicht des Sanierungstyps (wie `WallType.renovationNew`). */
|
||||
renovationNew?: Array<LayerRenovation>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Ein Stift (ArchiCAD-Stiftsatz-Muster): ein reiner NAME/PLATZHALTER, der
|
||||
@@ -3688,6 +3704,18 @@ export type RoofType = {
|
||||
name: string;
|
||||
/** Aussen (Eindeckung) → innen (Verkleidung), analog `WallType.layers`. */
|
||||
layers: Array<Layer>;
|
||||
/**
|
||||
* [274] Sanierungstyp (Dachtyp-Id): neuer Aufbau aller als „saniert“ markierten Dächer dieses (Bestands-)Typs.
|
||||
*/
|
||||
renovationTarget?: string;
|
||||
/**
|
||||
* [274] Bezugsseite der Sanierung (fehlt ⇒ innen); innen = Tragwerk/Verkleidung bleibt, die Dachhaut verschiebt sich.
|
||||
*/
|
||||
renovationSide?: RenovationSide;
|
||||
/** [274] Manuelle Zuordnung je Schicht dieses Bestandstyps (wie `WallType.renovationOld`). */
|
||||
renovationOld?: Array<LayerRenovation>;
|
||||
/** [274] Manuelle Zuordnung je Schicht des Sanierungstyps (wie `WallType.renovationNew`). */
|
||||
renovationNew?: Array<LayerRenovation>;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,37 +1,49 @@
|
||||
// [274] Umbau-Panel, Abschnitt „Sanierung“: Typ-Paare Bestandstyp → Sanierungstyp mit Zählern, „Alle Wände vom Typ
|
||||
// sanieren“ (ein Undo-Schritt), „Sanierungstyp anlegen …“ (Kopie des Bestandstyps) und der Typ-Paar-Editor: Alt und Neu
|
||||
// nebeneinander, Zuordnung je Schicht (automatisch oder manuell), Bezugsseite, Ergebnis-Streifen mit SIA-Farben.
|
||||
// Die Regeln (Zuordnung, Teilstücke) rechnet der Kern (`renovation::build_up`); gespeichert wird am Bestandstyp.
|
||||
// [274] Umbau-Panel, Abschnitt „Sanierung“: Typ-Paare Bestandstyp → Sanierungstyp für Wände, Decken und Dächer mit
|
||||
// Zählern, „Alle … vom Typ sanieren“ (ein Undo-Schritt), „Sanierungstyp anlegen …“ (Kopie des Bestandstyps) und der
|
||||
// Typ-Paar-Editor: Alt und Neu nebeneinander, Zuordnung je Schicht (automatisch oder manuell), Bezugsseite (Decken:
|
||||
// unten/oben), Ergebnis-Streifen mit SIA-Farben. Die Regeln (Zuordnung, Teilstücke) rechnet der Kern
|
||||
// (`renovation::build_up`, für alle drei Bauteilarten dieselbe); gespeichert wird am Bestandstyp.
|
||||
|
||||
import { useState } from "react";
|
||||
import { t } from "../i18n";
|
||||
import type { TranslationKey } from "../i18n";
|
||||
import { useStore } from "../state/appStore";
|
||||
import {
|
||||
RENOVATION_HOSTS,
|
||||
createRenovationTypeOps,
|
||||
renovateAllOfTypeOps,
|
||||
renovationPair,
|
||||
renovationPairs,
|
||||
renovationTypes,
|
||||
setTypePairOps,
|
||||
} from "../core";
|
||||
import type { RenovationHost } from "../core";
|
||||
import type { LayerRenovation, Project, RenovationSide } from "../model/types";
|
||||
import { RenovationStrip } from "../ui/RenovationStrip";
|
||||
import { usePanelHostAction } from "./host";
|
||||
|
||||
function PairEditor({ project, typeId }: { project: Project; typeId: string }) {
|
||||
/** Ressourcen-Reiter mit den Schichten je Bauteilart. */
|
||||
const RESOURCE_TAB = { wall: "wallStyles", ceiling: "ceilingStyles", roof: "roofStyles" } as const;
|
||||
|
||||
/** Bezugsseiten-Beschriftung je Bauteilart (Decken: unten/oben). */
|
||||
const sideKey = (host: RenovationHost, side: "inside" | "outside"): TranslationKey =>
|
||||
(host === "wall" ? `renovation.panel.sanierung.side.${side}` : `renovation.panel.sanierung.side.${host}.${side}`) as TranslationKey;
|
||||
|
||||
function PairEditor({ project, typeId, host }: { project: Project; typeId: string; host: RenovationHost }) {
|
||||
const applyChange = useStore((s) => s.applyChange);
|
||||
const openResources = usePanelHostAction("onOpenResources");
|
||||
const wt = project.wallTypes.find((x) => x.id === typeId);
|
||||
const pair = renovationPair(project, typeId);
|
||||
const types = renovationTypes(project, host);
|
||||
const wt = types.find((x) => x.id === typeId);
|
||||
const pair = renovationPair(project, typeId, undefined, host);
|
||||
if (!wt || !pair) return null;
|
||||
const oldOv = wt.renovationOld ?? [];
|
||||
const newOv = wt.renovationNew ?? [];
|
||||
const setOv = (which: "old" | "new", i: number, v: LayerRenovation) => {
|
||||
const n = which === "old" ? wt.layers.length : (project.wallTypes.find((x) => x.id === pair.target)?.layers.length ?? 0);
|
||||
const n = which === "old" ? wt.layers.length : (types.find((x) => x.id === pair.target)?.layers.length ?? 0);
|
||||
const cur = [...(which === "old" ? oldOv : newOv)];
|
||||
while (cur.length < n) cur.push("auto");
|
||||
cur[i] = v;
|
||||
applyChange((p) => setTypePairOps(p, typeId, which === "old" ? { old: cur } : { new: cur }));
|
||||
applyChange((p) => setTypePairOps(p, typeId, which === "old" ? { old: cur } : { new: cur }, host));
|
||||
};
|
||||
const layerRow = (which: "old" | "new", l: (typeof pair.old)[number], i: number) => {
|
||||
const ov = (which === "old" ? oldOv : newOv)[i] ?? "auto";
|
||||
@@ -63,8 +75,8 @@ function PairEditor({ project, typeId }: { project: Project; typeId: string }) {
|
||||
<div className="reno-pair-editor" data-testid="reno-pair-editor">
|
||||
<label className="reno-field">
|
||||
<span>{t("renovation.panel.sanierung.target")}</span>
|
||||
<select value={pair.target} data-testid="reno-pair-target" onChange={(e) => applyChange((p) => setTypePairOps(p, typeId, { target: e.target.value, old: null, new: null }))}>
|
||||
{project.wallTypes
|
||||
<select value={pair.target} data-testid="reno-pair-target" onChange={(e) => applyChange((p) => setTypePairOps(p, typeId, { target: e.target.value, old: null, new: null }, host))}>
|
||||
{types
|
||||
.filter((x) => x.id !== typeId)
|
||||
.map((x) => (
|
||||
<option key={x.id} value={x.id}>
|
||||
@@ -75,9 +87,9 @@ function PairEditor({ project, typeId }: { project: Project; typeId: string }) {
|
||||
</label>
|
||||
<label className="reno-field">
|
||||
<span>{t("renovation.panel.sanierung.side")}</span>
|
||||
<select value={pair.side} data-testid="reno-pair-side" onChange={(e) => applyChange((p) => setTypePairOps(p, typeId, { side: e.target.value as RenovationSide }))}>
|
||||
<option value="inside">{t("renovation.panel.sanierung.side.inside")}</option>
|
||||
<option value="outside">{t("renovation.panel.sanierung.side.outside")}</option>
|
||||
<select value={pair.side} data-testid="reno-pair-side" onChange={(e) => applyChange((p) => setTypePairOps(p, typeId, { side: e.target.value as RenovationSide }, host))}>
|
||||
<option value="inside">{t(sideKey(host, "inside"))}</option>
|
||||
<option value="outside">{t(sideKey(host, "outside"))}</option>
|
||||
</select>
|
||||
</label>
|
||||
<div className="reno-pair-cols">
|
||||
@@ -92,13 +104,18 @@ function PairEditor({ project, typeId }: { project: Project; typeId: string }) {
|
||||
</div>
|
||||
<RenovationStrip pair={pair} width={170} />
|
||||
<div className="reno-select-by">
|
||||
<button type="button" className="reno-link-btn" data-testid="reno-pair-reset" onClick={() => applyChange((p) => setTypePairOps(p, typeId, { old: null, new: null }))}>
|
||||
<button type="button" className="reno-link-btn" data-testid="reno-pair-reset" onClick={() => applyChange((p) => setTypePairOps(p, typeId, { old: null, new: null }, host))}>
|
||||
{t("renovation.panel.sanierung.reset")}
|
||||
</button>
|
||||
<button type="button" className="reno-link-btn" onClick={() => openResources("wallStyles")}>
|
||||
<button type="button" className="reno-link-btn" onClick={() => openResources(RESOURCE_TAB[host])}>
|
||||
{t("renovation.panel.sanierung.editLayers")}
|
||||
</button>
|
||||
<button type="button" className="reno-link-btn" data-testid="reno-pair-remove" onClick={() => applyChange((p) => setTypePairOps(p, typeId, { target: null, old: null, new: null, side: null }))}>
|
||||
<button
|
||||
type="button"
|
||||
className="reno-link-btn"
|
||||
data-testid="reno-pair-remove"
|
||||
onClick={() => applyChange((p) => setTypePairOps(p, typeId, { target: null, old: null, new: null, side: null }, host))}
|
||||
>
|
||||
{t("renovation.panel.sanierung.remove")}
|
||||
</button>
|
||||
</div>
|
||||
@@ -110,10 +127,15 @@ export function RenovationSanierung({ project }: { project: Project }) {
|
||||
const applyChange = useStore((s) => s.applyChange);
|
||||
const info = renovationPairs(project);
|
||||
const [open, setOpen] = useState<string | null>(null);
|
||||
const targets = new Set(info.pairs.map((x) => x.target));
|
||||
const candidates = project.wallTypes.filter((x) => !x.renovationTarget && !targets.has(x.id));
|
||||
// Bestandstypen ohne Sanierungstyp (und nicht selbst Sanierungstyp) je Bauteilart; Schlüssel `host:id`.
|
||||
const candidates = RENOVATION_HOSTS.flatMap((host) => {
|
||||
const targets = new Set(info.pairs.filter((x) => x.kind === host).map((x) => x.target));
|
||||
return renovationTypes(project, host)
|
||||
.filter((x) => !x.renovationTarget && !targets.has(x.id))
|
||||
.map((x) => ({ host, id: x.id, name: x.name, key: `${host}:${x.id}` }));
|
||||
});
|
||||
const [pick, setPick] = useState("");
|
||||
const pickId = candidates.some((x) => x.id === pick) ? pick : (candidates[0]?.id ?? "");
|
||||
const picked = candidates.find((x) => x.key === pick) ?? candidates[0];
|
||||
return (
|
||||
<div className="reno-block" data-testid="reno-sanierung">
|
||||
<div className="reno-head">{t("renovation.panel.sanierung.title")}</div>
|
||||
@@ -121,49 +143,69 @@ export function RenovationSanierung({ project }: { project: Project }) {
|
||||
{t("renovation.panel.sanierung.count", { n: String(info.renovated) })}
|
||||
</div>
|
||||
{info.pairs.length === 0 && <div className="reno-hint">{t("renovation.panel.sanierung.empty")}</div>}
|
||||
{info.pairs.map((pr) => (
|
||||
<div className="reno-pair" key={pr.type} data-testid="reno-pair">
|
||||
<div className="reno-pair-title">
|
||||
<span>{pr.name}</span>
|
||||
<span aria-hidden="true">→</span>
|
||||
<span>{pr.targetName ?? pr.target}</span>
|
||||
{RENOVATION_HOSTS.map((host) => {
|
||||
const pairs = info.pairs.filter((x) => x.kind === host);
|
||||
if (pairs.length === 0) return null;
|
||||
return (
|
||||
<div key={host} data-testid={`reno-pairs-${host}`}>
|
||||
<div className="reno-head sub">{t(`renovation.panel.sanierung.host.${host}` as TranslationKey)}</div>
|
||||
{pairs.map((pr) => {
|
||||
const key = `${host}:${pr.type}`;
|
||||
return (
|
||||
<div className="reno-pair" key={key} data-testid="reno-pair" data-kind={host}>
|
||||
<div className="reno-pair-title">
|
||||
<span>{pr.name}</span>
|
||||
<span aria-hidden="true">→</span>
|
||||
<span>{pr.targetName ?? pr.target}</span>
|
||||
</div>
|
||||
<div className="reno-hint">
|
||||
{t((host === "wall" ? "renovation.panel.sanierung.walls" : `renovation.panel.sanierung.${host}s`) as TranslationKey, { r: String(pr.renovated), n: String(pr.elements) })}
|
||||
</div>
|
||||
<div className="reno-select-by">
|
||||
<button
|
||||
type="button"
|
||||
className="reno-link-btn"
|
||||
data-testid="reno-pair-renovate-all"
|
||||
disabled={pr.elements === 0 || pr.renovated === pr.elements}
|
||||
onClick={() => applyChange((p) => renovateAllOfTypeOps(p, pr.type, host))}
|
||||
>
|
||||
{t((host === "wall" ? "renovation.panel.sanierung.renovateAll" : `renovation.panel.sanierung.renovateAll.${host}`) as TranslationKey)}
|
||||
</button>
|
||||
<button type="button" className="reno-link-btn" data-testid="reno-pair-edit" aria-expanded={open === key} onClick={() => setOpen(open === key ? null : key)}>
|
||||
{t("renovation.panel.sanierung.edit")}
|
||||
</button>
|
||||
</div>
|
||||
{open === key && <PairEditor project={project} typeId={pr.type} host={host} />}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<div className="reno-hint">{t("renovation.panel.sanierung.walls", { r: String(pr.renovated), n: String(pr.walls) })}</div>
|
||||
<div className="reno-select-by">
|
||||
<button
|
||||
type="button"
|
||||
className="reno-link-btn"
|
||||
data-testid="reno-pair-renovate-all"
|
||||
disabled={pr.walls === 0 || pr.renovated === pr.walls}
|
||||
onClick={() => applyChange((p) => renovateAllOfTypeOps(p, pr.type))}
|
||||
>
|
||||
{t("renovation.panel.sanierung.renovateAll")}
|
||||
</button>
|
||||
<button type="button" className="reno-link-btn" data-testid="reno-pair-edit" aria-expanded={open === pr.type} onClick={() => setOpen(open === pr.type ? null : pr.type)}>
|
||||
{t("renovation.panel.sanierung.edit")}
|
||||
</button>
|
||||
</div>
|
||||
{open === pr.type && <PairEditor project={project} typeId={pr.type} />}
|
||||
</div>
|
||||
))}
|
||||
{candidates.length > 0 && (
|
||||
);
|
||||
})}
|
||||
{picked && (
|
||||
<div className="reno-field reno-create">
|
||||
<select value={pickId} aria-label={t("renovation.panel.sanierung.createFor")} data-testid="reno-create-type" onChange={(e) => setPick(e.target.value)}>
|
||||
{candidates.map((x) => (
|
||||
<option key={x.id} value={x.id}>
|
||||
{x.name}
|
||||
</option>
|
||||
))}
|
||||
<select value={picked.key} aria-label={t("renovation.panel.sanierung.createFor")} data-testid="reno-create-type" onChange={(e) => setPick(e.target.value)}>
|
||||
{RENOVATION_HOSTS.map((host) => {
|
||||
const list = candidates.filter((x) => x.host === host);
|
||||
return list.length === 0 ? null : (
|
||||
<optgroup key={host} label={t(`renovation.panel.sanierung.host.${host}` as TranslationKey)}>
|
||||
{list.map((x) => (
|
||||
<option key={x.key} value={x.key}>
|
||||
{x.name}
|
||||
</option>
|
||||
))}
|
||||
</optgroup>
|
||||
);
|
||||
})}
|
||||
</select>
|
||||
<button
|
||||
type="button"
|
||||
className="reno-add-btn"
|
||||
data-testid="reno-create"
|
||||
onClick={() => {
|
||||
const src = project.wallTypes.find((x) => x.id === pickId);
|
||||
if (!src) return;
|
||||
applyChange((p) => createRenovationTypeOps(p, pickId, t("renovation.panel.sanierung.newName", { name: src.name })).ops);
|
||||
setOpen(pickId);
|
||||
const src = picked;
|
||||
applyChange((p) => createRenovationTypeOps(p, src.id, t("renovation.panel.sanierung.newName", { name: src.name }), src.host).ops);
|
||||
setOpen(src.key);
|
||||
}}
|
||||
>
|
||||
{t("renovation.panel.sanierung.create")}
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
import { memo } from "react";
|
||||
import { t } from "../../i18n";
|
||||
import type { RenovationStatus } from "../../model/types";
|
||||
import { RENOVATION_STATUSES, commonBuildUp, parseBuildUpKey, renovationPair, setBuildUpOps } from "../../core";
|
||||
import { RENOVATION_STATUSES, commonBuildUp, hostTypeId, parseBuildUpKey, renovationPair, renovationTypes, setBuildUpOps } from "../../core";
|
||||
import type { RenovationHost } from "../../core";
|
||||
import { getState, useStore } from "../../state/appStore";
|
||||
import { RenovationStrip } from "../../ui/RenovationStrip";
|
||||
import { useRenovationSelection } from "../../state/renovationHook";
|
||||
@@ -65,26 +66,33 @@ export const RenovationField = memo(function RenovationField() {
|
||||
);
|
||||
});
|
||||
|
||||
const NO_TYPES: readonly { id: string; name: string; renovationTarget?: string }[] = [];
|
||||
const NO_IDS: readonly string[] = [];
|
||||
const SEL_KEY = { wall: "walls", ceiling: "ceilings", roof: "roofs" } as const;
|
||||
|
||||
/**
|
||||
* [274] „Neuer Aufbau (Sanierung)“ der gewählten Wände: keiner, wie Typ (Sanierungstyp des Wandtyps) oder ein anderer
|
||||
* Wandtyp (Ausnahme). Mehrfachauswahl in einem Undo-Schritt; bei gemeinsamem Wandtyp der Streifen Alt/Neu/Ergebnis.
|
||||
* [274] „Neuer Aufbau (Sanierung)“ der gewählten Wände, Decken oder Dächer (die erste Art der Auswahl): keiner, wie Typ
|
||||
* (Sanierungstyp des Typs) oder ein anderer Typ derselben Art (Ausnahme). Mehrfachauswahl in einem Undo-Schritt; bei
|
||||
* gemeinsamem Typ der Streifen Alt/Neu/Ergebnis.
|
||||
*/
|
||||
const BuildUpField = memo(function BuildUpField() {
|
||||
const types = useStore((s) => s.project.wallTypes) ?? NO_TYPES;
|
||||
const applyChange = useStore((s) => s.applyChange);
|
||||
const wallIds = useStore((s) => s.selection.walls);
|
||||
// Gemeinsamer Aufbau und gemeinsamer Wandtyp als Text: rendert nur bei echter Änderung neu.
|
||||
const host = useStore((s): RenovationHost | null => (s.selection.walls.length ? "wall" : s.selection.ceilings.length ? "ceiling" : s.selection.roofs.length ? "roof" : null));
|
||||
const ids = useStore((s) => (host ? s.selection[SEL_KEY[host]] : NO_IDS));
|
||||
// Typen der Art (Id, Name, Sanierungstyp) als Text: rendert nur bei echter Änderung neu.
|
||||
const typesKey = useStore((s) => (host ? JSON.stringify(renovationTypes(s.project, host).map((x) => [x.id, x.name, x.renovationTarget ?? ""])) : "[]"));
|
||||
// Gemeinsamer Aufbau und gemeinsamer Typ als Text.
|
||||
const key = useStore((s) => {
|
||||
const set = new Set(s.selection.walls);
|
||||
const ts = new Set(s.project.walls.filter((w) => set.has(w.id)).map((w) => w.wallTypeId));
|
||||
return JSON.stringify([commonBuildUp(s.project, s.selection.walls), ts.size === 1 ? [...ts][0] : null]);
|
||||
if (!host) return JSON.stringify([null, null]);
|
||||
const set = new Set(ids);
|
||||
const items = ((s.project as unknown as Record<string, { id: string }[] | undefined>)[SEL_KEY[host]] ?? []).filter((x) => set.has(x.id));
|
||||
const ts = new Set(items.map((x) => hostTypeId(x, host) ?? ""));
|
||||
return JSON.stringify([commonBuildUp(s.project, ids, host), ts.size === 1 ? [...ts][0] || null : null]);
|
||||
});
|
||||
const [common, typeId] = JSON.parse(key) as [string | null, string | null];
|
||||
if (common === null || wallIds.length === 0) return null;
|
||||
if (!host || common === null || ids.length === 0) return null;
|
||||
const types = (JSON.parse(typesKey) as [string, string, string][]).map(([id, name, target]) => ({ id, name, target }));
|
||||
const own = typeId ? types.find((x) => x.id === typeId) : undefined;
|
||||
const ownTarget = own?.renovationTarget ? types.find((x) => x.id === own.renovationTarget) : undefined;
|
||||
const ownTarget = own?.target ? types.find((x) => x.id === own.target) : undefined;
|
||||
const options = [
|
||||
...(common === "mixed" ? [{ value: MIXED, label: t("renovation.mixed") }] : []),
|
||||
{ value: "", label: t("renovation.buildUp.none") },
|
||||
@@ -94,7 +102,7 @@ const BuildUpField = memo(function BuildUpField() {
|
||||
const value = common === "mixed" ? MIXED : common;
|
||||
const b = parseBuildUpKey(value === MIXED ? "" : value);
|
||||
const target = b.kind === "other" ? b.typeId : b.kind === "type" ? ownTarget?.id : undefined;
|
||||
const pair = typeId && target ? renovationPair(getState().project, typeId, target) : null;
|
||||
const pair = typeId && target ? renovationPair(getState().project, typeId, target, host) : null;
|
||||
return (
|
||||
<>
|
||||
<div className="objinfo-field" data-testid="objinfo-renovation-buildup">
|
||||
@@ -105,7 +113,7 @@ const BuildUpField = memo(function BuildUpField() {
|
||||
value={value}
|
||||
onChange={(v) => {
|
||||
if (v === MIXED) return;
|
||||
applyChange((p) => setBuildUpOps(p, wallIds, parseBuildUpKey(v)));
|
||||
applyChange((p) => setBuildUpOps(p, ids, parseBuildUpKey(v), host));
|
||||
}}
|
||||
options={options}
|
||||
title={t("renovation.buildUp")}
|
||||
|
||||
@@ -235,7 +235,10 @@ export function installTestHooks(): void {
|
||||
phase: l?.renovationPhase ?? null,
|
||||
draw: s.drawRenovation.status,
|
||||
walls: Object.fromEntries(s.project.walls.map((w) => [w.id, w.renovation?.status ?? "existing"])),
|
||||
buildUp: Object.fromEntries(s.project.walls.map((w) => [w.id, w.renovation?.newTypeId ?? (w.renovation?.renovated ? "type" : "")])),
|
||||
// [274] Wände, Decken und Dächer (Ids sind projektweit eindeutig).
|
||||
buildUp: Object.fromEntries(
|
||||
[...s.project.walls, ...(s.project.ceilings ?? []), ...(s.project.roofs ?? [])].map((w) => [w.id, w.renovation?.newTypeId ?? (w.renovation?.renovated ? "type" : "")]),
|
||||
),
|
||||
};
|
||||
},
|
||||
context: () =>
|
||||
|
||||
Reference in new issue
Block a user