[274] Umbau je Schicht: Sanierung mehrschichtiger Wände über Typ-Paar Bestand → Sanierungstyp
Modell (Rust, gen:types): WallType.renovationTarget/renovationSide/renovationOld/renovationNew, Wand renovation.renovated bzw. renovation.newTypeId (Ausnahme). Kern renovation::build_up: Zuordnung von der Bezugsseite her (Baustoff + Dicke + Lage = Bestand, manuell überschreibbar), gezeigter Aufbau je Filter (alt, neu, überlagert in Teilschichten), Ersatzwand mit Ersatztyp und Achsversatz für Grundriss, Schnitt, Ansicht, Axo, 3D und Kennzahlen; Farben je Schicht, Abbruch-Kanten gestrichelt, im Umbauplan gelbe gestrichelte Kontur über der roten Füllung. Abfragen renovationPair/renovationPairs. Oberfläche: Objekt-Info „Neuer Aufbau (Sanierung)“ mit Streifen Alt/Neu/Ergebnis, Umbau-Panel Abschnitt „Sanierung“ (Typ-Paare, Editor, Sanierungstyp anlegen, alle Wände vom Typ sanieren). Beispiel Umbau: Südwand Beton 20 + Dämmung 10 → Dämmung 20, Schnitt C. Tests: Kern renovation_layers_tests.rs, vitest renovationLayers.test.ts, e2e renovation274.spec.ts; Bilder doc/review-274. Nicht in der Tauri-App/auf dem Mac geprüft, 3D-Bild nicht angesehen.
This commit is contained in:
36 files changed
+2017
-44
No files matched your search
@@ -23,6 +23,7 @@ import {
|
||||
import type { Project, RenovationShow, RenovationStatus } from "../model/types";
|
||||
import { ConfirmDialog } from "../ui/ConfirmDialog";
|
||||
import { usePanelHostAction } from "./host";
|
||||
import { RenovationSanierung } from "./RenovationSanierung";
|
||||
|
||||
const MIXED = "__mixed";
|
||||
|
||||
@@ -238,6 +239,9 @@ export function RenovationPanel() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* [274] Sanierung je Schicht: Typ-Paare Bestand → Sanierungstyp */}
|
||||
<RenovationSanierung project={project} />
|
||||
|
||||
{/* Etappen */}
|
||||
<div className="reno-block">
|
||||
<div className="reno-head">{t("renovation.phases.title")}</div>
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
// [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.
|
||||
|
||||
import { useState } from "react";
|
||||
import { t } from "../i18n";
|
||||
import type { TranslationKey } from "../i18n";
|
||||
import { useStore } from "../state/appStore";
|
||||
import {
|
||||
createRenovationTypeOps,
|
||||
renovateAllOfTypeOps,
|
||||
renovationPair,
|
||||
renovationPairs,
|
||||
setTypePairOps,
|
||||
} 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 }) {
|
||||
const applyChange = useStore((s) => s.applyChange);
|
||||
const openResources = usePanelHostAction("onOpenResources");
|
||||
const wt = project.wallTypes.find((x) => x.id === typeId);
|
||||
const pair = renovationPair(project, typeId);
|
||||
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 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 }));
|
||||
};
|
||||
const layerRow = (which: "old" | "new", l: (typeof pair.old)[number], i: number) => {
|
||||
const ov = (which === "old" ? oldOv : newOv)[i] ?? "auto";
|
||||
const choices: LayerRenovation[] = which === "old" ? ["auto", "existing", "demolish"] : ["auto", "existing", "new"];
|
||||
return (
|
||||
<div className="reno-pair-layer" key={i} data-testid={`reno-pair-${which}-layer`} data-fate={l.fate}>
|
||||
<span className="reno-swatch" style={{ background: l.color }} aria-hidden="true" />
|
||||
<span className="reno-pair-name" title={l.name}>
|
||||
{l.name}
|
||||
</span>
|
||||
<span className="reno-pair-cm">{(l.thickness * 100).toFixed(1)}</span>
|
||||
<select
|
||||
value={ov}
|
||||
data-testid={`reno-pair-${which}-fate`}
|
||||
aria-label={l.name}
|
||||
className={`reno-fate is-${l.fate}`}
|
||||
onChange={(e) => setOv(which, i, e.target.value as LayerRenovation)}
|
||||
>
|
||||
{choices.map((c) => (
|
||||
<option key={c} value={c}>
|
||||
{c === "auto" ? `${t("renovation.fate.auto")} (${t(`renovation.fate.${l.fate}` as TranslationKey)})` : t(`renovation.fate.${c === "existing" ? "kept" : c}` as TranslationKey)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
return (
|
||||
<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
|
||||
.filter((x) => x.id !== typeId)
|
||||
.map((x) => (
|
||||
<option key={x.id} value={x.id}>
|
||||
{x.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</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>
|
||||
</label>
|
||||
<div className="reno-pair-cols">
|
||||
<div className="reno-pair-col">
|
||||
<div className="reno-head sub">{t("renovation.panel.sanierung.oldLayers")}</div>
|
||||
{pair.old.map((l, i) => layerRow("old", l, i))}
|
||||
</div>
|
||||
<div className="reno-pair-col">
|
||||
<div className="reno-head sub">{t("renovation.panel.sanierung.newLayers")}</div>
|
||||
{pair.new.map((l, i) => layerRow("new", l, i))}
|
||||
</div>
|
||||
</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 }))}>
|
||||
{t("renovation.panel.sanierung.reset")}
|
||||
</button>
|
||||
<button type="button" className="reno-link-btn" onClick={() => openResources("wallStyles")}>
|
||||
{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 }))}>
|
||||
{t("renovation.panel.sanierung.remove")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
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));
|
||||
const [pick, setPick] = useState("");
|
||||
const pickId = candidates.some((x) => x.id === pick) ? pick : (candidates[0]?.id ?? "");
|
||||
return (
|
||||
<div className="reno-block" data-testid="reno-sanierung">
|
||||
<div className="reno-head">{t("renovation.panel.sanierung.title")}</div>
|
||||
<div className="reno-hint" data-testid="reno-sanierung-count">
|
||||
{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>
|
||||
</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 && (
|
||||
<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>
|
||||
<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);
|
||||
}}
|
||||
>
|
||||
{t("renovation.panel.sanierung.create")}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -4,8 +4,9 @@
|
||||
import { memo } from "react";
|
||||
import { t } from "../../i18n";
|
||||
import type { RenovationStatus } from "../../model/types";
|
||||
import { RENOVATION_STATUSES } from "../../core";
|
||||
import { useStore } from "../../state/appStore";
|
||||
import { RENOVATION_STATUSES, commonBuildUp, parseBuildUpKey, renovationPair, setBuildUpOps } from "../../core";
|
||||
import { getState, useStore } from "../../state/appStore";
|
||||
import { RenovationStrip } from "../../ui/RenovationStrip";
|
||||
import { useRenovationSelection } from "../../state/renovationHook";
|
||||
import { Dropdown } from "../../ui/Dropdown";
|
||||
|
||||
@@ -44,6 +45,7 @@ export const RenovationField = memo(function RenovationField() {
|
||||
width={150}
|
||||
/>
|
||||
</div>
|
||||
<BuildUpField />
|
||||
{phases.length > 0 && (
|
||||
<div className="objinfo-field" data-testid="objinfo-renovation-phase">
|
||||
<span className="objinfo-flabel">{t("renovation.phase")}</span>
|
||||
@@ -62,3 +64,59 @@ export const RenovationField = memo(function RenovationField() {
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
const NO_TYPES: readonly { id: string; name: string; renovationTarget?: string }[] = [];
|
||||
|
||||
/**
|
||||
* [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.
|
||||
*/
|
||||
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 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]);
|
||||
});
|
||||
const [common, typeId] = JSON.parse(key) as [string | null, string | null];
|
||||
if (common === null || wallIds.length === 0) return null;
|
||||
const own = typeId ? types.find((x) => x.id === typeId) : undefined;
|
||||
const ownTarget = own?.renovationTarget ? types.find((x) => x.id === own.renovationTarget) : undefined;
|
||||
const options = [
|
||||
...(common === "mixed" ? [{ value: MIXED, label: t("renovation.mixed") }] : []),
|
||||
{ value: "", label: t("renovation.buildUp.none") },
|
||||
{ value: "type", label: ownTarget ? t("renovation.buildUp.type", { name: ownTarget.name }) : t("renovation.buildUp.typeMissing") },
|
||||
...types.filter((x) => x.id !== typeId).map((x) => ({ value: `t:${x.id}`, label: t("renovation.buildUp.other", { name: x.name }) })),
|
||||
];
|
||||
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;
|
||||
return (
|
||||
<>
|
||||
<div className="objinfo-field" data-testid="objinfo-renovation-buildup">
|
||||
<span className="objinfo-flabel" title={t("renovation.buildUp.hint")}>
|
||||
{t("renovation.buildUp")}
|
||||
</span>
|
||||
<Dropdown
|
||||
value={value}
|
||||
onChange={(v) => {
|
||||
if (v === MIXED) return;
|
||||
applyChange((p) => setBuildUpOps(p, wallIds, parseBuildUpKey(v)));
|
||||
}}
|
||||
options={options}
|
||||
title={t("renovation.buildUp")}
|
||||
width={150}
|
||||
/>
|
||||
</div>
|
||||
{pair && (
|
||||
<div className="objinfo-field reno-strip-field" data-testid="objinfo-renovation-strip">
|
||||
<RenovationStrip pair={pair} width={140} />
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user