Merge [272] Varianten (mit Umbau-Panel zusammengeführt, Import selectionRenovationIds aus state/renovationHook)
This commit is contained in:
73 files changed
+2979
-100
No files matched your search
@@ -26,6 +26,7 @@ export interface AppMenuBarProps {
|
||||
onNewProjectFromComplexSample: () => void;
|
||||
onNewProjectFromWettbewerbSample: () => void;
|
||||
onNewProjectFromUmbauSample?: () => void;
|
||||
onNewProjectFromVariantenSample?: () => void;
|
||||
onNewProjectFromTemplate: () => void;
|
||||
onOpenProject: () => void;
|
||||
onSaveProject: () => void;
|
||||
@@ -68,6 +69,8 @@ export interface AppMenuBarProps {
|
||||
onOpenBcf?: () => void;
|
||||
/** Verlauf-Panel öffnen ([84]). */
|
||||
onOpenHistory?: () => void;
|
||||
/** [272] Panel „Varianten“ öffnen. */
|
||||
onOpenDesignOptions?: () => void;
|
||||
}
|
||||
|
||||
/** Menüleiste (Bearbeiten/Ansicht/Fenster) — sitzt in der TopBar neben der Wortmarke. */
|
||||
@@ -77,6 +80,7 @@ export const AppMenuBar = memo(function AppMenuBar({
|
||||
onNewProjectFromComplexSample,
|
||||
onNewProjectFromWettbewerbSample,
|
||||
onNewProjectFromUmbauSample,
|
||||
onNewProjectFromVariantenSample,
|
||||
onNewProjectFromTemplate,
|
||||
onOpenProject,
|
||||
onSaveProject,
|
||||
@@ -107,6 +111,7 @@ export const AppMenuBar = memo(function AppMenuBar({
|
||||
onOpenSettings,
|
||||
onOpenBcf,
|
||||
onOpenHistory,
|
||||
onOpenDesignOptions,
|
||||
}: AppMenuBarProps) {
|
||||
const fileItems: DropdownItem[] = [
|
||||
{ label: t("file.new"), onSelect: onNewProject },
|
||||
@@ -114,6 +119,7 @@ export const AppMenuBar = memo(function AppMenuBar({
|
||||
{ label: t("file.newFromComplexSample"), onSelect: onNewProjectFromComplexSample },
|
||||
{ label: t("file.newFromWettbewerbSample"), onSelect: onNewProjectFromWettbewerbSample },
|
||||
...(onNewProjectFromUmbauSample ? [{ label: t("file.newFromUmbauSample"), onSelect: onNewProjectFromUmbauSample }] : []),
|
||||
...(onNewProjectFromVariantenSample ? [{ label: t("file.newFromVariantenSample"), onSelect: onNewProjectFromVariantenSample }] : []),
|
||||
{ label: t("file.newFromTemplateFile"), onSelect: onNewProjectFromTemplate },
|
||||
{ divider: true },
|
||||
{ label: t("file.open"), onSelect: onOpenProject },
|
||||
@@ -136,6 +142,7 @@ export const AppMenuBar = memo(function AppMenuBar({
|
||||
{ label: t("menu.edit.undo"), onSelect: onUndo, disabled: !canUndo },
|
||||
{ label: t("menu.edit.redo"), onSelect: onRedo, disabled: !canRedo },
|
||||
...(onOpenHistory ? [{ label: t("nav.history"), onSelect: onOpenHistory }] : []),
|
||||
...(onOpenDesignOptions ? [{ label: t("designOption.title"), onSelect: onOpenDesignOptions }] : []),
|
||||
{ divider: true },
|
||||
{
|
||||
label: t("menu.edit.delete"),
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// [272] Chip „Variante: …“ in der Statusleiste (neben „Umbau“): zeigt die Variantenkombination der aktiven Ansicht (nur die
|
||||
// Abweichungen von den Hauptvarianten) und öffnet per Klick das Panel „Varianten“, in dem man sie einstellt. Nur sichtbar,
|
||||
// wenn das Projekt Variantensätze hat; bei wenig Platz wandert es mit Pausfolie und „Umbau“ in „⋯“ ([263]).
|
||||
|
||||
import { t } from "../i18n";
|
||||
import { useStore } from "../state/appStore";
|
||||
import { combinationSuffix, designOptionTargets } from "../core";
|
||||
|
||||
export function DesignOptionControl() {
|
||||
const project = useStore((s) => s.project);
|
||||
const activeLevelId = useStore((s) => s.activeLevelId);
|
||||
const draw = useStore((s) => s.drawDesignOption);
|
||||
if (!project.designOptionSets?.length) return null;
|
||||
const level = project.drawingLevels.find((l) => l.id === activeLevelId);
|
||||
const suffix = combinationSuffix(project, level?.designOptions);
|
||||
const drawKey = draw ? `${draw.set}/${draw.option}` : "";
|
||||
const drawLabel = designOptionTargets(project).find((x) => x.key === drawKey)?.label ?? t("designOption.main");
|
||||
const shown = suffix || t("designOption.primaryCombination");
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className={`sb-toggle${suffix || draw ? " sb-renovation-on" : ""}`}
|
||||
data-testid="design-option-toggle"
|
||||
title={t("designOption.hint", { combination: shown, draw: drawLabel })}
|
||||
onClick={() => window.dispatchEvent(new CustomEvent("dossier:reveal-panel", { detail: "design-options" }))}
|
||||
>
|
||||
{t("designOption.short", { combination: shown })}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
+31
-6
@@ -44,7 +44,7 @@ import {
|
||||
type GuideHit,
|
||||
} from "./sheetSnap";
|
||||
import { createLayoutImage, imageAspect, imageGeometry } from "../model/layoutImages";
|
||||
import { posterHeaderItems, viewportScaleLabel } from "../model/posterTemplates";
|
||||
import { posterHeaderItems, viewportScaleLabel, viewportVariantLabel } from "../model/posterTemplates";
|
||||
import { planToPrintSvg } from "../export/planToPrintSvg";
|
||||
import { legendPlan, legendPrintSvg } from "../export/legendSvg";
|
||||
import { legendBox, legendEntries, legendKeysOfViewports, type LegendKind } from "../analysis/legend";
|
||||
@@ -111,7 +111,8 @@ export function ViewportPlanSvg({
|
||||
// Massstab ZUERST: er geht in die Plan-Erzeugung ein (Bemassung in Papier-mm, s. model/dimension.ts).
|
||||
const scaleN = resolveViewportScale(viewport, snap);
|
||||
// Geschoss/Zeichnung wie bisher; Schnitt/Ansicht über die abgeleitete Projektion ([115], Schnitt asynchron).
|
||||
void viewportSnapshotPlan(project, snap, codes, scaleN)
|
||||
// [272] Eigene Variantenkombination des Viewports (dieselbe Ansicht in anderer Kombination).
|
||||
void viewportSnapshotPlan(project, snap, codes, scaleN, false, viewport)
|
||||
.then((plan) => {
|
||||
if (disposed) return;
|
||||
const print = planToPrintSvg(plan, {
|
||||
@@ -130,7 +131,7 @@ export function ViewportPlanSvg({
|
||||
return () => {
|
||||
disposed = true;
|
||||
};
|
||||
}, [project, viewport.snapshotId, viewport.widthMm, viewport.heightMm, viewport.scaleDenominator, viewport.center?.x, viewport.center?.y]);
|
||||
}, [project, viewport.snapshotId, viewport.widthMm, viewport.heightMm, viewport.scaleDenominator, viewport.center?.x, viewport.center?.y, viewport.designOptions]);
|
||||
// Lage/Grösse über die Attribute des inneren SVG (folgt auch dem Ghost beim Ziehen).
|
||||
useEffect(() => {
|
||||
if (ref.current) placeInner(ref.current, rect);
|
||||
@@ -803,9 +804,9 @@ export function LayoutSheetPane({
|
||||
);
|
||||
})}
|
||||
{/* Massstab unter jedem Viewport (Master „Massstabsangaben"). */}
|
||||
{master?.viewportScaleLabels &&
|
||||
layout.viewports.map((vp) => {
|
||||
const l = viewportScaleLabel(project, vp, sheet);
|
||||
{layout.viewports.map((vp) => {
|
||||
// [272] Ohne Massstabsangaben des Masters nur der Titelzusatz der Varianten (falls abweichend).
|
||||
const l = master?.viewportScaleLabels ? viewportScaleLabel(project, vp, sheet) : viewportVariantLabel(project, vp, sheet);
|
||||
return l ? (
|
||||
<text key={`sl-${vp.id}`} x={l.x} y={l.y} fontSize={l.sizeMm} fontFamily="Helvetica, Arial, sans-serif" fill="#111111" pointerEvents="none" data-scale-label>
|
||||
{l.text}
|
||||
@@ -1217,6 +1218,30 @@ export function LayoutSheetPane({
|
||||
/>
|
||||
</span>
|
||||
</label>
|
||||
{/* [272] Eigene Variantenkombination des Viewports: dieselbe Ansicht in anderer Kombination (Titelzusatz). */}
|
||||
{(project.designOptionSets ?? []).map((s) => (
|
||||
<label key={s.id} className="layout-sheet-hud-row">
|
||||
<span>{s.name}</span>
|
||||
<select
|
||||
className="res-input"
|
||||
data-testid={`vp-design-option-${s.id}`}
|
||||
value={selectedVp.designOptions?.[s.id] ?? ""}
|
||||
onChange={(e) => {
|
||||
const next = { ...(selectedVp.designOptions ?? {}) };
|
||||
if (e.target.value) next[s.id] = e.target.value;
|
||||
else delete next[s.id];
|
||||
handlers.onPatchViewport(selectedVp.id, { designOptions: Object.keys(next).length ? next : undefined });
|
||||
}}
|
||||
>
|
||||
<option value="">{t("designOption.fromSnapshot")}</option>
|
||||
{s.options.map((o) => (
|
||||
<option key={o.id} value={o.id}>
|
||||
{o.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
))}
|
||||
<div className="layout-sheet-hud-size">
|
||||
{Math.round(selectedVp.widthMm)} × {Math.round(selectedVp.heightMm)} mm
|
||||
</div>
|
||||
|
||||
@@ -48,6 +48,8 @@ import { ModelViewsTab } from "./resourceManager/ModelViewsTab";
|
||||
import type { ModelViewHandlers } from "./resourceManager/ModelViewsTab";
|
||||
import { RenovationTab } from "./resourceManager/RenovationTab";
|
||||
import type { RenovationHandlers } from "./resourceManager/RenovationTab";
|
||||
import { DesignOptionsTab } from "./resourceManager/DesignOptionsTab";
|
||||
import type { DesignOptionHandlers } from "./resourceManager/DesignOptionsTab";
|
||||
import { PenSetsTab } from "./resourceManager/PenSetsTab";
|
||||
import { PalettesTab } from "./resourceManager/PalettesTab";
|
||||
import { TextStylesTab } from "./resourceManager/TextStylesTab";
|
||||
@@ -72,6 +74,7 @@ export type TabId =
|
||||
| "viewTemplates"
|
||||
| "modelViews"
|
||||
| "renovation"
|
||||
| "designOptions"
|
||||
| "pens"
|
||||
| "palettes";
|
||||
|
||||
@@ -93,10 +96,11 @@ const TABS: { id: TabId; labelKey: string }[] = [
|
||||
{ id: "viewTemplates", labelKey: "resources.tab.viewTemplates" },
|
||||
{ id: "modelViews", labelKey: "resources.tab.modelViews" },
|
||||
{ id: "renovation", labelKey: "resources.tab.renovation" },
|
||||
{ id: "designOptions", labelKey: "resources.tab.designOptions" },
|
||||
];
|
||||
|
||||
/** Bündel der immutablen Mutationen (von App über setProject bereitgestellt). */
|
||||
export interface ResourceManagerHandlers extends ViewTemplateHandlers, ModelViewHandlers, RenovationHandlers {
|
||||
export interface ResourceManagerHandlers extends ViewTemplateHandlers, ModelViewHandlers, RenovationHandlers, DesignOptionHandlers {
|
||||
onPatchComponent: (id: string, patch: Partial<Component>) => void;
|
||||
onAddComponent: () => void;
|
||||
onDeleteComponent: (id: string) => void;
|
||||
@@ -496,6 +500,7 @@ export function ResourceManager({
|
||||
{tab === "viewTemplates" && <ViewTemplatesTab project={project} handlers={handlers} />}
|
||||
{tab === "modelViews" && <ModelViewsTab project={project} handlers={handlers} />}
|
||||
{tab === "renovation" && <RenovationTab project={project} handlers={handlers} />}
|
||||
{tab === "designOptions" && <DesignOptionsTab project={project} handlers={handlers} />}
|
||||
{tab === "overrides" && (
|
||||
<OverridesTab
|
||||
project={project}
|
||||
|
||||
+12
-1
@@ -16,6 +16,8 @@ import type { SnapSettings } from "../tools/types";
|
||||
import { t } from "../i18n";
|
||||
import { TraceControl } from "./TraceControl";
|
||||
import { RenovationControl } from "./RenovationControl";
|
||||
import { DesignOptionControl } from "./DesignOptionControl";
|
||||
import { useStore } from "../state/appStore";
|
||||
import { BUILD_INFO, formatBuildShort } from "../update/buildInfo";
|
||||
|
||||
export interface StatusBarProps {
|
||||
@@ -488,6 +490,9 @@ export const StatusBar = memo(function StatusBar({
|
||||
);
|
||||
const traceEl = <TraceControl enabled={!!traceEnabled} onRunCommand={onRunCommand} />;
|
||||
const renovationEl = <RenovationControl />;
|
||||
// [272] Varianten (nur mit Variantensätzen im Projekt; sonst leer).
|
||||
const hasDesignOptions = useStore((s) => !!s.project.designOptionSets?.length);
|
||||
const designOptionEl = <DesignOptionControl />;
|
||||
const snapEl = <SnapControl snap={snap} onSnapChange={onSnapChange} />;
|
||||
const refEl = (
|
||||
<button
|
||||
@@ -504,7 +509,7 @@ export const StatusBar = memo(function StatusBar({
|
||||
// Was in „⋯“ wandert (Reihenfolge = Wegfall-Priorität von oben nach unten).
|
||||
const inMore: React.ReactNode[] = [];
|
||||
if (level >= 3) inMore.push(<span key="lm">{lineModeEl}</span>);
|
||||
if (level >= 4) inMore.push(<span key="tr">{traceEl}</span>, <span key="ren">{renovationEl}</span>);
|
||||
if (level >= 4) inMore.push(<span key="tr">{traceEl}</span>, <span key="ren">{renovationEl}</span>, <span key="dopt">{designOptionEl}</span>);
|
||||
if (level >= 5) {
|
||||
inMore.push(<span key="sn">{snapEl}</span>, <span key="rf">{refEl}</span>);
|
||||
}
|
||||
@@ -535,6 +540,12 @@ export const StatusBar = memo(function StatusBar({
|
||||
<Sep />
|
||||
{renovationEl}
|
||||
<Sep />
|
||||
{hasDesignOptions && (
|
||||
<>
|
||||
{designOptionEl}
|
||||
<Sep />
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{level < 5 && (
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
// [272] Ressourcen-Tab „Varianten“: Variantensätze (z. B. „Dachform“) mit ihren Varianten anlegen, umbenennen, löschen;
|
||||
// Hauptvariante wählen; „Variante übernehmen“ (ihre Elemente ins Hauptmodell, die übrigen Varianten des Satzes werden
|
||||
// gelöscht — ein Undo-Schritt). Reine Darstellung über Handler mit Werten (auch im macOS-Nebenfenster).
|
||||
|
||||
import { useState } from "react";
|
||||
import { t } from "../../i18n";
|
||||
import type { Project } from "../../model/types";
|
||||
import { designOptionSets, primaryOption } from "../../core";
|
||||
|
||||
export interface DesignOptionHandlers {
|
||||
onAddDesignOptionSet?: (name: string) => void;
|
||||
onRenameDesignOptionSet?: (setId: string, name: string) => void;
|
||||
onAddDesignOption?: (setId: string) => void;
|
||||
onRenameDesignOption?: (setId: string, optionId: string, name: string) => void;
|
||||
onSetPrimaryDesignOption?: (setId: string, optionId: string) => void;
|
||||
/** Variante übernehmen: Elemente ins Hauptmodell, übrige Varianten des Satzes gelöscht, Satz weg. */
|
||||
onAcceptDesignOption?: (setId: string, optionId: string) => void;
|
||||
/** Satz (ohne `optionId`) bzw. Variante samt ihren Elementen löschen. */
|
||||
onDeleteDesignOption?: (setId: string, optionId?: string) => void;
|
||||
}
|
||||
|
||||
/** Zahl der Elemente je Variante (Satz-Id → Varianten-Id → Anzahl). */
|
||||
function counts(project: Project): Map<string, number> {
|
||||
const out = new Map<string, number>();
|
||||
const lists = [project.walls, project.openings, project.ceilings, project.roofs, project.stairs, project.columns, project.extrudedSolids, project.rooms, project.drawings2d];
|
||||
for (const list of lists) {
|
||||
for (const e of (list ?? []) as { designOption?: { set: string; option: string } }[]) {
|
||||
if (!e.designOption) continue;
|
||||
const k = `${e.designOption.set}/${e.designOption.option}`;
|
||||
out.set(k, (out.get(k) ?? 0) + 1);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
export function DesignOptionsTab({ project, handlers }: { project: Project; handlers: DesignOptionHandlers }) {
|
||||
const sets = designOptionSets(project);
|
||||
const [newName, setNewName] = useState("");
|
||||
const n = counts(project);
|
||||
const add = () => {
|
||||
if (!handlers.onAddDesignOptionSet) return;
|
||||
handlers.onAddDesignOptionSet(newName.trim() || t("designOption.set.defaultName", { n: sets.length + 1 }));
|
||||
setNewName("");
|
||||
};
|
||||
return (
|
||||
<div className="rm-design-options" data-testid="rm-design-options">
|
||||
<h4 className="rm-subhead">{t("designOption.sets.title")}</h4>
|
||||
<p className="rm-hint">{t("designOption.sets.hint")}</p>
|
||||
{sets.length === 0 && <div className="rm-empty">{t("designOption.sets.empty")}</div>}
|
||||
{sets.map((s) => {
|
||||
const prim = primaryOption(s);
|
||||
return (
|
||||
<div key={s.id} className="rm-design-option-set" data-testid="rm-design-option-set">
|
||||
<div className="rm-row">
|
||||
<input
|
||||
type="text"
|
||||
value={s.name}
|
||||
aria-label={t("designOption.set")}
|
||||
disabled={!handlers.onRenameDesignOptionSet}
|
||||
onChange={(e) => handlers.onRenameDesignOptionSet?.(s.id, e.target.value)}
|
||||
/>
|
||||
<button type="button" className="rm-icon-btn" title={t("designOption.option.add")} aria-label={t("designOption.option.add")} disabled={!handlers.onAddDesignOption} onClick={() => handlers.onAddDesignOption?.(s.id)} data-testid="rm-design-option-add">
|
||||
<span className="material-symbols-outlined" aria-hidden="true">add</span>
|
||||
</button>
|
||||
<button type="button" className="rm-icon-btn" title={t("designOption.set.delete")} aria-label={t("designOption.set.delete")} disabled={!handlers.onDeleteDesignOption} onClick={() => handlers.onDeleteDesignOption?.(s.id)}>
|
||||
<span className="material-symbols-outlined" aria-hidden="true">delete</span>
|
||||
</button>
|
||||
</div>
|
||||
{s.options.map((o) => (
|
||||
<div className="rm-row rm-design-option" key={o.id} data-testid="rm-design-option">
|
||||
<label className="rm-design-option-primary" title={t("designOption.primary")}>
|
||||
<input type="radio" name={`primary-${s.id}`} checked={prim === o.id} disabled={!handlers.onSetPrimaryDesignOption} onChange={() => handlers.onSetPrimaryDesignOption?.(s.id, o.id)} aria-label={t("designOption.primary")} />
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={o.name}
|
||||
aria-label={t("designOption.option")}
|
||||
disabled={!handlers.onRenameDesignOption}
|
||||
onChange={(e) => handlers.onRenameDesignOption?.(s.id, o.id, e.target.value)}
|
||||
/>
|
||||
<span className="rm-design-option-count" title={t("designOption.count")}>
|
||||
{n.get(`${s.id}/${o.id}`) ?? 0}
|
||||
</span>
|
||||
<button type="button" className="rm-add-btn" disabled={!handlers.onAcceptDesignOption} onClick={() => handlers.onAcceptDesignOption?.(s.id, o.id)} title={t("designOption.accept.hint")} data-testid="rm-design-option-accept">
|
||||
{t("designOption.accept")}
|
||||
</button>
|
||||
<button type="button" className="rm-icon-btn" title={t("designOption.option.delete")} aria-label={t("designOption.option.delete")} disabled={!handlers.onDeleteDesignOption} onClick={() => handlers.onDeleteDesignOption?.(s.id, o.id)}>
|
||||
<span className="material-symbols-outlined" aria-hidden="true">delete</span>
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
<div className="rm-row">
|
||||
<input type="text" value={newName} placeholder={t("designOption.set.placeholder")} aria-label={t("designOption.set.new")} onChange={(e) => setNewName(e.target.value)} onKeyDown={(e) => e.key === "Enter" && add()} data-testid="rm-design-option-set-name" />
|
||||
<button type="button" className="rm-add-btn" disabled={!handlers.onAddDesignOptionSet} onClick={add} data-testid="rm-design-option-set-add">
|
||||
{t("designOption.set.add")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -31,6 +31,7 @@ export type TopBarEvents = Required<
|
||||
| "onNewProjectFromComplexSample"
|
||||
| "onNewProjectFromWettbewerbSample"
|
||||
| "onNewProjectFromUmbauSample"
|
||||
| "onNewProjectFromVariantenSample"
|
||||
| "onNewProjectFromTemplate"
|
||||
| "onOpenProject"
|
||||
| "onSaveProject"
|
||||
@@ -135,6 +136,7 @@ export function useTopBarElements(opts: {
|
||||
onNewProjectFromComplexSample={ev.onNewProjectFromComplexSample}
|
||||
onNewProjectFromWettbewerbSample={ev.onNewProjectFromWettbewerbSample}
|
||||
onNewProjectFromUmbauSample={ev.onNewProjectFromUmbauSample}
|
||||
onNewProjectFromVariantenSample={ev.onNewProjectFromVariantenSample}
|
||||
onNewProjectFromTemplate={ev.onNewProjectFromTemplate}
|
||||
onOpenProject={ev.onOpenProject}
|
||||
onSaveProject={ev.onSaveProject}
|
||||
|
||||
Reference in new issue
Block a user