From 55db1d1363f4e04e82162c670fc57f9a05d5b270 Mon Sep 17 00:00:00 2001 From: Scarriffle Date: Thu, 30 Jul 2026 14:36:04 +0200 Subject: [PATCH] Web: Einkaufsliste-Karte zum Abhaken (wie die volle Seite) Die Karte zeigte die Bedarfe als Tabelle ohne Haekchen. Jetzt als abhakbare Checklist (Gesamt + je Lagerort) mit Durchstreichen beim Abhaken - dieselbe Bedienung wie die Einkaufslisten-Seite. Abhaken ist sitzungslokal (wie dort auch, noch nicht dauerhaft gespeichert). Co-Authored-By: Claude Opus 4.8 --- web/src/dashboard/cards.jsx | 81 +++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 31 deletions(-) diff --git a/web/src/dashboard/cards.jsx b/web/src/dashboard/cards.jsx index a04a78f..58ef4ba 100644 --- a/web/src/dashboard/cards.jsx +++ b/web/src/dashboard/cards.jsx @@ -312,6 +312,7 @@ function KarteAblauf({ modus = "alle" }) { */ function KarteEinkaufsliste({ props: karteProps }) { const ortId = karteProps?.location_id || ""; + const [erledigt, setErledigt] = useState({}); // abgehakte Zeilen (nur in dieser Sitzung) const { daten, fehler } = useDaten(async () => { const [produkte, gruppen, orte] = await Promise.all([ api.shoppingList(), api.groupShoppingList(), api.shoppingByLocation(), @@ -327,49 +328,67 @@ function KarteEinkaufsliste({ props: karteProps }) { const orteLeer = orte.every((o) => !o.products.length && !o.groups.length); if (gesamtLeer && orteLeer) return
Alle Mindestbestände erreicht.
; - // Ein Abschnitt (Gesamt oder ein Ort). Die Produkt-Formatierung kommt herein, - // weil Gesamt-Produkte Gebinde/Basiseinheit tragen, je-Ort-Bedarfe aber schon - // eine fertige Einheit (unit_label). - const abschnitt = (gruppen, produkte, prodWert) => ( -
- - - - {gruppen.map((it) => ( - - - - - - ))} - {produkte.map((it) => ( - - - - - - ))} - -
BedarfBestandFehlt
Gruppe {it.name}{fmt(it.stock)} {it.unit_name}{fmt(it.deficit)} {it.unit_name}
{it.name}{prodWert(it, "stock")}{prodWert(it, "deficit")}
-
+ const abhaken = (key, val) => setErledigt((e) => ({ ...e, [key]: val })); + + // Ein Abschnitt (Gesamt oder ein Ort) als abhakbare Liste – wie die volle Seite. + // `prefix` macht die Schlüssel über die Abschnitte hinweg eindeutig, `prodInfo` + // formatiert die Produktzeile (Gesamt trägt Gebinde/Basiseinheit, je-Ort schon + // eine fertige Einheit). + const abschnitt = (gruppen, produkte, prefix, prodInfo) => ( + + ); + const gesamtInfo = (it) => ( + <>fehlt {amountText(it.deficit, it.package_size, it.base_unit)}{" "} + (Bestand {amountText(it.stock, it.package_size, it.base_unit)}) + ); + const ortInfo = (it) => ( + <>fehlt {fmt(it.deficit)} {it.unit_label}{" "} + (Bestand {fmt(it.stock)} / min {fmt(it.min_stock)}) ); - const gesamtProd = (it, feld) => amountText(it[feld], it.package_size, it.base_unit); - const ortProd = (it, feld) => `${fmt(it[feld])} ${it.unit_label}`; return (
{!gesamtLeer && (
-
Gesamt
- {abschnitt(daten.gruppen, daten.produkte, gesamtProd)} +
Gesamt
+ {abschnitt(daten.gruppen, daten.produkte, "", gesamtInfo)}
)} {orte.map((o) => ((o.products.length || o.groups.length) ? (
-
+
{o.location_name}
- {abschnitt(o.groups, o.products, ortProd)} + {abschnitt(o.groups, o.products, `l${o.location_id}`, ortInfo)}
) : null))}