[271] Umbau-Panel im Dock: Zeichen-Status, Umbaufilter mit Vorschau, Status der Auswahl, Etappen; schmale Selektoren beheben 45 Renders je Wand-Änderung
This commit is contained in:
19 files changed
+984
-56
No files matched your search
@@ -124,6 +124,7 @@ export { buildCostReport, costGroupLabel, costUnitLabel } from "../export/costRe
|
||||
export {
|
||||
BUILTIN_RENOVATION_FILTERS, RENOVATION_STATUSES, RENOVATION_COLLECTIONS, DEFAULT_RENOVATION_STYLES, renovationFilterList, renovationStatus, renovationPhases,
|
||||
renovationForNew, setRenovationOps, renovatableIds, commonRenovation, setPhasesOps, newPhaseId,
|
||||
renovationFilterShows, renovationStyleOf, idsByRenovationStatus, renovationCounts, phaseUsage,
|
||||
} from "../model/renovation";
|
||||
export type { RenovationFilterEntry, RenovationCollection } from "../model/renovation";
|
||||
export { buildUmbauSampleProject } from "../model/sampleProjectUmbau";
|
||||
@@ -4717,6 +4717,29 @@ export const de = {
|
||||
"renovation.styles.line": "Linie",
|
||||
"renovation.styles.dashed": "gestrichelt",
|
||||
"renovation.styles.reset": "Vorgabe",
|
||||
"renovation.panel.tab": "Umbau",
|
||||
"renovation.panel.draw.hint": "Gilt für alles, was jetzt neu gezeichnet wird.",
|
||||
"renovation.panel.draw.status": "Status neuer Bauteile",
|
||||
"renovation.panel.filter.title": "Umbaufilter dieser Ansicht",
|
||||
"renovation.panel.filter.locked": "Diese Ansicht hat keinen eigenen Umbaufilter.",
|
||||
"renovation.panel.filter.preview": "Darstellung im Filter",
|
||||
"renovation.show.show": "wie gezeichnet",
|
||||
"renovation.show.hide": "ausgeblendet",
|
||||
"renovation.show.override": "Umbau-Farbe",
|
||||
"renovation.panel.selection.title": "Auswahl",
|
||||
"renovation.panel.selection.none": "Keine Bauteile mit Umbau-Status gewählt.",
|
||||
"renovation.panel.selection.count": "{n} Bauteile gewählt",
|
||||
"renovation.panel.set": "Auf {status} setzen",
|
||||
"renovation.panel.selectAll": "Alle {status} wählen ({n})",
|
||||
"renovation.panel.selectBy": "Nach Status wählen",
|
||||
"renovation.panel.selectionPhase": "Etappe der Auswahl",
|
||||
"renovation.panel.phases.name": "Name der Etappe",
|
||||
"renovation.panel.phases.used": "{n} Bauteile",
|
||||
"renovation.panel.phases.deleteTitle": "Etappe löschen",
|
||||
"renovation.panel.phases.deleteMessage": "Etappe „{name}“ löschen? {n} Bauteile verlieren ihre Etappe, ihr Status bleibt.",
|
||||
"renovation.panel.phases.deleteMessageUnused": "Etappe „{name}“ löschen?",
|
||||
"renovation.panel.phases.delete": "Löschen",
|
||||
"renovation.panel.colors": "Umbau-Farben in den Ressourcen …",
|
||||
"resources.tab.renovation": "Umbau",
|
||||
"file.newFromUmbauSample": "Neu aus Vorlage: Beispiel Umbau",
|
||||
"menu.native.newFromUmbauSample": "Beispiel Umbau",
|
||||
|
||||
@@ -4703,6 +4703,29 @@ export const en: Record<TranslationKey, string> = {
|
||||
"renovation.styles.line": "Line",
|
||||
"renovation.styles.dashed": "dashed",
|
||||
"renovation.styles.reset": "Default",
|
||||
"renovation.panel.tab": "Renovation",
|
||||
"renovation.panel.draw.hint": "Applies to everything drawn from now on.",
|
||||
"renovation.panel.draw.status": "Status of new elements",
|
||||
"renovation.panel.filter.title": "Renovation filter of this view",
|
||||
"renovation.panel.filter.locked": "This view has no renovation filter of its own.",
|
||||
"renovation.panel.filter.preview": "Display in the filter",
|
||||
"renovation.show.show": "as drawn",
|
||||
"renovation.show.hide": "hidden",
|
||||
"renovation.show.override": "renovation color",
|
||||
"renovation.panel.selection.title": "Selection",
|
||||
"renovation.panel.selection.none": "No elements with a renovation status selected.",
|
||||
"renovation.panel.selection.count": "{n} elements selected",
|
||||
"renovation.panel.set": "Set to {status}",
|
||||
"renovation.panel.selectAll": "Select all {status} ({n})",
|
||||
"renovation.panel.selectBy": "Select by status",
|
||||
"renovation.panel.selectionPhase": "Phase of the selection",
|
||||
"renovation.panel.phases.name": "Phase name",
|
||||
"renovation.panel.phases.used": "{n} elements",
|
||||
"renovation.panel.phases.deleteTitle": "Delete phase",
|
||||
"renovation.panel.phases.deleteMessage": "Delete phase “{name}”? {n} elements lose their phase; their status stays.",
|
||||
"renovation.panel.phases.deleteMessageUnused": "Delete phase “{name}”?",
|
||||
"renovation.panel.phases.delete": "Delete",
|
||||
"renovation.panel.colors": "Renovation colors in the resources …",
|
||||
"resources.tab.renovation": "Renovation",
|
||||
"file.newFromUmbauSample": "New From Template: Renovation Example",
|
||||
"menu.native.newFromUmbauSample": "Renovation Example",
|
||||
|
||||
@@ -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
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,308 @@
|
||||
// Dock-Panel „Umbau“ ([271], Wunsch Maintainer 17.11., wie Archicads Palette Umbau): Zeichen-Status neuer Bauteile,
|
||||
// Umbaufilter der aktiven Ansicht (mit Vorschau je Status), Status der Auswahl samt „nach Status wählen“ und die
|
||||
// Etappen. Zustand und Aktionen teilt es mit dem Popover der Statusleiste (`state/renovationHook.ts`); Änderungen
|
||||
// gehen als Ops über `applyChange` (ein Undo-Schritt je Aktion).
|
||||
//
|
||||
// Bezeichner englisch, UI-Text/Kommentare deutsch (CONVENTIONS.md).
|
||||
|
||||
import { useState } from "react";
|
||||
import { t } from "../i18n";
|
||||
import type { TranslationKey } from "../i18n";
|
||||
import { useStore } from "../state/appStore";
|
||||
import { renovationFilterLabel, useRenovationControls, useRenovationSelection } from "../state/renovationHook";
|
||||
import {
|
||||
BUILTIN_RENOVATION_FILTERS,
|
||||
newPhaseId,
|
||||
phaseUsage,
|
||||
renovationCounts,
|
||||
renovationFilterShows,
|
||||
renovationStyleOf,
|
||||
RENOVATION_STATUSES,
|
||||
setPhasesOps,
|
||||
} from "../core";
|
||||
import type { Project, RenovationShow, RenovationStatus } from "../model/types";
|
||||
import { ConfirmDialog } from "../ui/ConfirmDialog";
|
||||
import { usePanelHostAction } from "./host";
|
||||
|
||||
const MIXED = "__mixed";
|
||||
|
||||
/** Farbfeld eines Status (SIA-Farbmuster: Füllung, Linie, gestrichelt wie im Plan). */
|
||||
function Swatch({ project, status, show }: { project: Project; status: RenovationStatus; show?: RenovationShow }) {
|
||||
const st = renovationStyleOf(project, status);
|
||||
const hidden = show === "hide";
|
||||
const plain = show === "show";
|
||||
return (
|
||||
<span
|
||||
className={`reno-swatch${hidden ? " is-hidden" : ""}${plain ? " is-plain" : ""}`}
|
||||
style={{
|
||||
background: hidden || plain ? "transparent" : st.fill,
|
||||
borderColor: st.line ?? "rgba(0,0,0,0.45)",
|
||||
borderStyle: st.dashed ? "dashed" : "solid",
|
||||
}}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function ShowChip({ project, status, show }: { project: Project; status: RenovationStatus; show: RenovationShow }) {
|
||||
return (
|
||||
<span className="reno-chip" data-testid={`reno-chip-${status}`} data-show={show}>
|
||||
<Swatch project={project} status={status} show={show} />
|
||||
<span className="reno-chip-text">
|
||||
<span className="reno-chip-status">{t(`renovation.status.${status}` as TranslationKey)}</span>
|
||||
<span className="reno-chip-show">{t(`renovation.show.${show}` as TranslationKey)}</span>
|
||||
</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export function RenovationPanel() {
|
||||
const project = useStore((s) => s.project);
|
||||
const { levelEditable, draw, setDraw, phases, own, filter, filterPhase, setLevel } = useRenovationControls();
|
||||
const sel = useRenovationSelection();
|
||||
const applyChange = useStore((s) => s.applyChange);
|
||||
const openResources = usePanelHostAction("onOpenResources");
|
||||
const [confirmId, setConfirmId] = useState<string | null>(null);
|
||||
const counts = renovationCounts(project, sel.floorId);
|
||||
const shows = filter ? renovationFilterShows(project, filter) : null;
|
||||
const filterIds = ["", ...BUILTIN_RENOVATION_FILTERS, ...own.map((f) => f.id)];
|
||||
|
||||
const statusValue = sel.common.status === "mixed" || sel.common.status === null ? null : sel.common.status;
|
||||
const phaseValue = sel.common.phase === "mixed" ? MIXED : (sel.common.phase ?? "");
|
||||
|
||||
const setPhases = (next: { id: string; name: string }[], key?: string) => applyChange((p) => setPhasesOps(p, next), key);
|
||||
const move = (i: number, d: number) => {
|
||||
const j = i + d;
|
||||
if (j < 0 || j >= phases.length) return;
|
||||
const next = [...phases];
|
||||
[next[i], next[j]] = [next[j], next[i]];
|
||||
setPhases(next);
|
||||
};
|
||||
const confirmPhase = confirmId ? phases.find((p) => p.id === confirmId) : undefined;
|
||||
const confirmUsage = confirmPhase ? phaseUsage(project, confirmPhase.id) : 0;
|
||||
|
||||
return (
|
||||
<section className="reno-panel" data-testid="renovation-dock">
|
||||
{/* Neue Bauteile zeichnen als */}
|
||||
<div className="reno-block">
|
||||
<div className="reno-head">{t("renovation.drawStatus")}</div>
|
||||
<div className="reno-status-row" role="radiogroup" aria-label={t("renovation.panel.draw.status")}>
|
||||
{RENOVATION_STATUSES.map((s) => (
|
||||
<button
|
||||
key={s}
|
||||
type="button"
|
||||
role="radio"
|
||||
aria-checked={draw.status === s}
|
||||
className={`reno-status-btn${draw.status === s ? " active" : ""}`}
|
||||
data-testid={`reno-draw-${s}`}
|
||||
onClick={() => setDraw(s, draw.phase)}
|
||||
>
|
||||
<Swatch project={project} status={s} />
|
||||
<span>{t(`renovation.status.${s}` as TranslationKey)}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{phases.length > 0 && (
|
||||
<label className="reno-field">
|
||||
<span>{t("renovation.phase")}</span>
|
||||
<select value={draw.phase ?? ""} data-testid="reno-draw-phase" onChange={(e) => setDraw(draw.status, e.target.value || undefined)}>
|
||||
<option value="">{t("renovation.phase.none")}</option>
|
||||
{phases.map((p) => (
|
||||
<option key={p.id} value={p.id}>
|
||||
{p.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
<div className="reno-hint">{t("renovation.panel.draw.hint")}</div>
|
||||
</div>
|
||||
|
||||
{/* Umbaufilter der aktiven Ansicht */}
|
||||
<div className="reno-block">
|
||||
<div className="reno-head">{t("renovation.panel.filter.title")}</div>
|
||||
{!levelEditable && <div className="reno-hint">{t("renovation.panel.filter.locked")}</div>}
|
||||
<ul className="reno-filters" role="radiogroup" aria-label={t("renovation.filter")}>
|
||||
{filterIds.map((id) => {
|
||||
const fs = id ? renovationFilterShows(project, id) : null;
|
||||
return (
|
||||
<li key={id || "none"}>
|
||||
<button
|
||||
type="button"
|
||||
role="radio"
|
||||
aria-checked={filter === id}
|
||||
disabled={!levelEditable}
|
||||
className={`reno-filter${filter === id ? " active" : ""}`}
|
||||
data-testid={`reno-filter-${id || "none"}`}
|
||||
onClick={() => setLevel({ renovationFilter: id || undefined, renovationPhase: filterPhase || undefined })}
|
||||
>
|
||||
<span className="reno-filter-name">{id ? renovationFilterLabel(id, own) : t("renovation.filter.none")}</span>
|
||||
<span className="reno-filter-sw">
|
||||
{fs && RENOVATION_STATUSES.map((s) => <Swatch key={s} project={project} status={s} show={fs[s]} />)}
|
||||
</span>
|
||||
</button>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
{phases.length > 0 && filter && (
|
||||
<label className="reno-field">
|
||||
<span>{t("renovation.filterPhase")}</span>
|
||||
<select
|
||||
value={filterPhase}
|
||||
disabled={!levelEditable}
|
||||
data-testid="reno-filter-phase"
|
||||
onChange={(e) => setLevel({ renovationFilter: filter, renovationPhase: e.target.value || undefined })}
|
||||
>
|
||||
<option value="">{t("renovation.phase.all")}</option>
|
||||
{phases.map((p) => (
|
||||
<option key={p.id} value={p.id}>
|
||||
{p.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
{shows && (
|
||||
<div className="reno-preview" aria-label={t("renovation.panel.filter.preview")} data-testid="reno-preview">
|
||||
{RENOVATION_STATUSES.map((s) => (
|
||||
<ShowChip key={s} project={project} status={s} show={shows[s]} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Auswahl */}
|
||||
<div className="reno-block">
|
||||
<div className="reno-head">{t("renovation.panel.selection.title")}</div>
|
||||
{sel.ids.length === 0 ? (
|
||||
<div className="reno-hint" data-testid="reno-sel-none">
|
||||
{t("renovation.panel.selection.none")}
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<div className="reno-sel-state" data-testid="reno-sel-state" data-status={statusValue ?? "mixed"}>
|
||||
{statusValue ? <Swatch project={project} status={statusValue} /> : <span className="reno-swatch is-mixed" aria-hidden="true" />}
|
||||
<span>{statusValue ? t(`renovation.status.${statusValue}` as TranslationKey) : t("renovation.mixed")}</span>
|
||||
<span className="reno-sel-count">{t("renovation.panel.selection.count", { n: String(sel.ids.length) })}</span>
|
||||
</div>
|
||||
<div className="reno-status-row">
|
||||
{RENOVATION_STATUSES.map((s) => (
|
||||
<button
|
||||
key={s}
|
||||
type="button"
|
||||
className={`reno-status-btn small${statusValue === s ? " active" : ""}`}
|
||||
data-testid={`reno-set-${s}`}
|
||||
onClick={() => sel.setStatus(s)}
|
||||
>
|
||||
<Swatch project={project} status={s} />
|
||||
<span>{t("renovation.panel.set", { status: t(`renovation.status.${s}` as TranslationKey) })}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{phases.length > 0 && (
|
||||
<label className="reno-field">
|
||||
<span>{t("renovation.panel.selectionPhase")}</span>
|
||||
<select
|
||||
value={phaseValue}
|
||||
data-testid="reno-sel-phase"
|
||||
onChange={(e) => e.target.value !== MIXED && sel.setPhase(e.target.value || null)}
|
||||
>
|
||||
{phaseValue === MIXED && <option value={MIXED}>{t("renovation.mixed")}</option>}
|
||||
<option value="">{t("renovation.phase.none")}</option>
|
||||
{phases.map((p) => (
|
||||
<option key={p.id} value={p.id}>
|
||||
{p.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
<div className="reno-head sub">{t("renovation.panel.selectBy")}</div>
|
||||
<div className="reno-select-by">
|
||||
{RENOVATION_STATUSES.map((s) => (
|
||||
<button
|
||||
key={s}
|
||||
type="button"
|
||||
className="reno-link-btn"
|
||||
disabled={counts[s] === 0}
|
||||
data-testid={`reno-select-${s}`}
|
||||
onClick={() => sel.selectByStatus(s)}
|
||||
>
|
||||
<Swatch project={project} status={s} />
|
||||
{t("renovation.panel.selectAll", { status: t(`renovation.status.${s}` as TranslationKey), n: String(counts[s]) })}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Etappen */}
|
||||
<div className="reno-block">
|
||||
<div className="reno-head">{t("renovation.phases.title")}</div>
|
||||
{phases.length === 0 && <div className="reno-hint">{t("renovation.phases.empty")}</div>}
|
||||
{phases.map((ph, i) => (
|
||||
<div className="reno-phase-row" key={ph.id} data-testid="reno-phase-row">
|
||||
<input
|
||||
type="text"
|
||||
value={ph.name}
|
||||
aria-label={t("renovation.panel.phases.name")}
|
||||
data-testid="reno-phase-name"
|
||||
onChange={(e) => setPhases(phases.map((x) => (x.id === ph.id ? { ...x, name: e.target.value } : x)), `reno-phase-${ph.id}`)}
|
||||
/>
|
||||
<button type="button" className="reno-icon-btn" disabled={i === 0} title={t("renovation.phases.up")} aria-label={t("renovation.phases.up")} onClick={() => move(i, -1)}>
|
||||
▲
|
||||
</button>
|
||||
<button type="button" className="reno-icon-btn" disabled={i === phases.length - 1} title={t("renovation.phases.down")} aria-label={t("renovation.phases.down")} onClick={() => move(i, 1)}>
|
||||
▼
|
||||
</button>
|
||||
<button type="button" className="reno-icon-btn" title={t("renovation.phases.remove")} aria-label={t("renovation.phases.remove")} data-testid="reno-phase-remove" onClick={() => setConfirmId(ph.id)}>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
<button
|
||||
type="button"
|
||||
className="reno-add-btn"
|
||||
data-testid="reno-phase-add"
|
||||
onClick={() => setPhases([...phases, { id: newPhaseId(project), name: t("renovation.phases.defaultName", { n: String(phases.length + 1) }) }])}
|
||||
>
|
||||
{t("renovation.phases.add")}
|
||||
</button>
|
||||
<button type="button" className="reno-link-btn" data-testid="reno-open-colors" onClick={() => openResources("renovation")}>
|
||||
{t("renovation.panel.colors")}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{confirmPhase && (
|
||||
<ConfirmDialog
|
||||
title={t("renovation.panel.phases.deleteTitle")}
|
||||
message={
|
||||
confirmUsage > 0
|
||||
? t("renovation.panel.phases.deleteMessage", { name: confirmPhase.name, n: String(confirmUsage) })
|
||||
: t("renovation.panel.phases.deleteMessageUnused", { name: confirmPhase.name })
|
||||
}
|
||||
confirmLabel={t("renovation.panel.phases.delete")}
|
||||
danger
|
||||
onClose={() => setConfirmId(null)}
|
||||
onConfirm={() => {
|
||||
setPhases(phases.filter((x) => x.id !== confirmPhase.id));
|
||||
setConfirmId(null);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
/** Reiter-Symbol: Wand in drei Status (voll, gestrichelt, Umriss) — Bestand, Abbruch, Neu. */
|
||||
export function RenovationTabIcon() {
|
||||
return (
|
||||
<svg width={16} height={16} viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth={1.4} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" focusable="false">
|
||||
<rect x="2" y="2.5" width="12" height="3" fill="currentColor" fillOpacity="0.45" />
|
||||
<rect x="2" y="6.5" width="12" height="3" strokeDasharray="2 1.6" />
|
||||
<rect x="2" y="10.5" width="12" height="3" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import { LayoutsPanel, LayoutsTabIcon } from "./LayoutsPanel";
|
||||
import { BcfPanel } from "./BcfPanel";
|
||||
import { ClashPanel } from "./ClashPanel";
|
||||
import { HistoryPanel } from "./HistoryPanel";
|
||||
import { RenovationPanel, RenovationTabIcon } from "./RenovationPanel";
|
||||
import { ObjectSettingsPanel } from "./objectSettings/ObjectSettingsPanel";
|
||||
import {
|
||||
ToolsTabIcon,
|
||||
@@ -59,6 +60,7 @@ export const BUILTIN_PANEL_IDS = {
|
||||
history: "history",
|
||||
objectSettings: "object-settings",
|
||||
objectLibrary: "object-library",
|
||||
renovation: "renovation",
|
||||
} as const;
|
||||
|
||||
// Werkzeug-Palette (Symbol + Name je Werkzeug, ArchiCAD/Vectorworks-Stil).
|
||||
@@ -209,3 +211,13 @@ registerPanel({
|
||||
hasDisplayMode: false,
|
||||
render: () => <ObjectSettingsPanel />,
|
||||
});
|
||||
|
||||
// Umbau ([271], Wunsch Maintainer 17.11.): Zeichen-Status, Umbaufilter der Ansicht, Status der Auswahl, Etappen.
|
||||
// Im Standard-Layout rechts oben neben Objekt-Info und Flächenbilanz.
|
||||
registerPanel({
|
||||
id: BUILTIN_PANEL_IDS.renovation,
|
||||
title: "renovation.panel.tab",
|
||||
icon: <RenovationTabIcon />,
|
||||
hasDisplayMode: false,
|
||||
render: () => <RenovationPanel />,
|
||||
});
|
||||
@@ -45,6 +45,7 @@ import type { TerrainOptions } from "../model/terrain";
|
||||
import type { TextStylePreset } from "../text/richText";
|
||||
import type { ScheduleKind } from "../export/exportSchedule";
|
||||
import type { DetailLevel } from "../model/viewTypes";
|
||||
import type { TabId as ResourceTabId } from "../ui/ResourceManager";
|
||||
|
||||
// ── Darstellungsmodus-Steuerung je Dock-Inhalt ────────────────────────────
|
||||
|
||||
@@ -140,6 +141,8 @@ export interface PanelHostValue {
|
||||
* unter Tauri als natives Fenster, sonst als In-App-Dialog (App.openSettings).
|
||||
* Erreichbar über „Fenster"-Menü (AppMenuBar/native Menüleiste). */
|
||||
onOpenSettings: () => void;
|
||||
/** Öffnet die Ressourcen (unter Tauri das Nebenfenster), optional auf einem Tab, z. B. `"renovation"` ([271]). */
|
||||
onOpenResources: (tab?: ResourceTabId) => void;
|
||||
|
||||
// Ressourcen-Handler (Bauteile / Schraffuren / Linienstile). Spiegelt
|
||||
// ResourceManagerHandlers, hier flach getippt, damit dieses Modul nicht von
|
||||
|
||||
@@ -47,7 +47,8 @@ import type {
|
||||
// Flächenbilanz mit Raumprogramm war nur ~300 px hoch). Die Höhe merkt sich der Gruppen-Splitter (`resizeGroups`).
|
||||
// v14 ([253]): Objekt-Bibliothek ("object-library") als Tab neben den Werkzeugen links oben.
|
||||
// v15 ([253]): links oben (Werkzeuge/Objekte) bekommt mehr Höhe: Gewichte 1,6 : 1 (die Objekt-Palette war im 900-px-Fenster nur ~270 px hoch).
|
||||
export const LAYOUT_VERSION = 15;
|
||||
// v16 ([271]): Umbau-Panel ("renovation") als Tab rechts oben neben Objekt-Info und Flächenbilanz.
|
||||
export const LAYOUT_VERSION = 16;
|
||||
|
||||
/** localStorage-Schlüssel des zuletzt benutzten Layouts. */
|
||||
const CURRENT_KEY = "cad.layout";
|
||||
@@ -79,7 +80,7 @@ const DEFAULT_LEFT_GROUPS: DockGroup[] = [
|
||||
{ tabs: ["attributes"], activeTab: "attributes", weight: 1 },
|
||||
];
|
||||
const DEFAULT_RIGHT_GROUPS: DockGroup[] = [
|
||||
{ tabs: ["object-info", "room-balance"], activeTab: "object-info", weight: 1.6 },
|
||||
{ tabs: ["object-info", "room-balance", "renovation"], activeTab: "object-info", weight: 1.6 },
|
||||
{
|
||||
tabs: ["drawing-levels", "layers", "site", "elements", "view-snapshots", "layouts"],
|
||||
activeTab: "drawing-levels",
|
||||
|
||||
@@ -1,30 +1,23 @@
|
||||
// [271] Objekt-Info und Objekteinstellungen: „Umbau“ — Status (Bestand, Abbruch, Neu) und Etappe der Auswahl.
|
||||
// Mehrfachauswahl: alle gewählten Bauteile in einem Undo-Schritt; verschiedene Werte zeigen „gemischt“.
|
||||
|
||||
import { useMemo } from "react";
|
||||
import { memo } from "react";
|
||||
import { t } from "../../i18n";
|
||||
import type { RenovationStatus } from "../../model/types";
|
||||
import { commonRenovation, renovatableIds, renovationPhases, RENOVATION_STATUSES, setRenovationOps } from "../../core";
|
||||
import { RENOVATION_STATUSES } from "../../core";
|
||||
import { useStore } from "../../state/appStore";
|
||||
import type { Selection } from "../../state/selection";
|
||||
import { useRenovationSelection } from "../../state/renovationHook";
|
||||
import { Dropdown } from "../../ui/Dropdown";
|
||||
|
||||
const NO_PHASES: readonly { id: string; name: string }[] = [];
|
||||
const MIXED = "__mixed";
|
||||
const NO_PHASE = "";
|
||||
|
||||
/** Ids der Auswahl, die einen Umbau-Status tragen (Wände, Öffnungen, Decken, Dächer, Treppen, Stützen, Körper, Räume). */
|
||||
export function selectionRenovationIds(sel: Selection): string[] {
|
||||
return [...sel.walls, ...sel.openings, ...sel.ceilings, ...sel.roofs, ...sel.stairs, ...sel.columns, ...sel.solids, ...sel.rooms];
|
||||
}
|
||||
|
||||
export function RenovationField() {
|
||||
const project = useStore((s) => s.project);
|
||||
const selection = useStore((s) => s.selection);
|
||||
const applyChange = useStore((s) => s.applyChange);
|
||||
const ids = useMemo(() => renovatableIds(project, selectionRenovationIds(selection)), [project, selection]);
|
||||
const common = useMemo(() => commonRenovation(project, ids), [project, ids]);
|
||||
/** `memo`: ohne Props rendert das Feld nur bei geänderter Auswahl/Status neu, nicht bei jeder Op des Eltern-Panels ([121]). */
|
||||
export const RenovationField = memo(function RenovationField() {
|
||||
const phases = useStore((s) => s.project.renovation?.phases) ?? NO_PHASES;
|
||||
const { ids, common, setStatus, setPhase } = useRenovationSelection();
|
||||
if (ids.length === 0) return null;
|
||||
const phases = renovationPhases(project);
|
||||
const statusValue = common.status === "mixed" || common.status === null ? MIXED : common.status;
|
||||
const phaseValue = common.phase === "mixed" ? MIXED : (common.phase ?? NO_PHASE);
|
||||
const statusOptions = [
|
||||
@@ -44,7 +37,7 @@ export function RenovationField() {
|
||||
value={statusValue}
|
||||
onChange={(v) => {
|
||||
if (v === MIXED) return;
|
||||
applyChange((p) => setRenovationOps(p, ids, v as RenovationStatus));
|
||||
setStatus(v as RenovationStatus);
|
||||
}}
|
||||
options={statusOptions}
|
||||
title={t("renovation.label")}
|
||||
@@ -58,7 +51,7 @@ export function RenovationField() {
|
||||
value={phaseValue}
|
||||
onChange={(v) => {
|
||||
if (v === MIXED) return;
|
||||
applyChange((p) => setRenovationOps(p, ids, undefined, v === NO_PHASE ? null : v));
|
||||
setPhase(v === NO_PHASE ? null : v);
|
||||
}}
|
||||
options={phaseOptions}
|
||||
title={t("renovation.phase")}
|
||||
@@ -68,4 +61,4 @@ export function RenovationField() {
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -9,7 +9,7 @@ import { openLevel } from "../tabNavigation";
|
||||
import type { FlatHostOpts, HostPart } from "./types";
|
||||
|
||||
export function buildToolsHost(c: FlatHostOpts) {
|
||||
const { activeCategoryCode, activeLevel, activeLevelId, activeTool, activeWallTypeId, addCategory, addCeiling, addCeilingType, addComponent, addDrawing, addElevation, addFloor, addHatch, addLineStyle, addRoofType, addSection, addTextStyle, addWallType, deleteCeilingType, deleteComponent, deleteHatch, deleteLineStyle, deleteRoofType, deleteTextStyle, deleteWallType, engineView, importHatches, importLineStyles, onRunCommand, onSelectTool, openLayerSettings, openSettings, patchCeilingType, patchComponent, patchHatch, patchLineStyle, patchRoofType, patchTextStyle, patchWallType, setActiveCategoryCode, setActiveWallTypeId, setMenu, setSnap, snap, toggleCategoryVisible, toggleLevelVisible } = c;
|
||||
const { activeCategoryCode, activeLevel, activeLevelId, activeTool, activeWallTypeId, addCategory, addCeiling, addCeilingType, addComponent, addDrawing, addElevation, addFloor, addHatch, addLineStyle, addRoofType, addSection, addTextStyle, addWallType, deleteCeilingType, deleteComponent, deleteHatch, deleteLineStyle, deleteRoofType, deleteTextStyle, deleteWallType, engineView, importHatches, importLineStyles, onRunCommand, onSelectTool, openLayerSettings, openResources, openSettings, patchCeilingType, patchComponent, patchHatch, patchLineStyle, patchRoofType, patchTextStyle, patchWallType, setActiveCategoryCode, setActiveWallTypeId, setMenu, setSnap, snap, toggleCategoryVisible, toggleLevelVisible } = c;
|
||||
return {
|
||||
activeLevelId,
|
||||
activeTool,
|
||||
@@ -44,6 +44,7 @@ export function buildToolsHost(c: FlatHostOpts) {
|
||||
if (isTauriRuntime()) void openDrawingLevelsWindowNative();
|
||||
},
|
||||
onOpenSettings: () => openSettings(),
|
||||
onOpenResources: (tab) => openResources(tab),
|
||||
onPatchComponent: patchComponent,
|
||||
onAddComponent: addComponent,
|
||||
onDeleteComponent: deleteComponent,
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
// [271] Umbau: gemeinsamer Zustand und gemeinsame Aktionen für das Dock-Panel „Umbau“ und das Statusleisten-Popover
|
||||
// (ein Ort, keine Doppelspur): Zeichen-Status neuer Bauteile, Umbaufilter und Etappe der aktiven Ansicht (Felder der
|
||||
// Zeichnungsebene wie die Modelldarstellung [173], darum je Reiter eigen und mit Undo), Status der Auswahl.
|
||||
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { t } from "../i18n";
|
||||
import type { TranslationKey } from "../i18n";
|
||||
import { getState, useStore } from "./appStore";
|
||||
import { EMPTY_SELECTION } from "./selection";
|
||||
import type { Selection } from "./selection";
|
||||
import {
|
||||
BUILTIN_RENOVATION_FILTERS,
|
||||
commonRenovation,
|
||||
idsByRenovationStatus,
|
||||
patchItem,
|
||||
setRenovationOps,
|
||||
} from "../core";
|
||||
import type { RenovationStatus } from "../model/types";
|
||||
|
||||
/** Anzeigename eines Filters (eingebaut übersetzt, eigene mit ihrem Namen). */
|
||||
export function renovationFilterLabel(id: string, own: readonly { id: string; name: string }[]): string {
|
||||
if ((BUILTIN_RENOVATION_FILTERS as readonly string[]).includes(id)) return t(`renovation.filter.${id}` as TranslationKey);
|
||||
return own.find((f) => f.id === id)?.name ?? id;
|
||||
}
|
||||
|
||||
/** Ids der Auswahl, die einen Umbau-Status tragen (Wände, Öffnungen, Decken, Dächer, Treppen, Stützen, Körper, Räume). */
|
||||
export function selectionRenovationIds(sel: Selection): string[] {
|
||||
return [...sel.walls, ...sel.openings, ...sel.ceilings, ...sel.roofs, ...sel.stairs, ...sel.columns, ...sel.solids, ...sel.rooms];
|
||||
}
|
||||
|
||||
const NO_PHASES: readonly { id: string; name: string }[] = [];
|
||||
const NO_FILTERS: readonly { id: string; name: string }[] = [];
|
||||
|
||||
/**
|
||||
* Zeichen-Status, Filter/Etappe der aktiven Ansicht und deren Setzer. Liest bewusst nur schmale Teile des Projekts
|
||||
* (Ebene, Etappen, eigene Filter), damit Statusleiste und Panel nicht bei jeder Op neu rendern ([121]).
|
||||
*/
|
||||
export function useRenovationControls() {
|
||||
const level = useStore((s) => s.project.drawingLevels.find((l) => l.id === s.activeLevelId));
|
||||
const rPhases = useStore((s) => s.project.renovation?.phases);
|
||||
const rFilters = useStore((s) => s.project.renovation?.filters);
|
||||
const draw = useStore((s) => s.drawRenovation);
|
||||
const setDraw = useStore((s) => s.setDrawRenovation);
|
||||
const applyChange = useStore((s) => s.applyChange);
|
||||
const phases = rPhases ?? NO_PHASES;
|
||||
const own = rFilters ?? NO_FILTERS;
|
||||
const filter = level?.renovationFilter ?? "";
|
||||
const levelEditable = !!level && (level.kind === "floor" || level.kind === "section" || level.kind === "elevation" || level.kind === "ceiling");
|
||||
const setLevel = useCallback(
|
||||
(patch: { renovationFilter?: string; renovationPhase?: string }) => {
|
||||
if (!level) return;
|
||||
applyChange((p) =>
|
||||
patchItem(p, "drawingLevels", level.id, (l) => {
|
||||
const next = { ...l, ...patch };
|
||||
if (!next.renovationFilter) delete next.renovationFilter;
|
||||
if (!next.renovationPhase || !next.renovationFilter) delete next.renovationPhase;
|
||||
return next;
|
||||
}),
|
||||
);
|
||||
},
|
||||
[level, applyChange],
|
||||
);
|
||||
return { level, levelEditable, draw, setDraw, phases, own, filter, filterPhase: level?.renovationPhase ?? "", setLevel };
|
||||
}
|
||||
|
||||
/** Status der Auswahl und Aktionen darauf (setzen: ein Undo-Schritt; nach Status wählen). Ohne Projekt-Abonnement. */
|
||||
export function useRenovationSelection() {
|
||||
const selection = useStore((s) => s.selection);
|
||||
const applyChange = useStore((s) => s.applyChange);
|
||||
const setSelection = useStore((s) => s.setSelection);
|
||||
const ids = useMemo(() => selectionRenovationIds(selection), [selection]);
|
||||
// Gemeinsamer Status/Etappe als Text: rendert nur bei echter Änderung neu, nicht bei jeder Op.
|
||||
const key = useStore((s) => JSON.stringify(commonRenovation(s.project, selectionRenovationIds(s.selection))));
|
||||
const common = useMemo(() => JSON.parse(key) as ReturnType<typeof commonRenovation>, [key]);
|
||||
const floorId = useStore((s) => (s.project.drawingLevels.find((l) => l.id === s.activeLevelId)?.kind === "floor" ? s.activeLevelId : null));
|
||||
const setStatus = (status: RenovationStatus) => applyChange((p) => setRenovationOps(p, ids, status));
|
||||
const setPhase = (phase: string | null) => applyChange((p) => setRenovationOps(p, ids, undefined, phase));
|
||||
/** Alle Bauteile des Geschosses mit Status `status` wählen; liefert die Zahl. */
|
||||
const selectByStatus = (status: RenovationStatus) => {
|
||||
const found = idsByRenovationStatus(getState().project, status, { floorId });
|
||||
setSelection({ ...EMPTY_SELECTION, ...found });
|
||||
return Object.values(found).reduce((a, v) => a + v.length, 0);
|
||||
};
|
||||
return { ids, common, floorId, setStatus, setPhase, selectByStatus };
|
||||
}
|
||||
+242
@@ -9656,3 +9656,245 @@ body {
|
||||
}
|
||||
.quick-guide-body hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
|
||||
.quick-guide-body img { display: block; max-width: 100%; height: auto; margin: 6px 0 12px; background: #fff; border: 1px solid var(--line); }
|
||||
|
||||
/* ── [271] Dock-Panel „Umbau“ ─────────────────────────────────────────────────────────────────────── */
|
||||
.reno-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
padding: 4px 8px 10px;
|
||||
font-size: 12px;
|
||||
color: var(--ink);
|
||||
}
|
||||
.reno-block {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
padding: 6px 0;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.reno-block:last-of-type {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.reno-head {
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--muted);
|
||||
}
|
||||
.reno-head.sub {
|
||||
margin-top: 4px;
|
||||
}
|
||||
.reno-hint {
|
||||
color: var(--ink-2);
|
||||
font-size: 11px;
|
||||
}
|
||||
.reno-swatch {
|
||||
display: inline-block;
|
||||
flex: 0 0 auto;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
box-sizing: border-box;
|
||||
border: 1.5px solid rgba(0, 0, 0, 0.45);
|
||||
border-radius: 3px;
|
||||
}
|
||||
.reno-swatch.is-plain {
|
||||
border-color: var(--ink-2) !important;
|
||||
border-style: solid !important;
|
||||
}
|
||||
.reno-swatch.is-hidden {
|
||||
border-style: dotted !important;
|
||||
border-color: var(--muted) !important;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.reno-swatch.is-mixed {
|
||||
background: repeating-linear-gradient(45deg, #a6a6a6 0 3px, #ffd800 3px 6px, #e3001b 6px 9px);
|
||||
}
|
||||
.reno-status-row {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.reno-status-btn {
|
||||
flex: 1 1 70px;
|
||||
min-height: 30px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
padding: 3px 8px;
|
||||
font: inherit;
|
||||
font-weight: 600;
|
||||
color: var(--ink);
|
||||
background: var(--input);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.reno-status-btn.small {
|
||||
min-height: 28px;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.reno-status-btn:hover {
|
||||
border-color: var(--accent-border);
|
||||
}
|
||||
.reno-status-btn.active {
|
||||
background: var(--active-dim);
|
||||
border-color: var(--active);
|
||||
box-shadow: inset 0 0 0 1px var(--active);
|
||||
}
|
||||
.reno-field {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
.reno-field select,
|
||||
.reno-phase-row input {
|
||||
min-width: 0;
|
||||
flex: 1 1 auto;
|
||||
max-width: 160px;
|
||||
font: inherit;
|
||||
color: var(--ink);
|
||||
background: var(--input);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
padding: 3px 6px;
|
||||
}
|
||||
.reno-filters {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
.reno-filter {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
padding: 2px 8px;
|
||||
font: inherit;
|
||||
color: var(--ink);
|
||||
background: transparent;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
}
|
||||
.reno-filter:hover:not(:disabled) {
|
||||
background: var(--accent-dim);
|
||||
}
|
||||
.reno-filter.active {
|
||||
background: var(--active-dim);
|
||||
border-color: var(--active);
|
||||
font-weight: 600;
|
||||
}
|
||||
.reno-filter:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: default;
|
||||
}
|
||||
.reno-filter-sw {
|
||||
display: inline-flex;
|
||||
gap: 3px;
|
||||
}
|
||||
.reno-preview {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
padding: 4px 8px;
|
||||
background: var(--accent-dim);
|
||||
border-radius: 8px;
|
||||
}
|
||||
.reno-chip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 11px;
|
||||
}
|
||||
.reno-chip-text {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
flex: 1 1 auto;
|
||||
gap: 8px;
|
||||
}
|
||||
.reno-chip-show {
|
||||
color: var(--ink-2);
|
||||
}
|
||||
.reno-sel-state {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.reno-sel-count {
|
||||
margin-left: auto;
|
||||
font-weight: 400;
|
||||
color: var(--ink-2);
|
||||
}
|
||||
.reno-select-by {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
.reno-link-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 3px 6px;
|
||||
font: inherit;
|
||||
color: var(--ink);
|
||||
background: transparent;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
}
|
||||
.reno-link-btn:hover:not(:disabled) {
|
||||
background: var(--accent-dim);
|
||||
}
|
||||
.reno-link-btn:disabled {
|
||||
opacity: 0.45;
|
||||
cursor: default;
|
||||
}
|
||||
.reno-phase-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
.reno-phase-row input {
|
||||
max-width: none;
|
||||
}
|
||||
.reno-icon-btn {
|
||||
flex: 0 0 auto;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
font-size: 10px;
|
||||
color: var(--ink-2);
|
||||
background: transparent;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.reno-icon-btn:hover:not(:disabled) {
|
||||
border-color: var(--accent-border);
|
||||
color: var(--ink);
|
||||
}
|
||||
.reno-icon-btn:disabled {
|
||||
opacity: 0.35;
|
||||
cursor: default;
|
||||
}
|
||||
.reno-add-btn {
|
||||
align-self: flex-start;
|
||||
padding: 4px 10px;
|
||||
font: inherit;
|
||||
color: var(--ink);
|
||||
background: var(--input);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 999px;
|
||||
cursor: pointer;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// Allgemeine Rückfrage als Overlay-Dialog (Ersatz für `window.confirm`, im Tauri-WKWebView stumm). Muster wie
|
||||
// `PromptDialog`: abgedunkeltes Overlay, Klick daneben und Esc schliessen. Gerendert im Body-Portal, damit Panels mit
|
||||
// eigener Überlagerung ihn nicht beschneiden.
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import { t } from "../i18n";
|
||||
import { useModalFocus } from "./modalFocus";
|
||||
|
||||
export interface ConfirmDialogProps {
|
||||
title: string;
|
||||
message: string;
|
||||
/** Beschriftung des bestätigenden Knopfs (z. B. „Löschen“). */
|
||||
confirmLabel: string;
|
||||
/** Riskante Aktion: bestätigender Knopf mit roter Kontur. */
|
||||
danger?: boolean;
|
||||
onConfirm: () => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export function ConfirmDialog({ title, message, confirmLabel, danger, onConfirm, onClose }: ConfirmDialogProps) {
|
||||
const dialogRef = useModalFocus({});
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.key === "Escape") onClose();
|
||||
};
|
||||
window.addEventListener("keydown", onKey);
|
||||
return () => window.removeEventListener("keydown", onKey);
|
||||
}, [onClose]);
|
||||
return createPortal(
|
||||
<div className="imp-overlay" onClick={onClose}>
|
||||
<div className="imp-dialog" ref={dialogRef} role="alertdialog" aria-modal="true" aria-label={title} data-testid="confirm-dialog" onClick={(e) => e.stopPropagation()}>
|
||||
<header className="imp-head">
|
||||
<span className="imp-head-title">{title}</span>
|
||||
<button className="imp-close" onClick={onClose} aria-label={t("export.close")}>
|
||||
×
|
||||
</button>
|
||||
</header>
|
||||
<div className="imp-body">
|
||||
<section className="imp-section">{message}</section>
|
||||
</div>
|
||||
<footer className="imp-foot">
|
||||
<button className="imp-btn" onClick={onClose}>
|
||||
{t("export.cancel")}
|
||||
</button>
|
||||
<button className={`imp-btn ${danger ? "danger" : "primary"}`} data-autofocus data-testid="confirm-dialog-ok" onClick={onConfirm}>
|
||||
{confirmLabel}
|
||||
</button>
|
||||
</footer>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
);
|
||||
}
|
||||
@@ -3,25 +3,17 @@
|
||||
// Modelldarstellung ein Feld der Ebene, darum je Reiter/Ausschnitt eigen und mit Undo). Bei wenig Platz wandert es
|
||||
// mit der Pausfolie in „⋯“ ([263]).
|
||||
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { t } from "../i18n";
|
||||
import type { TranslationKey } from "../i18n";
|
||||
import { useStore } from "../state/appStore";
|
||||
import { BUILTIN_RENOVATION_FILTERS, patchItem, renovationPhases, RENOVATION_STATUSES } from "../core";
|
||||
import { renovationFilterLabel, useRenovationControls } from "../state/renovationHook";
|
||||
import { BUILTIN_RENOVATION_FILTERS, RENOVATION_STATUSES } from "../core";
|
||||
import type { RenovationStatus } from "../model/types";
|
||||
|
||||
/** Anzeigename eines Filters (eingebaut übersetzt, eigene mit ihrem Namen). */
|
||||
export function renovationFilterLabel(id: string, own: readonly { id: string; name: string }[]): string {
|
||||
if ((BUILTIN_RENOVATION_FILTERS as readonly string[]).includes(id)) return t(`renovation.filter.${id}` as TranslationKey);
|
||||
return own.find((f) => f.id === id)?.name ?? id;
|
||||
}
|
||||
export { renovationFilterLabel };
|
||||
|
||||
export function RenovationControl() {
|
||||
const project = useStore((s) => s.project);
|
||||
const activeLevelId = useStore((s) => s.activeLevelId);
|
||||
const draw = useStore((s) => s.drawRenovation);
|
||||
const setDraw = useStore((s) => s.setDrawRenovation);
|
||||
const applyChange = useStore((s) => s.applyChange);
|
||||
const { draw, setDraw, phases, own, filter, filterPhase, levelEditable, setLevel } = useRenovationControls();
|
||||
const [open, setOpen] = useState(false);
|
||||
const wrapRef = useRef<HTMLSpanElement | null>(null);
|
||||
useEffect(() => {
|
||||
@@ -37,22 +29,6 @@ export function RenovationControl() {
|
||||
document.removeEventListener("keydown", onKey);
|
||||
};
|
||||
}, [open]);
|
||||
const level = project.drawingLevels.find((l) => l.id === activeLevelId);
|
||||
const phases = renovationPhases(project);
|
||||
const own = useMemo(() => project.renovation?.filters ?? [], [project.renovation?.filters]);
|
||||
const filter = level?.renovationFilter ?? "";
|
||||
const levelEditable = !!level && (level.kind === "floor" || level.kind === "section" || level.kind === "elevation" || level.kind === "ceiling");
|
||||
const setLevel = (patch: { renovationFilter?: string; renovationPhase?: string }) => {
|
||||
if (!level) return;
|
||||
applyChange((p) =>
|
||||
patchItem(p, "drawingLevels", level.id, (l) => {
|
||||
const next = { ...l, ...patch };
|
||||
if (!next.renovationFilter) delete next.renovationFilter;
|
||||
if (!next.renovationPhase || !next.renovationFilter) delete next.renovationPhase;
|
||||
return next;
|
||||
}),
|
||||
);
|
||||
};
|
||||
const statusLabel = t(`renovation.status.${draw.status}` as TranslationKey);
|
||||
const filterLabel = filter ? renovationFilterLabel(filter, own) : t("renovation.filter.none");
|
||||
return (
|
||||
@@ -108,7 +84,7 @@ export function RenovationControl() {
|
||||
disabled={!levelEditable}
|
||||
aria-label={t("renovation.filter")}
|
||||
data-testid="renovation-filter"
|
||||
onChange={(e) => setLevel({ renovationFilter: e.target.value || undefined, renovationPhase: level?.renovationPhase })}
|
||||
onChange={(e) => setLevel({ renovationFilter: e.target.value || undefined, renovationPhase: filterPhase || undefined })}
|
||||
>
|
||||
<option value="">{t("renovation.filter.none")}</option>
|
||||
{BUILTIN_RENOVATION_FILTERS.map((id) => (
|
||||
@@ -127,7 +103,7 @@ export function RenovationControl() {
|
||||
<label className="sb-snap-row sb-snap-row-num">
|
||||
<span>{t("renovation.filterPhase")}</span>
|
||||
<select
|
||||
value={level?.renovationPhase ?? ""}
|
||||
value={filterPhase}
|
||||
aria-label={t("renovation.filterPhase")}
|
||||
onChange={(e) => setLevel({ renovationFilter: filter, renovationPhase: e.target.value || undefined })}
|
||||
>
|
||||
|
||||
Reference in new issue
Block a user