[255] UI-Review: Fenster-/Türliste und Raumbuch als Zeilenkarten in der schmalen Dock-Spalte (gemeinsame Komponente CardTable)
This commit is contained in:
6 files changed
+77
-9
No files matched your search
@@ -0,0 +1,39 @@
|
||||
// Gemeinsame Tabelle für breite Berichte im Dock (Fenster-/Türliste, Raumbuch …).
|
||||
//
|
||||
// • Breites Dock: normale Tabelle, bei Bedarf waagrecht scrollbar (Umhüllung `.area-scroll`, setzt der Aufrufer).
|
||||
// • Schmale Dock-Spalte (Container-Query in styles.css, ≤ 460 px): jede Zeile wird zur Karte — erste Zelle als
|
||||
// Titel, die übrigen als Raster „Kopf über Wert“. Der Kopf steht in `data-label` der Zelle; diese Komponente
|
||||
// setzt ihn aus der Kopfzeile, damit die Zellen nichts davon wissen müssen. Leere Zellen entfallen in der Karte.
|
||||
// • Es ändert sich nur die Darstellung: Zellen, Eingaben, CSV und PDF bleiben dieselben.
|
||||
|
||||
import { useLayoutEffect, useRef, type ReactNode } from "react";
|
||||
|
||||
export function CardTable({ className = "", children, testId }: { className?: string; children: ReactNode; testId?: string }) {
|
||||
const ref = useRef<HTMLTableElement>(null);
|
||||
// Nach jedem Rendern: Spaltenköpfe in die Zellen der jeweiligen Spalte kopieren (Zellen mit colSpan überspringen).
|
||||
useLayoutEffect(() => {
|
||||
const table = ref.current;
|
||||
if (!table) return;
|
||||
const heads = Array.from(table.tHead?.rows[0]?.cells ?? []).map((th) => th.textContent?.trim() ?? "");
|
||||
for (const body of Array.from(table.tBodies)) {
|
||||
for (const row of Array.from(body.rows)) {
|
||||
Array.from(row.cells).forEach((cell, i) => {
|
||||
const label = i > 0 && cell.colSpan === 1 ? heads[i] : "";
|
||||
if (label) {
|
||||
if (cell.dataset.label !== label) cell.dataset.label = label;
|
||||
// Längere Textzellen (Typname, Räume, Oberflächen) belegen in der Karte mehrere Rasterspalten.
|
||||
const len = cell.querySelector("input,select,button") ? 0 : (cell.textContent ?? "").length;
|
||||
const span = len > 22 ? "3" : len > 9 || cell.querySelector("select") ? "2" : "";
|
||||
if (span) cell.dataset.span = span;
|
||||
else delete cell.dataset.span;
|
||||
} else if (cell.dataset.label !== undefined) delete cell.dataset.label;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return (
|
||||
<table ref={ref} className={`area-table wide ${className}`.trim()} data-testid={testId}>
|
||||
{children}
|
||||
</table>
|
||||
);
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
// Räumen); die Kennwert-Felder sind direkt in der Tabelle editierbar (Ops mit coalesceKey: Tippen = ein
|
||||
// Undo-Schritt). CSV und PDF kommen aus demselben Berichtsmodell wie der Flächennachweis.
|
||||
|
||||
import { CardTable } from "./CardTable";
|
||||
import { useMemo } from "react";
|
||||
import { t } from "../i18n";
|
||||
import { usePanelHost } from "./host";
|
||||
@@ -71,7 +72,7 @@ export function OpeningScheduleSection() {
|
||||
<div className="balance-empty">{t("openings.empty")}</div>
|
||||
) : (
|
||||
<div className="area-scroll">
|
||||
<table className="area-table opening-table">
|
||||
<CardTable className="opening-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{t("openings.col.mark")}</th>
|
||||
@@ -154,7 +155,7 @@ export function OpeningScheduleSection() {
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</CardTable>
|
||||
</div>
|
||||
)}
|
||||
<ul className="area-notes">
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// (`roomBook`); bearbeitet werden die Angaben in der Objekt-Info des Raums. CSV und PDF kommen aus
|
||||
// demselben Berichtsmodell wie die Fenster-/Türliste.
|
||||
|
||||
import { CardTable } from "./CardTable";
|
||||
import { useMemo } from "react";
|
||||
import { t } from "../i18n";
|
||||
import { exportProjectName, areaReportToCsv, buildAreaReportPdf, buildRoomBookReport, hasSlope, roomBook, usageLabel } from "../core";
|
||||
@@ -48,7 +49,7 @@ export function RoomBookSection() {
|
||||
<div className="balance-empty">{t("roomBook.empty")}</div>
|
||||
) : (
|
||||
<div className="area-scroll">
|
||||
<table className="area-table opening-table room-book-table">
|
||||
<CardTable className="opening-table room-book-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{t("openings.col.floor")}</th>
|
||||
@@ -99,9 +100,9 @@ export function RoomBookSection() {
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</CardTable>
|
||||
{book.quantities.length > 0 && (
|
||||
<table className="area-table opening-table room-book-table">
|
||||
<CardTable className="opening-table room-book-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{t("roomBook.col.surface")}</th>
|
||||
@@ -120,7 +121,7 @@ export function RoomBookSection() {
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</CardTable>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user