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

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

No files matched your search

+54
View File
@@ -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,
);
}
+7 -31
View File
@@ -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 })}
>