diff --git a/app.js b/app.js index 119e031..23b9af9 100644 --- a/app.js +++ b/app.js @@ -488,7 +488,7 @@ function switchTab(tab) { }); if (tab === "batches") { batchStateFilter.value = "!done"; - sortField = "name"; + sortField = "batch_id"; sortAsc = true; loadBatches(); } @@ -523,15 +523,11 @@ async function loadBatches() { const data = await parseJson(res); console.log("[HR] Batches response:", data); - // Response can be { data: [...] } or an array wrapping it - if (data && Array.isArray(data.data)) { + // Response is a flat array of batch objects + if (Array.isArray(data)) { + allBatches = data; + } else if (data && Array.isArray(data.data)) { allBatches = data.data; - } else if ( - Array.isArray(data) && - data.length > 0 && - Array.isArray(data[0].data) - ) { - allBatches = data[0].data; } else { allBatches = []; } @@ -544,6 +540,14 @@ async function loadBatches() { } } +// Description can be a string or an object like { en_US: "...", de_DE: "..." } +function getDescription(desc) { + if (!desc) return ""; + if (typeof desc === "string") return desc; + // Prefer de_DE, fall back to en_US, then any value + return desc.de_DE || desc.en_US || Object.values(desc)[0] || ""; +} + function sortBatches(field) { if (sortField === field) { sortAsc = !sortAsc; @@ -568,10 +572,10 @@ function renderBatches() { // Text search if (!query) return true; + const desc = getDescription(b.description); return ( - (b.name && b.name.toLowerCase().includes(query)) || - (b.description && b.description.toLowerCase().includes(query)) || - (b.carrier && b.carrier.toLowerCase().includes(query)) + (b.batch_id && b.batch_id.toLowerCase().includes(query)) || + (desc && desc.toLowerCase().includes(query)) ); }); @@ -590,7 +594,7 @@ function renderBatches() { if (filtered.length === 0) { batchList.innerHTML = - 'No batches match'; + 'No batches match'; return; } @@ -598,10 +602,11 @@ function renderBatches() { .map( (b) => ` - ${esc(b.name)} - ${esc(b.description || "")} - ${esc(b.carrier || "")} + ${esc(b.batch_id)} + ${esc(getDescription(b.description))} ${esc(b.state || "open")} + ${esc(String(b.gepackt ?? ""))} + ${esc(String(b.ungepackt ?? ""))} `, ) .join(""); diff --git a/index.html b/index.html index 911481b..0c439ea 100644 --- a/index.html +++ b/index.html @@ -250,17 +250,16 @@ - - + + + diff --git a/styles.css b/styles.css index 8999886..b04d2ba 100644 --- a/styles.css +++ b/styles.css @@ -1169,6 +1169,14 @@ tbody td { color: #92400e; } +.batch-num-cell { + font-size: 13px; + font-weight: 600; + color: var(--text); + text-align: center; + white-space: nowrap; +} + .batch-empty { text-align: center; color: var(--text-muted);
Charge Name TransportBeschreibung SendOffen