[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
@@ -4194,6 +4194,79 @@ export const de = {
|
||||
"anonymity.kind.file": "Dateiname",
|
||||
"anonymity.kind.email": "E-Mail",
|
||||
"anonymity.kind.phone": "Telefon",
|
||||
"anonymity.area.materials": "Materialien",
|
||||
"anonymity.item.rooms": "Raum",
|
||||
"anonymity.item.drawingLevels": "Geschoss",
|
||||
"anonymity.item.layers": "Ebene / Klasse",
|
||||
"anonymity.item.groups": "Gruppe",
|
||||
"anonymity.item.blockDefs": "Block",
|
||||
"anonymity.item.layouts": "Blatt",
|
||||
"anonymity.item.masterLayouts": "Masterlayout",
|
||||
"anonymity.item.drawings2d": "Zeichnung",
|
||||
"anonymity.item.walls": "Wand",
|
||||
"anonymity.item.openings": "Öffnung",
|
||||
"anonymity.item.stairs": "Treppe",
|
||||
"anonymity.item.columns": "Stütze",
|
||||
"anonymity.item.context": "Kontext",
|
||||
"anonymity.item.extrudedSolids": "Körper",
|
||||
"anonymity.item.viewSnapshots": "Ausschnitt",
|
||||
"anonymity.item.viewSnapshotFolders": "Ausschnitt-Ordner",
|
||||
"anonymity.item.viewTemplates": "Ansichtsvorlage",
|
||||
"anonymity.item.layoutFolders": "Layout-Ordner",
|
||||
"anonymity.item.publishSets": "Publikationssatz",
|
||||
"anonymity.item.roomProgram": "Raumprogramm",
|
||||
"anonymity.item.export": "Ausgabe",
|
||||
"anonymity.item.cameras": "Kamera",
|
||||
"anonymity.item.components": "Bauteil",
|
||||
"anonymity.item.wallTypes": "Wandtyp",
|
||||
"anonymity.item.textStyles": "Textstil",
|
||||
"anonymity.item.ceilings": "Decke",
|
||||
"anonymity.item.roofs": "Dach",
|
||||
"anonymity.item.trees": "Baum",
|
||||
"anonymity.item.hatches": "Schraffur",
|
||||
"anonymity.item.lineStyles": "Linienstil",
|
||||
"anonymity.item.materials": "Material",
|
||||
"anonymity.field.name": "Name",
|
||||
"anonymity.field.text": "Text",
|
||||
"anonymity.field.note": "Notiz",
|
||||
"anonymity.field.notes": "Notizen",
|
||||
"anonymity.field.label": "Beschriftung",
|
||||
"anonymity.field.title": "Titel",
|
||||
"anonymity.field.description": "Beschreibung",
|
||||
"anonymity.field.comment": "Kommentar",
|
||||
"anonymity.field.sheetName": "Blattname",
|
||||
"anonymity.field.projectName": "Projektname",
|
||||
"anonymity.field.projectNumber": "Projektnummer",
|
||||
"anonymity.field.author": "Bearbeiter:in",
|
||||
"anonymity.field.number": "Nummer",
|
||||
"anonymity.field.planNumber": "Plannummer",
|
||||
"anonymity.field.revision": "Revision",
|
||||
"anonymity.field.date": "Datum",
|
||||
"anonymity.field.mark": "Kennzeichen",
|
||||
"anonymity.field.abbrev": "Kürzel",
|
||||
"anonymity.field.family": "Familie",
|
||||
"anonymity.field.code": "Code",
|
||||
"anonymity.field.group": "Gruppe",
|
||||
"anonymity.field.layer": "Ebene",
|
||||
"anonymity.field.value": "Wert",
|
||||
"anonymity.field.setName": "Satzname",
|
||||
"anonymity.field.namePattern": "Namensmuster",
|
||||
"anonymity.field.identifiers": "Angaben",
|
||||
"anonymity.field.keyword": "Kennwort",
|
||||
"anonymity.field.source": "Quelle",
|
||||
"anonymity.field.template": "Vorlage",
|
||||
"anonymity.field.folder": "Ordner",
|
||||
"anonymity.field.floorFinish": "Bodenbelag",
|
||||
"anonymity.field.ceilingFinish": "Deckenbelag",
|
||||
"anonymity.field.wallFinish": "Wandbelag",
|
||||
"anonymity.field.floorBuildUp": "Bodenaufbau",
|
||||
"anonymity.field.species": "Art",
|
||||
"anonymity.field.format": "Format",
|
||||
"anonymity.field.fileName": "Dateiname",
|
||||
"anonymity.field.scale": "Massstab",
|
||||
"anonymity.part.titleBlock": "Titelblock",
|
||||
"anonymity.part.images": "Bild",
|
||||
"anonymity.part.index": "Eintrag",
|
||||
"publish.competition.identifiers": "Weitere Angaben, die nicht vorkommen dürfen",
|
||||
"publish.competition.identifiersHint": "Büro, Namen, E-Mail, Telefon, getrennt durch Komma. Vor dem Export der anonymen Abgabe im Freitext gesucht.",
|
||||
"publish.competition.keyword": "Kennwort",
|
||||
@@ -4213,6 +4286,7 @@ export const de = {
|
||||
"siteProof.col.allowed": "Zulässig",
|
||||
"siteProof.col.actual": "Projekt",
|
||||
"siteProof.col.reserve": "Reserve (+) / Überschr. (−)",
|
||||
"siteProof.col.reserveShort": "Reserve",
|
||||
"siteProof.col.ok": "Erfüllt",
|
||||
"siteProof.col.basis": "Grundlage",
|
||||
"siteProof.col.value": "Wert",
|
||||
|
||||
@@ -4180,6 +4180,79 @@ export const en: Record<TranslationKey, string> = {
|
||||
"anonymity.kind.file": "file name",
|
||||
"anonymity.kind.email": "e-mail",
|
||||
"anonymity.kind.phone": "phone",
|
||||
"anonymity.area.materials": "Materials",
|
||||
"anonymity.item.rooms": "Room",
|
||||
"anonymity.item.drawingLevels": "Level",
|
||||
"anonymity.item.layers": "Layer / class",
|
||||
"anonymity.item.groups": "Group",
|
||||
"anonymity.item.blockDefs": "Block",
|
||||
"anonymity.item.layouts": "Sheet",
|
||||
"anonymity.item.masterLayouts": "Master layout",
|
||||
"anonymity.item.drawings2d": "Drawing",
|
||||
"anonymity.item.walls": "Wall",
|
||||
"anonymity.item.openings": "Opening",
|
||||
"anonymity.item.stairs": "Stair",
|
||||
"anonymity.item.columns": "Column",
|
||||
"anonymity.item.context": "Context",
|
||||
"anonymity.item.extrudedSolids": "Solid",
|
||||
"anonymity.item.viewSnapshots": "View snapshot",
|
||||
"anonymity.item.viewSnapshotFolders": "Snapshot folder",
|
||||
"anonymity.item.viewTemplates": "View template",
|
||||
"anonymity.item.layoutFolders": "Layout folder",
|
||||
"anonymity.item.publishSets": "Publish set",
|
||||
"anonymity.item.roomProgram": "Room program",
|
||||
"anonymity.item.export": "Output",
|
||||
"anonymity.item.cameras": "Camera",
|
||||
"anonymity.item.components": "Component",
|
||||
"anonymity.item.wallTypes": "Wall type",
|
||||
"anonymity.item.textStyles": "Text style",
|
||||
"anonymity.item.ceilings": "Ceiling",
|
||||
"anonymity.item.roofs": "Roof",
|
||||
"anonymity.item.trees": "Tree",
|
||||
"anonymity.item.hatches": "Hatch",
|
||||
"anonymity.item.lineStyles": "Line style",
|
||||
"anonymity.item.materials": "Material",
|
||||
"anonymity.field.name": "Name",
|
||||
"anonymity.field.text": "Text",
|
||||
"anonymity.field.note": "Note",
|
||||
"anonymity.field.notes": "Notes",
|
||||
"anonymity.field.label": "Label",
|
||||
"anonymity.field.title": "Title",
|
||||
"anonymity.field.description": "Description",
|
||||
"anonymity.field.comment": "Comment",
|
||||
"anonymity.field.sheetName": "Sheet name",
|
||||
"anonymity.field.projectName": "Project name",
|
||||
"anonymity.field.projectNumber": "Project number",
|
||||
"anonymity.field.author": "Author",
|
||||
"anonymity.field.number": "Number",
|
||||
"anonymity.field.planNumber": "Plan number",
|
||||
"anonymity.field.revision": "Revision",
|
||||
"anonymity.field.date": "Date",
|
||||
"anonymity.field.mark": "Mark",
|
||||
"anonymity.field.abbrev": "Abbreviation",
|
||||
"anonymity.field.family": "Family",
|
||||
"anonymity.field.code": "Code",
|
||||
"anonymity.field.group": "Group",
|
||||
"anonymity.field.layer": "Layer",
|
||||
"anonymity.field.value": "Value",
|
||||
"anonymity.field.setName": "Set name",
|
||||
"anonymity.field.namePattern": "Name pattern",
|
||||
"anonymity.field.identifiers": "Identifiers",
|
||||
"anonymity.field.keyword": "Keyword",
|
||||
"anonymity.field.source": "Source",
|
||||
"anonymity.field.template": "Template",
|
||||
"anonymity.field.folder": "Folder",
|
||||
"anonymity.field.floorFinish": "Floor finish",
|
||||
"anonymity.field.ceilingFinish": "Ceiling finish",
|
||||
"anonymity.field.wallFinish": "Wall finish",
|
||||
"anonymity.field.floorBuildUp": "Floor build-up",
|
||||
"anonymity.field.species": "Species",
|
||||
"anonymity.field.format": "Format",
|
||||
"anonymity.field.fileName": "File name",
|
||||
"anonymity.field.scale": "Scale",
|
||||
"anonymity.part.titleBlock": "Title block",
|
||||
"anonymity.part.images": "Image",
|
||||
"anonymity.part.index": "Entry",
|
||||
"publish.competition.identifiers": "Further details that must not appear",
|
||||
"publish.competition.identifiersHint": "Office, names, e-mail, phone, separated by commas. Searched in free text before an anonymous submission is exported.",
|
||||
"publish.competition.keyword": "Keyword",
|
||||
@@ -4199,6 +4272,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"siteProof.col.allowed": "Allowed",
|
||||
"siteProof.col.actual": "Project",
|
||||
"siteProof.col.reserve": "Reserve (+) / excess (−)",
|
||||
"siteProof.col.reserveShort": "Reserve",
|
||||
"siteProof.col.ok": "Met",
|
||||
"siteProof.col.basis": "Basis",
|
||||
"siteProof.col.value": "Value",
|
||||
|
||||
@@ -73,11 +73,11 @@ export function AreaTableSection() {
|
||||
{r.cells.map((c, ci) =>
|
||||
typeof c === "string" ? (
|
||||
// Kurze Textzellen in Zahlenspalten (Strich, ja/nein) stehen wie die Zahlen rechts.
|
||||
<td key={ci} className={ci > 0 && c.length <= 4 ? "num" : undefined}>
|
||||
<td key={ci} data-label={ci > 0 ? s.columns[ci] : undefined} className={ci > 0 && c.length <= 4 ? "num" : undefined}>
|
||||
{c}
|
||||
</td>
|
||||
) : (
|
||||
<td key={ci} className="num">
|
||||
<td key={ci} data-label={ci > 0 ? s.columns[ci] : undefined} className="num">
|
||||
{c.n === null ? "–" : c.n.toFixed(c.d)}
|
||||
</td>
|
||||
),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// mit Vorschau-Symbol je Objekt. Klick wählt das Objekt und startet den Befehl `libobj` (Einfügepunkt klicken,
|
||||
// R = drehen, M = spiegeln). Der Katalog kommt aus dem Rust-Kern; die Vorschau zeichnet der Kern (grob).
|
||||
|
||||
import { useMemo } from "react";
|
||||
import { useMemo, useState } from "react";
|
||||
import { t } from "../i18n";
|
||||
import type { TranslationKey } from "../i18n";
|
||||
import { usePanelHostAction } from "./host";
|
||||
@@ -43,7 +43,31 @@ function Preview({ def }: { def: LibObjectDef }) {
|
||||
);
|
||||
}
|
||||
|
||||
const OPEN_KEY = "cad.objlib.open";
|
||||
|
||||
/** Gemerkter Zustand der Gruppen (offen/zu) je Gruppen-Schlüssel; leer, wenn nichts gespeichert ist. */
|
||||
function loadOpen(): Record<string, boolean> {
|
||||
try {
|
||||
const raw = localStorage.getItem(OPEN_KEY);
|
||||
const v: unknown = raw ? JSON.parse(raw) : null;
|
||||
return v && typeof v === "object" ? (v as Record<string, boolean>) : {};
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
export function ObjectLibraryPanel() {
|
||||
const [open, setOpen] = useState<Record<string, boolean>>(loadOpen);
|
||||
const setGroupOpen = (g: string, v: boolean) =>
|
||||
setOpen((o) => {
|
||||
const next = { ...o, [g]: v };
|
||||
try {
|
||||
localStorage.setItem(OPEN_KEY, JSON.stringify(next));
|
||||
} catch {
|
||||
/* Speicher gesperrt: der Zustand gilt nur für diese Sitzung */
|
||||
}
|
||||
return next;
|
||||
});
|
||||
const onRunCommand = usePanelHostAction("onRunCommand");
|
||||
const catalog = useMemo(() => libCatalog(), []);
|
||||
const groups = useMemo(() => libGroups(), []);
|
||||
@@ -60,7 +84,7 @@ export function ObjectLibraryPanel() {
|
||||
<div className="objlib-panel" style={{ overflowY: "auto", padding: "6px 8px" }}>
|
||||
<div style={{ fontSize: 11, color: "var(--muted)", marginBottom: 6 }}>{t("lib.hint")}</div>
|
||||
{groups.map((g) => (
|
||||
<details key={g} open={g === groups[0]} style={{ marginBottom: 4 }}>
|
||||
<details key={g} open={open[g] ?? g === groups[0]} onToggle={(e) => { const v = e.currentTarget.open; if (v !== (open[g] ?? g === groups[0])) setGroupOpen(g, v); }} style={{ marginBottom: 4 }}>
|
||||
<summary style={{ cursor: "pointer", fontSize: 12, fontWeight: 600, padding: "3px 0" }}>{t(`lib.g.${g}` as TranslationKey)}</summary>
|
||||
<div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(72px, 1fr))", gap: 4, padding: "4px 0" }}>
|
||||
{catalog.objects
|
||||
|
||||
@@ -46,7 +46,8 @@ import type {
|
||||
// v13 ([238]): rechts oben (Objekt-Info/Flächenbilanz) bekommt mehr Höhe: Gewichte 1,6 : 1 statt 1 : 1,5 (die
|
||||
// Flächenbilanz mit Raumprogramm war nur ~300 px hoch). Die Höhe merkt sich der Gruppen-Splitter (`resizeGroups`).
|
||||
// v14 ([253]): Objekt-Bibliothek ("object-library") als Tab neben den Werkzeugen links oben.
|
||||
export const LAYOUT_VERSION = 14;
|
||||
// v15 ([253]): links oben (Werkzeuge/Objekte) bekommt mehr Höhe: Gewichte 1,6 : 1 (die Objekt-Palette war im 900-px-Fenster nur ~270 px hoch).
|
||||
export const LAYOUT_VERSION = 15;
|
||||
|
||||
/** localStorage-Schlüssel des zuletzt benutzten Layouts. */
|
||||
const CURRENT_KEY = "cad.layout";
|
||||
@@ -74,7 +75,7 @@ const NAMED_PREFIX = "cad.layouts.";
|
||||
// der Attribute-Palette darunter (Vectorworks-Bild). Das Ribbon-Band bleibt als
|
||||
// Reiter erreichbar, ist aber nicht mehr der primäre Weg zu den Werkzeugen.
|
||||
const DEFAULT_LEFT_GROUPS: DockGroup[] = [
|
||||
{ tabs: ["tools", "object-library"], activeTab: "tools", weight: 1 },
|
||||
{ tabs: ["tools", "object-library"], activeTab: "tools", weight: 1.6 },
|
||||
{ tabs: ["attributes"], activeTab: "attributes", weight: 1 },
|
||||
];
|
||||
const DEFAULT_RIGHT_GROUPS: DockGroup[] = [
|
||||
|
||||
@@ -8910,6 +8910,56 @@ body {
|
||||
font-weight: 700;
|
||||
border-top: 1px solid var(--ink-2);
|
||||
}
|
||||
/* Breite Tabelle (> 6 Spalten) in schmaler Dock-Spalte: jede Zeile als Karte — Name oben, darunter die Kennwerte
|
||||
als Raster (5 Spalten) „Kopf über Zahl“ (data-label der Zelle). Kein waagrechtes Scrollen, nichts abgeschnitten. */
|
||||
.area-block {
|
||||
container-type: inline-size;
|
||||
}
|
||||
@container (max-width: 460px) {
|
||||
.area-table.wide,
|
||||
.area-table.wide tbody {
|
||||
display: block;
|
||||
}
|
||||
.area-table.wide thead {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0 0 0 0);
|
||||
}
|
||||
.area-table.wide tr {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
column-gap: 4px;
|
||||
padding: 3px 0;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.area-table.wide td {
|
||||
border-bottom: 0;
|
||||
padding: 1px 3px;
|
||||
min-width: 0;
|
||||
}
|
||||
.area-table.wide tr.total td {
|
||||
border-top: 0;
|
||||
}
|
||||
.area-table.wide tr.total {
|
||||
border-top: 1px solid var(--ink-2);
|
||||
}
|
||||
.area-table.wide td:first-child {
|
||||
grid-column: 1 / -1;
|
||||
font-weight: 600;
|
||||
min-width: 0;
|
||||
}
|
||||
.area-table.wide td[data-label]::before {
|
||||
content: attr(data-label);
|
||||
display: block;
|
||||
font-size: 9px;
|
||||
line-height: 1.2;
|
||||
font-weight: 600;
|
||||
color: var(--ink-2);
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
.area-inputs {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -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