// „Standards aktualisieren" ([109]): Bestätigungs-Overlay (kein window.confirm — im Tauri-WKWebView stumm). // Listet die Standard-Einträge des Projekts, die von der heutigen Bibliothek abweichen, mit den betroffenen // Feldern. Ob ein Eintrag selbst angepasst wurde, lässt sich nicht erkennen: umbenannte Einträge sind // abgewählt, alle anderen vorgewählt; „Alle überschreiben" wählt alles. Regel: `core/src/standards.rs`. import { useEffect, useMemo, useState } from "react"; import { createPortal } from "react-dom"; import type { Project } from "../../model/types"; import { standardsChangeKey, standardsUpdatePlan } from "../../model/standards"; import { t } from "../../i18n"; import { useModalFocus } from "../modalFocus"; const COLLECTION_ORDER = ["components", "hatches", "lineStyles", "wallTypes", "ceilingTypes", "roofTypes", "viewTemplates"]; export function StandardsUpdateDialog({ project, onApply, onClose, }: { project: Project; onApply: (selected: string[]) => void; onClose: () => void; }) { const plan = useMemo(() => standardsUpdatePlan(project), [project]); const [selected, setSelected] = useState>( () => new Set(plan.changes.filter((c) => !c.renamed).map(standardsChangeKey)), ); const dialogRef = useModalFocus({}); useEffect(() => { const onKey = (e: KeyboardEvent) => { if (e.key === "Escape") onClose(); }; window.addEventListener("keydown", onKey); return () => window.removeEventListener("keydown", onKey); }, [onClose]); const toggle = (key: string) => setSelected((s) => { const n = new Set(s); if (n.has(key)) n.delete(key); else n.add(key); return n; }); const groups = COLLECTION_ORDER.map((col) => ({ col, items: plan.changes.filter((c) => c.collection === col) })).filter((g) => g.items.length > 0); const nothing = plan.changes.length === 0 && plan.added === 0; const canApply = selected.size > 0 || plan.added > 0; return createPortal(
e.stopPropagation()}>
{t("resources.updateStandards")}
{nothing ? (
{t("resources.updateStandards.none")}
) : ( <>
{t("resources.updateStandards.intro")}
{plan.added > 0 && (
{t("resources.updateStandards.added", { n: plan.added })}
)}
{groups.map((g) => (
{t(`resources.updateStandards.col.${g.col}`)}
{g.items.map((c) => { const key = standardsChangeKey(c); return ( ); })}
))} )}
, document.body, ); }