From bd3ae0dd7a0f741aa9ba68cf16178f89a26dde1c Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 12:17:36 +0000 Subject: [PATCH] =?UTF-8?q?[263]=20UX-Reste:=20Quellen-Auswahl=20voll=20le?= =?UTF-8?q?sbar,=20Hilfe=20=E2=86=92=20Kurzanleitung=20und=20Fehler=20meld?= =?UTF-8?q?en,=20Nachweis-Export=20im=20leeren=20Projekt=20mit=20Hinweis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODO.md | 6 +-- e2e/uxReview263.spec.ts | 83 +++++++++++++++++++++++++++++++ src/core/extra.ts | 2 +- src/export/areaReport.test.ts | 11 ++++- src/export/areaReport.ts | 6 +++ src/i18n/de.ts | 5 ++ src/i18n/en.ts | 5 ++ src/native/appMenu.ts | 11 ++++- src/panels/AreaTableSection.tsx | 15 +++++- src/raw.d.ts | 5 ++ src/state/helpMenuHook.ts | 21 ++++++++ src/styles.css | 52 +++++++++++++++++++- src/ui/AppDialogs.tsx | 3 ++ src/ui/AppMenuBar.tsx | 3 ++ src/ui/QuickGuideDialog.tsx | 86 +++++++++++++++++++++++++++++++++ src/ui/miniMarkdown.test.ts | 28 +++++++++++ src/ui/miniMarkdown.ts | 77 +++++++++++++++++++++++++++++ src/update/bugReport.test.ts | 12 +++++ src/update/bugReport.ts | 12 +++++ 19 files changed, 432 insertions(+), 11 deletions(-) create mode 100644 src/state/helpMenuHook.ts create mode 100644 src/ui/QuickGuideDialog.tsx create mode 100644 src/ui/miniMarkdown.test.ts create mode 100644 src/ui/miniMarkdown.ts create mode 100644 src/update/bugReport.test.ts create mode 100644 src/update/bugReport.ts diff --git a/TODO.md b/TODO.md index e4cb0895..a6e63e16 100644 --- a/TODO.md +++ b/TODO.md @@ -62,9 +62,9 @@ Kennwort, anonym) als PDF; Austausch mit Fachplanern über DXF/IFC. 5. ~~Raumprogramm in der Flächenbilanz (320 px Panel): Name- und Gruppenfeld abgeschnitten („Wohnen/“, „Wohnunge“). Vorschlag: zweizeilige Zeilen oder Tooltip/Breite, S.~~ **Erledigt 15.11.:** zweizeilige Zeilen (Name über die ganze Breite, darunter Fläche/Anzahl/Gruppe/Stand), Tooltip mit vollem Text. 6. ~~Statusleiste bei 1280 px: Hinweistext (z. B. „1/4 Treffer — erneut klicken …“) schrumpft auf „1..“, sobald X/Y-Koordinaten stehen. Vorschlag: Hinweis mit `title`, Koordinaten verdichten, S.~~ **Erledigt 15.11.:** Hinweis mindestens 170 px mit `title`, Wertcluster schrumpfbar, unter 1500 px engere Abstände und ohne Build-Nummer (steht im Über-Dialog). 7. ~~Ressourcen-Fenster: Reiterleiste (… „Dachtypen“ …) bei 1280 px abgeschnitten, ohne Scroll-Hinweis; Zeilennamen („Holzwerkstoff (OSB/Spanplatte)“) ohne Tooltip. Vorschlag: gleicher Rand-Fade, `title`, S.~~ **Erledigt 15.11.:** Reiter umbrechen, Zeilennamen mit `title`. - 8. ~~Begriffe/Menüs: Ansicht-Menü „Perspektive“ steht zweimal (3D-Ansicht vs. Projektion; Vorschlag „3D-Ansicht“); Datei „Projekt öffnen“ ohne „ …“ (Startbildschirm mit), „DXF/DWG importieren…“ ohne Leerzeichen; Quellen-Auswahl „eigener Wert“ im Attribute-Panel bei 280 px als „eigen…“ gekürzt, S.~~ **Erledigt 15.11. (ohne „eigen…“ im Attribute-Panel, das bleibt offen):** Ansicht-Menü „3D-Ansicht“ (Ansichtsart) statt zweimal „Perspektive“; „Projekt öffnen …“; Konvention „ …“ (Leerzeichen davor) für Menü-/Befehlstexte de+en vereinheitlicht, Test `spelling.test.ts` (Fortschrittstexte „Suche…“ und Platzhalter ausgenommen). - 9. ~~Hilfe-Menü hat nur „Tastaturkürzel …“; „Über dossier“ nur über Klick auf die Wortmarke (nicht auffindbar), keine Kurzanleitung/Fehler-melden-Eintrag. Vorschlag: Einträge „Über dossier“, „Kurzanleitung“ (Test `kurzanleitung.test.ts` existiert), S.~~ **Teilweise erledigt 15.11.:** Hilfe → „Über dossier …“ (Browser/Electron; Hook `state/aboutDialogHook.ts`); im nativen Tauri-Menü steht „Über“ im App-Menü (macOS), dort nichts geändert. **Offen:** „Kurzanleitung“ und „Fehler melden“. - 10. ~~Rückmeldungen: „Publiziert (Dateien): 1“ nennt weder Dateiname noch Ort; CSV-Nachweis im leeren Projekt exportiert Nullen ohne Hinweis; schwebende Paletten (Verlauf, BCF, Objekteinstellungen mit T ausgenommen) schliessen nicht mit Esc, S.~~ **Teilweise erledigt 15.11.:** Meldung „Publiziert: «Name.pdf»“ (bei mehreren Dateien mit Anzahl; Ort wählt der Speichern-Dialog bzw. Download-Ordner); Verlauf, BCF und Kollisionen schliessen schwebend mit Esc (`closeOnEscape`, Fokus im Fenster). **Offen:** CSV-Nachweis im leeren Projekt ohne Hinweis. e2e: `uxReview263.spec.ts`. Nicht auf dem Mac geprüft. + 8. ~~Begriffe/Menüs: Ansicht-Menü „Perspektive“ steht zweimal (3D-Ansicht vs. Projektion; Vorschlag „3D-Ansicht“); Datei „Projekt öffnen“ ohne „ …“ (Startbildschirm mit), „DXF/DWG importieren…“ ohne Leerzeichen; Quellen-Auswahl „eigener Wert“ im Attribute-Panel bei 280 px als „eigen…“ gekürzt, S.~~ **Erledigt 15.11. („eigen…“ im Attribute-Panel: erledigt 16.11., Zahlenfeld gibt nach, Label-Spalte 36 %, Drehpfeile der Zahlenfelder im Panel ausgeblendet; „eigener Wert“ steht voll innerhalb des Panels, e2e `uxReview263.spec.ts`):** Ansicht-Menü „3D-Ansicht“ (Ansichtsart) statt zweimal „Perspektive“; „Projekt öffnen …“; Konvention „ …“ (Leerzeichen davor) für Menü-/Befehlstexte de+en vereinheitlicht, Test `spelling.test.ts` (Fortschrittstexte „Suche…“ und Platzhalter ausgenommen). + 9. ~~Hilfe-Menü hat nur „Tastaturkürzel …“; „Über dossier“ nur über Klick auf die Wortmarke (nicht auffindbar), keine Kurzanleitung/Fehler-melden-Eintrag. Vorschlag: Einträge „Über dossier“, „Kurzanleitung“ (Test `kurzanleitung.test.ts` existiert), S.~~ **Teilweise erledigt 15.11.:** Hilfe → „Über dossier …“ (Browser/Electron; Hook `state/aboutDialogHook.ts`); im nativen Tauri-Menü steht „Über“ im App-Menü (macOS), dort nichts geändert. **Erledigt 16.11.:** Hilfe → „Kurzanleitung …“ (Overlay-Dialog `QuickGuideDialog.tsx`, Inhalt von `doc/KURZANLEITUNG.md` beim Build gebündelt samt Bildern, kleiner Markdown-Leser `miniMarkdown.ts`, kein Netz; Text bleibt deutsch, im en-Titel „(German)“) und „Fehler melden …“ (öffnet `https://git.openbureau.ch/karim/dossier/issues/new` über `openExternalUrl`, vorbefüllt nur mit Version und Build, `update/bugReport.ts`); im nativen Tauri-Menü (Hilfe) dieselben Einträge. Nicht in der Tauri-App geprüft (System-Browser-Öffnung dort ungeprüft). + 10. ~~Rückmeldungen: „Publiziert (Dateien): 1“ nennt weder Dateiname noch Ort; CSV-Nachweis im leeren Projekt exportiert Nullen ohne Hinweis; schwebende Paletten (Verlauf, BCF, Objekteinstellungen mit T ausgenommen) schliessen nicht mit Esc, S.~~ **Teilweise erledigt 15.11.:** Meldung „Publiziert: «Name.pdf»“ (bei mehreren Dateien mit Anzahl; Ort wählt der Speichern-Dialog bzw. Download-Ordner); Verlauf, BCF und Kollisionen schliessen schwebend mit Esc (`closeOnEscape`, Fokus im Fenster). **Erledigt 16.11.:** CSV und PDF des Flächen- und Kennzahlen-Nachweises brechen im Projekt ohne Bauteile ab und melden „Noch keine Bauteile — der Nachweis wäre leer. Es wurde nichts exportiert.“ (`isAreaReportEmpty`); die übrigen Tabellen-Exporte (Raumbuch, Kosten …) unverändert. e2e: `uxReview263.spec.ts`. Nicht auf dem Mac geprüft. **Nicht geprüft:** Tauri/Mac (Nebenfenster, native Menüs, Metal), 3D-Ansicht und Zeichenfläche pixelgenau (SwiftShader), Layout-Inhalt im Druck, englisch/dunkel bei 1440, Tab-Reihenfolge/Screenreader ausserhalb der Dialoge ([249]). Dunkles Thema: Kontrast der Panels und Dialoge ohne Befund; der Plan bleibt als Papier hell (Absicht?). Grösse S–M. - ◐ **[261]** Version und Buildnummer (15.11., Entscheid Maintainer): Anwender-Version semver **1.0.0-beta.1** (`package.json`, `tauri.conf.json`, App-`Cargo.toml`, `website/hugo.toml`; Kern-Crates bleiben 0.1.0, nichts Sichtbares). Interne Buildnummer **`JJMMTT.N`** aus `scripts/build-number.cjs`: Env `DOSSIER_BUILD` gewinnt, sonst Datum + Anzahl Commits des Tages (`git log --since=midnight`), ohne Git `JJMMTT.0`. Eingebacken über Vite-`define` (`__DOSSIER_BUILD__`, `src/update/buildInfo.ts`; Browser/Electron/Tauri) und `scripts/build-cli.mjs` (`dossier-cli --version`); Anzeige „1.0.0-beta.1 (Build 261115.1)“ in Über-Dialog, Einstellungen, Startbildschirm, macOS-Info-Fenster (shortVersion) und dezent in der Statusleiste; `tauri:build` setzt `bundle.macOS.bundleVersion` (CFBundleVersion). Tests: `src/update/buildNumber.test.ts`. **Offen:** nicht in der Tauri-App/auf dem Mac geprüft (Prüfschritt 13.35); ~~Electron-`buildVersion` nicht gesetzt~~ (16.11. gesetzt, [170]: aus `dist/build-info.json`, gleiche Nummer wie die Oberfläche); Projektdatei trägt (noch) kein Feld für die schreibende App-Version/Build (bräuchte Modellfeld in Rust + `KNOWN_KEYS` + Fassade, S); Zähler zählt Commits, nicht Builds (zwei Builds ohne Commit dazwischen = gleiche Nummer; Abhilfe `DOSSIER_BUILD=261115.3`). Grösse S. - ◐ **[260]** Fenster/Türen im Grundriss: Darstellungsart **symbolisch** oder **geschnitten** wählbar (15.11., Entscheid Maintainer). Symbolisch = Öffnungssymbol nach Norm unabhängig von der Schnitthöhe (heutiges Verhalten für Öffnungen im Schnitt, Brüstungen/Stürze über/unter Schnitt als Symbol); geschnitten = Darstellung nach der tatsächlichen Schnitthöhe (Öffnung über dem Schnitt: Wand geschlossen, Öffnung als Linie über Schnitt). Einstellbar im Objekteinstellungsfenster (Taste T) je Fenster/Tür bzw. Typ, Vorgabe aus Modelldarstellung. diff --git a/e2e/uxReview263.spec.ts b/e2e/uxReview263.spec.ts index f7b5c371..b7fce197 100644 --- a/e2e/uxReview263.spec.ts +++ b/e2e/uxReview263.spec.ts @@ -203,3 +203,86 @@ test("Verlauf und BCF (schwebende Fenster) schliessen mit Esc", async ({ page }) await page.keyboard.press("Escape"); await expect(bcf).toBeHidden(); }); + +// [263] Rest: Quellen-Auswahl voll lesbar, Hilfe → Kurzanleitung / Fehler melden, CSV-Nachweis im leeren Projekt. +// Screenshots nur auf Wunsch: E2E_SHOTS=/pfad. +const shot = async (page: import("@playwright/test").Page, name: string) => { + if (process.env.E2E_SHOTS) await page.screenshot({ path: `${process.env.E2E_SHOTS}/${name}.png` }); +}; + +test("Attribute-Panel: „eigener Wert“ steht ungekürzt und innerhalb des Panels", async ({ page }) => { + await startNewProject(page); + await fileMenu(page, /^Neu aus Vorlage: Wettbewerb$/); + await discardIfAsked(page); + await page.mouse.click(400, 430); + const trigger = page.locator(".attr-val > .attr-num ~ .tb-dd-trigger").first(); + await expect(trigger).toBeVisible(); + const box = (await trigger.boundingBox())!; + const panel = (await page.locator(".attr-grid").first().boundingBox())!; + expect(box.x + box.width).toBeLessThanOrEqual(panel.x + panel.width + 1); + await expect(trigger).toContainText("eigener Wert"); + await shot(page, "attr-after"); +}); + +test("Hilfe: Kurzanleitung öffnet im Dialog, Esc schliesst", async ({ page }) => { + await startNewProject(page); + await page.getByRole("button", { name: "Hilfe", exact: true }).click(); + await page.getByRole("option", { name: "Kurzanleitung …", exact: true }).click(); + const dlg = page.getByRole("dialog", { name: "Kurzanleitung" }); + await expect(dlg).toBeVisible(); + await expect(dlg.getByRole("heading", { name: "Erster Wettbewerb mit Dossier" })).toBeVisible(); + await expect(dlg.getByRole("heading", { name: /^1\. Leeres Projekt/ })).toHaveCount(1); + expect(await dlg.textContent()).not.toContain("**"); + await shot(page, "guide-de"); + await dlg.locator("img").first().scrollIntoViewIfNeeded(); + await expect.poll(() => dlg.locator("img").first().evaluate((i: HTMLImageElement) => i.complete && i.naturalWidth > 0)).toBe(true); + await shot(page, "guide-de-img"); + await page.keyboard.press("Escape"); + await expect(dlg).toBeHidden(); +}); + +test("Hilfe: Fehler melden öffnet die Issue-Seite mit Version und Build, ohne Projektdaten", async ({ page }) => { + await page.addInitScript(() => { + const w = window as unknown as { __opened: string[] }; + w.__opened = []; + window.open = ((url?: string | URL) => { + w.__opened.push(String(url)); + return null; + }) as typeof window.open; + }); + await startNewProject(page); + await page.getByRole("button", { name: "Hilfe", exact: true }).click(); + await page.getByRole("option", { name: "Fehler melden …", exact: true }).click(); + const opened = await page.evaluate(() => (window as unknown as { __opened: string[] }).__opened); + expect(opened).toHaveLength(1); + const u = new URL(opened[0]!); + expect(u.origin + u.pathname).toBe("https://git.openbureau.ch/karim/dossier/issues/new"); + expect(u.searchParams.get("body")!).toMatch(/^Version: \S+ \(Build \S+\)/); +}); + +test("Fehler melden und Kurzanleitung auf Englisch", async ({ page }) => { + await page.goto("/?dossierTest&lang=en"); + await page.getByRole("button", { name: "New project" }).first().click(); + await page.getByRole("menubar").getByRole("button", { name: "Help", exact: true }).click(); + await shot(page, "help-en"); + await expect(page.getByRole("option", { name: "Report a Bug …", exact: true })).toBeVisible(); + await page.getByRole("option", { name: "Quick Guide …", exact: true }).click(); + await expect(page.getByRole("dialog", { name: "Quick Guide (German)" })).toBeVisible(); +}); + +test("Flächen-Nachweis im leeren Projekt: Hinweis statt Nullen, mit Bauteilen exportiert", async ({ page }) => { + await startNewProject(page); + await openTab(page, "Flächenbilanz"); + const downloads: string[] = []; + page.on("download", (d) => downloads.push(d.suggestedFilename())); + await page.getByRole("button", { name: "CSV", exact: true }).first().click(); + await expect(page.getByText("Noch keine Bauteile — der Nachweis wäre leer.")).toBeVisible(); + await shot(page, "csv-empty"); + expect(downloads).toEqual([]); + await fileMenu(page, /^Neu aus Vorlage: Wettbewerb$/); + await discardIfAsked(page); + await openTab(page, "Flächenbilanz"); + const dl = page.waitForEvent("download"); + await page.getByRole("button", { name: "CSV", exact: true }).first().click(); + expect((await dl).suggestedFilename()).toMatch(/\.csv$/); +}); diff --git a/src/core/extra.ts b/src/core/extra.ts index 8042cab7..71ae79d4 100644 --- a/src/core/extra.ts +++ b/src/core/extra.ts @@ -49,7 +49,7 @@ export { exportProjectName, competitionIdentity, isAnonymous, competitionKeyword export type { CompetitionIdentity } from "../export/competitionIdentity"; export { anonymityFindings } from "../export/competitionCheck"; export type { AnonymityFinding, AnonymityKind } from "../export/competitionCheck"; -export { buildAreaReport, areaReportToCsv, parseAreaReportCsv, areaReportToSvg, buildAreaReportPdf } from "../export/areaReport"; +export { isAreaReportEmpty, buildAreaReport, areaReportToCsv, parseAreaReportCsv, areaReportToSvg, buildAreaReportPdf } from "../export/areaReport"; export { setPdfFontLoader } from "../export/pdfFonts"; export type { AreaReport, AreaReportOptions } from "../export/areaReport"; export { sunPosition, shadowPolygons, shadowOfPrism, projectLatLon } from "../analysis/sun"; diff --git a/src/export/areaReport.test.ts b/src/export/areaReport.test.ts index 95d83170..af217e4e 100644 --- a/src/export/areaReport.test.ts +++ b/src/export/areaReport.test.ts @@ -1,8 +1,8 @@ import { describe, expect, it } from "vitest"; -import { sampleProject } from "../model/sampleProject"; +import { emptyProject, sampleProject } from "../model/sampleProject"; import type { Project, Room, Wall } from "../model/types"; import { computeAreaTable, computeIvhb } from "../analysis/areaTable"; -import { areaReportToCsv, areaReportToSvg, buildAreaReport, buildAreaReportPdf, layoutAreaReport, parseAreaReportCsv } from "./areaReport"; +import { isAreaReportEmpty, areaReportToCsv, areaReportToSvg, buildAreaReport, buildAreaReportPdf, layoutAreaReport, parseAreaReportCsv } from "./areaReport"; // Einfaches Haus: Achsen 10 × 8 m, Wände 0.3 m, EG-Räume innen 9.7 × 7.7 m (Handrechnung siehe flaechen.rs). function house(): Project { @@ -113,3 +113,10 @@ describe("Bericht", () => { expect(lay.pages.length).toBeGreaterThan(1); }); }); + +describe("isAreaReportEmpty [263]", () => { + it("leeres Projekt: leer; Musterhaus: nicht leer", () => { + expect(isAreaReportEmpty(emptyProject)).toBe(true); + expect(isAreaReportEmpty(sampleProject)).toBe(false); + }); +}); diff --git a/src/export/areaReport.ts b/src/export/areaReport.ts index d71ff6c2..0ea415bd 100644 --- a/src/export/areaReport.ts +++ b/src/export/areaReport.ts @@ -65,6 +65,12 @@ function areaCells(r: AreaRow): Cell[] { return [r.hnf, r.nnf, r.nf, r.vf, r.ff, r.ngf, r.kf, r.gf, r.agf].map((v) => num(v, 2)).concat(num(r.gv, 1)); } +/** [263] Ohne Bauteile (kein Raum, keine Fläche, kein Volumen) wäre der Nachweis nur Nullen: dann kein Export, sondern ein Hinweis. */ +export function isAreaReportEmpty(project: Project): boolean { + const { total, gv } = computeAreaTable(project); + return [total.hnf, total.nnf, total.vf, total.ff, total.kf, total.gf, total.agf, total.rooms, gv].every((v) => !(Math.abs(v) > 0)); +} + /** Baut den Bericht aus dem Projekt. */ export function buildAreaReport(project: Project, opts: AreaReportOptions = {}): AreaReport { const sections: ReportSection[] = []; diff --git a/src/i18n/de.ts b/src/i18n/de.ts index 51235ebf..3cebae9e 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -2607,6 +2607,7 @@ export const de = { "areas.basisInput": "aGF der AZ", "areas.includeUnderground": "Untergeschosse anrechnen", "areas.exportCsv": "CSV", + "areas.export.empty": "Noch keine Bauteile — der Nachweis wäre leer. Es wurde nichts exportiert.", "areas.exportPdf": "PDF", "areas.exportPdf.fail": "PDF konnte nicht erstellt werden.", "areas.noLevels": "Keine Geschosse mit Räumen.", @@ -4464,6 +4465,10 @@ export const de = { "menu.help": "Hilfe", "menu.help.shortcuts": "Tastaturkürzel …", "menu.help.about": "Über dossier …", + "menu.help.guide": "Kurzanleitung …", + "menu.help.bugReport": "Fehler melden …", + "help.guide.title": "Kurzanleitung", + "help.bugReport.body": "Version: {version}\n\nWas ist passiert?\n\nWas hast du erwartet?\n\nSchritte zum Nachstellen:\n1. \n", "help.shortcuts.title": "Tastaturkürzel", "help.shortcuts.intro": "Tastenkombinationen und Befehlskürzel, wie sie gerade gelten (inklusive eigener Änderungen aus den Einstellungen).", "help.shortcuts.filter": "Suchen …", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 1692c6a0..8d1fa019 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -2595,6 +2595,7 @@ export const en: Record = { "areas.basisInput": "aGF for AZ", "areas.includeUnderground": "Credit underground levels", "areas.exportCsv": "CSV", + "areas.export.empty": "No building elements yet — the report would be empty. Nothing was exported.", "areas.exportPdf": "PDF", "areas.exportPdf.fail": "Could not create the PDF.", "areas.noLevels": "No levels with rooms.", @@ -4450,6 +4451,10 @@ export const en: Record = { "menu.help": "Help", "menu.help.shortcuts": "Keyboard Shortcuts …", "menu.help.about": "About dossier …", + "menu.help.guide": "Quick Guide …", + "menu.help.bugReport": "Report a Bug …", + "help.guide.title": "Quick Guide (German)", + "help.bugReport.body": "Version: {version}\n\nWhat happened?\n\nWhat did you expect?\n\nSteps to reproduce:\n1. \n", "help.shortcuts.title": "Keyboard Shortcuts", "help.shortcuts.intro": "Key combinations and command aliases as they apply now (including your changes from Settings).", "help.shortcuts.filter": "Search …", diff --git a/src/native/appMenu.ts b/src/native/appMenu.ts index 9a995080..70b78659 100644 --- a/src/native/appMenu.ts +++ b/src/native/appMenu.ts @@ -17,6 +17,7 @@ import { isTauriRuntime } from "./projectFile"; import { t } from "../i18n"; import { openRenderDialog } from "../state/renderDialogHook"; import { openShortcutOverview } from "../state/shortcutOverviewHook"; +import { openBugReport, openQuickGuide } from "../state/helpMenuHook"; import { openImageExportDialog } from "../state/imageExportDialogHook"; import { APP_VERSION } from "../ui/TopBar"; import { BUILD_INFO } from "../update/buildInfo"; @@ -502,14 +503,22 @@ export function useNativeAppMenu( ], }); - // [210] Hilfe → Tastaturkürzel (Overlay-Dialog in der App). + // [210] Hilfe → Tastaturkürzel (Overlay-Dialog in der App); [263] Kurzanleitung (Dialog), Fehler melden (System-Browser). const helpMenu = await Submenu.new({ text: t("menu.help"), items: [ + await MenuItem.new({ + text: t("menu.help.guide"), + action: () => openQuickGuide(), + }), await MenuItem.new({ text: t("menu.help.shortcuts"), action: () => openShortcutOverview(), }), + await MenuItem.new({ + text: t("menu.help.bugReport"), + action: () => openBugReport(), + }), ], }); diff --git a/src/panels/AreaTableSection.tsx b/src/panels/AreaTableSection.tsx index 28e4075f..c1247b99 100644 --- a/src/panels/AreaTableSection.tsx +++ b/src/panels/AreaTableSection.tsx @@ -8,7 +8,7 @@ import { useMemo, useState } from "react"; import { t } from "../i18n"; -import { exportProjectName, areaReportToCsv, buildAreaReport, buildAreaReportPdf } from "../core"; +import { exportProjectName, areaReportToCsv, buildAreaReport, buildAreaReportPdf, isAreaReportEmpty } from "../core"; import type { AgfBasis } from "../core"; import { DEFAULT_AREA_INPUTS, ivhbOptionsOf, type AreaInputs } from "./areaInputs"; import { downloadCsv } from "./downloadFile"; @@ -29,7 +29,18 @@ export function AreaTableSection() { const set = (patch: Partial) => setInputs((i) => ({ ...i, ...patch })); const stem = `${exportProjectName(project) || "projekt"}-flaechen`; + // [263] Leeres Projekt: kein Export von Nullen, sondern ein Hinweis (sonst sähe die Datei wie ein Ergebnis aus). + const emptyHint = () => { + if (!isAreaReportEmpty(project)) return false; + notify(t("areas.export.empty")); + return true; + }; + const exportCsv = () => { + if (emptyHint()) return; + runWithAnonymityGate(project, [`${stem}.csv`], () => downloadCsv(`${stem}.csv`, areaReportToCsv(report))); + }; const exportPdf = () => { + if (emptyHint()) return; runWithAnonymityGate(project, [`${stem}.pdf`], async () => { try { (await buildAreaReportPdf(report)).save(`${stem}.pdf`); @@ -44,7 +55,7 @@ export function AreaTableSection() {
{t("areas.title")} - + +
+ {blocks.map(renderBlock)} +
+
+ + ); +}); diff --git a/src/ui/miniMarkdown.test.ts b/src/ui/miniMarkdown.test.ts new file mode 100644 index 00000000..4e5c51cb --- /dev/null +++ b/src/ui/miniMarkdown.test.ts @@ -0,0 +1,28 @@ +import { describe, expect, it } from "vitest"; +import { readFileSync } from "node:fs"; +import { join } from "node:path"; +import { parseInline, parseMarkdown } from "./miniMarkdown"; + +describe("miniMarkdown [263]", () => { + it("Inline: fett, kursiv, Code, Rest bleibt Text", () => { + expect(parseInline("a **b** *c* `d` e*")).toEqual([ + { t: "text", s: "a " }, { t: "b", s: "b" }, { t: "text", s: " " }, { t: "i", s: "c" }, { t: "text", s: " " }, + { t: "code", s: "d" }, { t: "text", s: " e*" }, + ]); + }); + it("Blöcke: Überschrift, Absatz über Zeilen, Listen mit Fortsetzung, Zitat, Bild, Linie", () => { + const b = parseMarkdown("# T\n\nzeile eins\nzeile zwei\n\n1. a\n weiter\n2. b\n\n- x\n\n> q\n> r\n\n![alt](p/a.png)\n\n---\n"); + expect(b.map((x) => x.t)).toEqual(["h", "p", "ol", "ul", "quote", "img", "hr"]); + expect((b[1] as { inl: { s: string }[] }).inl[0]!.s).toBe("zeile eins zeile zwei"); + expect((b[2] as { items: unknown[][] }).items).toHaveLength(2); + expect(b[5]).toEqual({ t: "img", alt: "alt", src: "p/a.png" }); + }); + it("die echte Kurzanleitung lässt sich lesen: Überschriften, Bilder, keine Rohzeichen", () => { + const md = readFileSync(join(process.cwd(), "doc", "KURZANLEITUNG.md"), "utf8"); + const b = parseMarkdown(md); + expect(b[0]).toMatchObject({ t: "h", level: 1 }); + expect(b.filter((x) => x.t === "h" && x.level === 2).length).toBeGreaterThanOrEqual(10); + expect(b.filter((x) => x.t === "img").length).toBe(5); + expect(JSON.stringify(b.filter((x) => x.t !== "img"))).not.toContain("**"); + }); +}); diff --git a/src/ui/miniMarkdown.ts b/src/ui/miniMarkdown.ts new file mode 100644 index 00000000..c78a11b9 --- /dev/null +++ b/src/ui/miniMarkdown.ts @@ -0,0 +1,77 @@ +// [263] Minimaler Markdown-Leser für die Kurzanleitung (doc/KURZANLEITUNG.md) im Hilfe-Dialog: Überschriften, Absätze, +// Listen (`-`, `1.`), Zitate, Trennlinie, Bilder und im Text **fett**, *kursiv*, `Code`. Mehr braucht das Dokument nicht; +// Tabellen/Codeblöcke gibt es dort nicht. Reine Funktion (Test `miniMarkdown.test.ts`), die Darstellung steht in +// `QuickGuideDialog.tsx` (kein dangerouslySetInnerHTML). + +export type Inline = { t: "text" | "b" | "i" | "code"; s: string }; +export type Block = + | { t: "h"; level: 1 | 2 | 3; inl: Inline[] } + | { t: "p"; inl: Inline[] } + | { t: "quote"; inl: Inline[] } + | { t: "ul" | "ol"; items: Inline[][] } + | { t: "img"; alt: string; src: string } + | { t: "hr" }; + +/** Zerlegt eine Zeile in Text-, Fett-, Kursiv- und Code-Stücke. Unabgeschlossene Zeichen bleiben Text. */ +export function parseInline(src: string): Inline[] { + const out: Inline[] = []; + const re = /`([^`]+)`|\*\*([^*]+)\*\*|\*([^*\s][^*]*)\*/g; + let last = 0; + for (const m of src.matchAll(re)) { + if (m.index! > last) out.push({ t: "text", s: src.slice(last, m.index) }); + if (m[1] !== undefined) out.push({ t: "code", s: m[1] }); + else if (m[2] !== undefined) out.push({ t: "b", s: m[2] }); + else out.push({ t: "i", s: m[3]! }); + last = m.index! + m[0].length; + } + if (last < src.length) out.push({ t: "text", s: src.slice(last) }); + return out; +} + +export function parseMarkdown(md: string): Block[] { + const lines = md.replace(/\r\n?/g, "\n").split("\n"); + const blocks: Block[] = []; + let para: string[] = []; + let quote: string[] = []; + let list: { t: "ul" | "ol"; items: string[] } | null = null; + const flush = () => { + if (para.length) blocks.push({ t: "p", inl: parseInline(para.join(" ")) }); + if (quote.length) blocks.push({ t: "quote", inl: parseInline(quote.join(" ")) }); + if (list) blocks.push({ t: list.t, items: list.items.map(parseInline) }); + para = []; + quote = []; + list = null; + }; + for (const raw of lines) { + const line = raw.trimEnd(); + let m: RegExpMatchArray | null; + if (!line.trim()) flush(); + else if ((m = line.match(/^(#{1,3})\s+(.*)$/))) { + flush(); + blocks.push({ t: "h", level: m[1]!.length as 1 | 2 | 3, inl: parseInline(m[2]!) }); + } else if (/^-{3,}$/.test(line)) { + flush(); + blocks.push({ t: "hr" }); + } else if ((m = line.match(/^!\[([^\]]*)\]\(([^)]+)\)$/))) { + flush(); + blocks.push({ t: "img", alt: m[1]!, src: m[2]! }); + } else if ((m = line.match(/^>\s?(.*)$/))) { + if (!quote.length) flush(); + quote.push(m[1]!); + } else if ((m = line.match(/^(?:([-*])|(\d+)\.)\s+(.*)$/))) { + const kind = m[1] ? "ul" : "ol"; + if (!list || list.t !== kind) { + flush(); + list = { t: kind, items: [] }; + } + list.items.push(m[3]!); + } else if (list && /^\s+\S/.test(raw)) { + list.items[list.items.length - 1] += " " + line.trim(); // Fortsetzungszeile eines Listenpunkts + } else { + if (quote.length || list) flush(); + para.push(line.trim()); + } + } + flush(); + return blocks; +} diff --git a/src/update/bugReport.test.ts b/src/update/bugReport.test.ts new file mode 100644 index 00000000..ac91c0cc --- /dev/null +++ b/src/update/bugReport.test.ts @@ -0,0 +1,12 @@ +import { describe, expect, it } from "vitest"; +import { BUG_REPORT_URL, bugReportUrl } from "./bugReport"; + +describe("bugReportUrl [263]", () => { + it("zeigt auf die Issue-Seite und trägt nur Version und Build", () => { + const url = bugReportUrl("Version: {version}\n\nWas passiert?", "Build", { version: "1.0.0-beta.1", build: "261116.1" }); + expect(url.startsWith(`${BUG_REPORT_URL}?body=`)).toBe(true); + const body = decodeURIComponent(url.split("?body=")[1]!); + expect(body).toBe("Version: 1.0.0-beta.1 (Build 261116.1)\n\nWas passiert?"); + expect(new URL(url).hostname).toBe("git.openbureau.ch"); + }); +}); diff --git a/src/update/bugReport.ts b/src/update/bugReport.ts new file mode 100644 index 00000000..95253d0f --- /dev/null +++ b/src/update/bugReport.ts @@ -0,0 +1,12 @@ +// [263] Hilfe → „Fehler melden …“: Adresse der Issue-Seite im Gitea des Projekts, mit Version und Build vorbefüllt. +// Bewusst nichts weiter (keine Projektdaten, kein Dateiname, keine Systemangaben): die Person ergänzt selbst. + +import { BUILD_INFO, formatBuildInfo, type BuildInfo } from "./buildInfo"; + +export const BUG_REPORT_URL = "https://git.openbureau.ch/karim/dossier/issues/new"; + +/** `versionLine` kommt fertig übersetzt (z. B. „Version 1.0.0-beta.1 (Build 261115.1)“), `bodyTemplate` enthält `{version}`. */ +export function bugReportUrl(bodyTemplate: string, buildWord: string, info: BuildInfo = BUILD_INFO): string { + const body = bodyTemplate.replace("{version}", formatBuildInfo(info, buildWord)); + return `${BUG_REPORT_URL}?body=${encodeURIComponent(body)}`; +}