[208] [253] [255] UI-Review: Flächentabelle ohne Querscrollen (Zeilenkarten), Fundstelle im Anonymitäts-Dialog lesbar, Baurecht-Blatt-Tabelle mit kurzen Köpfen, Objekt-Palette höher und Gruppen merken Zustand
This commit is contained in:
11 files changed
+335
-16
No files matched your search
@@ -6,18 +6,32 @@ import { memo, useEffect, useSyncExternalStore } from "react";
|
||||
import { getLanguage, t } from "../i18n";
|
||||
import { getAnonymityRequest, subscribeAnonymityRequest } from "../state/anonymityGate";
|
||||
import { useModalFocus } from "./modalFocus";
|
||||
import { anonymityPlaceParts } from "./anonymityPlace";
|
||||
|
||||
const AREA_KEYS = new Set([
|
||||
"rooms", "drawingLevels", "layers", "groups", "blockDefs", "layouts", "masterLayouts", "drawings2d", "walls", "openings",
|
||||
"stairs", "columns", "context", "extrudedSolids", "viewSnapshots", "viewSnapshotFolders", "viewTemplates", "layoutFolders",
|
||||
"publishSets", "roomProgram", "export", "cameras", "components", "wallTypes", "textStyles", "ceilings", "roofs", "trees",
|
||||
"hatches", "lineStyles",
|
||||
"hatches", "lineStyles", "materials",
|
||||
]);
|
||||
|
||||
function areaLabel(area: string): string {
|
||||
return AREA_KEYS.has(area) ? t(`anonymity.area.${area}`) : area;
|
||||
}
|
||||
|
||||
/** Fundstelle lesbar: Elementart „Name“ · Feld (z. B. Material „Wärmedämmung“ · Name). */
|
||||
function FindingPlace({ area, place }: { area: string; place: string }) {
|
||||
const p = anonymityPlaceParts(area, place);
|
||||
const q = (s: string) => (getLanguage() === "en" ? `\u201C${s}\u201D` : `\u201E${s}\u201C`);
|
||||
return (
|
||||
<>
|
||||
<b>{p.kind || areaLabel(area)}</b>
|
||||
{p.item ? <b> {q(p.item)}</b> : null}
|
||||
{p.field ? <span style={{ color: "var(--muted)" }}> · {p.field}</span> : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
const DialogBody = memo(function DialogBody() {
|
||||
const request = useSyncExternalStore(subscribeAnonymityRequest, getAnonymityRequest);
|
||||
const dialogRef = useModalFocus({});
|
||||
@@ -46,8 +60,7 @@ const DialogBody = memo(function DialogBody() {
|
||||
<ul data-testid="anonymity-findings" style={{ margin: "6px 0 0", paddingLeft: 18, maxHeight: 280, overflow: "auto", fontSize: 12 }}>
|
||||
{findings.map((f, i) => (
|
||||
<li key={i} data-kind={f.kind} style={{ marginBottom: 4 }}>
|
||||
<b>{areaLabel(f.area)}</b>
|
||||
{f.place ? <span style={{ color: "var(--muted)" }}> · {f.place}</span> : null}
|
||||
<FindingPlace area={f.area} place={f.place} />
|
||||
<div>
|
||||
{getLanguage() === "en" ? `\u201C${f.text}\u201D` : `\u201E${f.text}\u201C`} — {t(`anonymity.kind.${f.kind}`)}: <span className="mono">{f.term}</span>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Fundstellen-Zerlegung des Anonymitäts-Dialogs: Pfade des Kerns -> Elementart, Name, Feld (de/en).
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { setLanguage } from "../i18n";
|
||||
import { anonymityPlaceParts } from "./anonymityPlace";
|
||||
|
||||
afterEach(() => setLanguage("de"));
|
||||
|
||||
describe("anonymityPlaceParts", () => {
|
||||
it("typische Pfade auf Deutsch", () => {
|
||||
setLanguage("de");
|
||||
expect(anonymityPlaceParts("materials", "Wärmedämmung.name")).toEqual({ kind: "Material", item: "Wärmedämmung", field: "Name" });
|
||||
expect(anonymityPlaceParts("rooms", "Küche.note")).toEqual({ kind: "Raum", item: "Küche", field: "Notiz" });
|
||||
expect(anonymityPlaceParts("drawingLevels", "EG.name")).toEqual({ kind: "Geschoss", item: "EG", field: "Name" });
|
||||
expect(anonymityPlaceParts("layers", "Wände.layers.Anna.name")).toEqual({ kind: "Ebene / Klasse", item: "Wände › Anna", field: "Name" });
|
||||
expect(anonymityPlaceParts("drawings2d", "0.text")).toEqual({ kind: "Zeichnung", item: "0", field: "Text" });
|
||||
expect(anonymityPlaceParts("layouts", "Plan.titleBlock.sheetName")).toEqual({ kind: "Blatt", item: "Plan", field: "Titelblock · Blattname" });
|
||||
expect(anonymityPlaceParts("layouts", "Plan.images.logo.png.name")).toEqual({ kind: "Blatt", item: "Plan › logo.png", field: "Name" });
|
||||
});
|
||||
it("Englisch, unbekanntes Feld und Zusatztext", () => {
|
||||
setLanguage("en");
|
||||
expect(anonymityPlaceParts("materials", "Insulation.name")).toEqual({ kind: "Material", item: "Insulation", field: "Name" });
|
||||
expect(anonymityPlaceParts("rooms", "Kitchen.weird")).toEqual({ kind: "Room", item: "Kitchen", field: "weird" });
|
||||
expect(anonymityPlaceParts("export", "Dateiname")).toEqual({ kind: "Output", item: "", field: "Dateiname" });
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
// Lesbare Fundstelle für den Anonymitäts-Dialog ([208]): der Kern liefert Bereich und Pfad
|
||||
// (`Wärmedämmung.name`, `Plan.titleBlock.sheetName`); hier werden Elementart, Name und Feld daraus.
|
||||
//
|
||||
// Bezeichner englisch, Kommentare deutsch.
|
||||
|
||||
import { t } from "../i18n";
|
||||
|
||||
export interface PlaceParts {
|
||||
/** Elementart im Singular („Material“), leer wenn unbekannt. */
|
||||
kind: string;
|
||||
/** Name des Elements (ggf. mit Unterelement: „Plan › logo.png“). */
|
||||
item: string;
|
||||
/** Feld („Name“, „Blattname“); bei Orten ohne Pfad (Zusatztexte wie „Dateiname“) der Ort selbst. */
|
||||
field: string;
|
||||
}
|
||||
|
||||
/** Zwischenschlüssel im Pfad, die ein Unterelement einleiten (Liste in einem Element). */
|
||||
const NESTED = ["images", "layers", "children", "items", "rows"];
|
||||
|
||||
/** Übersetzung, oder der Fallback, wenn es den Schlüssel nicht gibt (`t` gibt dann den Schlüssel zurück). */
|
||||
function tr(key: string, fallback: string): string {
|
||||
const s = t(key);
|
||||
return s === key ? fallback : s;
|
||||
}
|
||||
|
||||
/** Zerlegt Bereich und Pfad in Elementart, Elementname und Feld. */
|
||||
export function anonymityPlaceParts(area: string, place: string): PlaceParts {
|
||||
const kind = tr(`anonymity.item.${area}`, "");
|
||||
const cut = place.lastIndexOf(".");
|
||||
if (cut < 0) return { kind, item: "", field: place };
|
||||
const key = place.slice(cut + 1);
|
||||
let item = place.slice(0, cut);
|
||||
let field = /^\d+$/.test(key) ? `${tr("anonymity.part.index", "")} ${key}`.trim() : tr(`anonymity.field.${key}`, key);
|
||||
if (item.endsWith(".titleBlock")) {
|
||||
item = item.slice(0, -".titleBlock".length);
|
||||
field = `${tr("anonymity.part.titleBlock", "titleBlock")} · ${field}`;
|
||||
}
|
||||
for (const n of NESTED) item = item.split(`.${n}.`).join(" › ");
|
||||
return { kind, item, field };
|
||||
}
|
||||
Reference in new issue
Block a user