[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

+2 -1
View File
@@ -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,
+85
View File
@@ -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 };
}