Chargen: Packungen als Leitangabe, Produkteinheit klein darunter
Anzeige getauscht - oben gross die Packungszahl, darunter klein die Menge in der Produkteinheit (z.B. "10 Pkg" / "1.945 Gramm"). Ohne Packungsgroesse bleibt die Produkteinheit die Leitangabe. Das Bearbeiten startet passend in Packungen; per Umschalter laesst sich weiterhin in der Produkteinheit eingeben. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -343,16 +343,14 @@ function LotsCard({ product, lots, baseShort, warnDays, isAdmin, imageUrl, onCha
|
|||||||
const unitName = product?.unit_name || baseShort;
|
const unitName = product?.unit_name || baseShort;
|
||||||
const pkgSize = product?.package_size || 0;
|
const pkgSize = product?.package_size || 0;
|
||||||
|
|
||||||
// Maßgeblich ist die im Produkt festgelegte Einheit.
|
// Leitangabe: Packungen, sobald eine Packungsgröße hinterlegt ist –
|
||||||
const primaryFactor = unitFactor;
|
// sonst die Produkteinheit. Darunter steht die jeweils andere Angabe klein.
|
||||||
const primaryLabel = unitName;
|
const primaryFactor = pkgSize > 0 ? pkgSize : unitFactor;
|
||||||
|
const primaryLabel = pkgSize > 0 ? "Pkg" : unitName;
|
||||||
|
|
||||||
// Untermengen: Basiseinheit (falls abweichend) und Packungen (falls hinterlegt).
|
|
||||||
function secondary(qty) {
|
function secondary(qty) {
|
||||||
const parts = [];
|
if (pkgSize > 0) return `${fmt(qty / unitFactor)} ${unitName}`;
|
||||||
if (unitFactor !== 1) parts.push(`${fmt(qty)} ${baseShort}`);
|
return unitFactor !== 1 ? `${fmt(qty)} ${baseShort}` : "";
|
||||||
if (pkgSize > 0) parts.push(`${fmt(qty / pkgSize)} Pkg`);
|
|
||||||
return parts.join(" · ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Faktor der aktuell im Editor gewählten Eingabeeinheit.
|
// Faktor der aktuell im Editor gewählten Eingabeeinheit.
|
||||||
@@ -362,9 +360,11 @@ function LotsCard({ product, lots, baseShort, warnDays, isAdmin, imageUrl, onCha
|
|||||||
const editFactor = editFactorOf(editUnit);
|
const editFactor = editFactorOf(editUnit);
|
||||||
|
|
||||||
function startEdit(l) {
|
function startEdit(l) {
|
||||||
|
// Bearbeiten startet in der Leitangabe (Packungen, falls vorhanden).
|
||||||
|
const mode = pkgSize > 0 ? "package" : "unit";
|
||||||
setEditId(l.id);
|
setEditId(l.id);
|
||||||
setEditUnit("unit");
|
setEditUnit(mode);
|
||||||
setDraft({ quantity: l.quantity / unitFactor, best_before: l.best_before || "" });
|
setDraft({ quantity: l.quantity / editFactorOf(mode), best_before: l.best_before || "" });
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeEditUnit(newMode) {
|
function changeEditUnit(newMode) {
|
||||||
@@ -429,8 +429,8 @@ function LotsCard({ product, lots, baseShort, warnDays, isAdmin, imageUrl, onCha
|
|||||||
{pkgSize > 0 ? (
|
{pkgSize > 0 ? (
|
||||||
<select value={editUnit} onChange={(e) => changeEditUnit(e.target.value)}
|
<select value={editUnit} onChange={(e) => changeEditUnit(e.target.value)}
|
||||||
style={{ maxWidth: 120, marginTop: 0 }}>
|
style={{ maxWidth: 120, marginTop: 0 }}>
|
||||||
<option value="unit">{unitName}</option>
|
|
||||||
<option value="package">Packung(en)</option>
|
<option value="package">Packung(en)</option>
|
||||||
|
<option value="unit">{unitName}</option>
|
||||||
</select>
|
</select>
|
||||||
) : (
|
) : (
|
||||||
<span className="muted small">{unitName}</span>
|
<span className="muted small">{unitName}</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user