From a5279bb01dc9911cef9284989f28ae3ae85b9d92 Mon Sep 17 00:00:00 2001 From: Henrik Jess Nielsen Date: Fri, 30 Oct 2026 12:41:28 +0100 Subject: [PATCH 1/3] =?UTF-8?q?feat(tilbud):=20'G=C3=A5=20til=20seddel'=20?= =?UTF-8?q?button=20showing=20how=20many=20offers=20are=20selected?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ticking an offer already adds it to the shopping list instantly (it shows in the Lübeck-tilbud section), but that wasn't visible. Add a fixed 'N valgt · Gå til seddel' button that appears once anything is selected, so the link between the checklist and the list is obvious and you can jump straight to it. --- templates/tilbud.html | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/templates/tilbud.html b/templates/tilbud.html index 55e0809..5a71be0 100644 --- a/templates/tilbud.html +++ b/templates/tilbud.html @@ -117,14 +117,27 @@ {% endfor %} + + + From 32e6841b8c702a731af187e20fb60b9189405343 Mon Sep 17 00:00:00 2001 From: Henrik Jess Nielsen Date: Fri, 30 Oct 2026 12:45:55 +0100 Subject: [PATCH 2/3] feat(stats): live 'Estimeret total' reflecting the actual list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Estimeret total was a hardcoded ~4.400. Make it dynamic: every list row (fixed catalog, added extras, picked Lübeck offers) carries data-est in DKK, and recalcAll sums them, so the tile updates live when you add/remove items or pick/unpick offers. 'Faktisk betalt' was already live; the Aftensmadsdage and Kødportioner tiles stay as illustrative figures. --- templates/index.html | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/templates/index.html b/templates/index.html index 0bca1c8..4cd7d6a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -209,8 +209,8 @@
Estimeret total
-
~4.400
-
kr. inkl. Rema
+
—
+
kr. for listen
Faktisk betalt
@@ -259,7 +259,7 @@
{% endfor %} {% for e in by_sec.get(sec.id, []) %} -
+
{{ e.name }} @@ -282,7 +282,7 @@
{% for o in picks %} {% set ps = saved.get(o.id, {}) %} -
+
{{ o.heading_da or o.heading }} @@ -317,7 +317,7 @@ {% set sk_extras = by_sec.get(sk, []) %} {% if sk_extras %} {% for e in sk_extras %} -
+
{{ e.name }}{% if e.note %}{{ e.note }}{% endif %}
{% if e.price %}{{ "{:.2f}".format(e.price).replace(".",",") }}{% else %}—{% endif %}
@@ -352,7 +352,7 @@
{% for e in loose %} -
+
{{ e.name }}{% if e.note %}{{ e.note }}{% endif %}
{% if e.price %}{{ "{:.2f}".format(e.price).replace(".",",") }}{% else %}—{% endif %}
@@ -547,6 +547,12 @@ function recalcAll() { ['s-total-citti','s-total-all','stat-actual'].forEach(id => document.getElementById(id).textContent = '—'); document.getElementById('total-savings').textContent = '~1.800'; } + + // Estimeret total = whole current list (fixed catalog + added items + + // picked offers), live from each row's data-est. Reflects add/remove/pick. + let est = 0; + document.querySelectorAll('[data-est]').forEach(r => { est += parseFloat(r.dataset.est) || 0; }); + document.getElementById('stat-est').textContent = est > 0 ? Math.round(est).toLocaleString('da-DK') : '—'; } // Item modal @@ -616,14 +622,17 @@ function appendExtraToSection(data) { const noteHtml = data.note ? `${data.note}` : ''; const row = document.createElement('div'); row.className = 'extra-item-row'; row.id = `extra-${data.id}`; + row.dataset.est = data.price || 0; row.innerHTML = `
${data.name}${noteHtml}
${priceStr}
`; table.appendChild(row); + recalcAll(); } async function deleteExtra(id, btn) { if (!confirm('Slet denne vare?')) return; await fetch(`/api/item/${id}`, {method: 'DELETE'}); document.getElementById(`extra-${id}`).remove(); + recalcAll(); } // Category modal @@ -697,6 +706,7 @@ async function removeOffer(id) { if (!document.querySelectorAll('#picks-table .item-row').length) { document.getElementById('sec-picks').style.display = 'none'; } + recalcAll(); showSaved(); } From dc53fbfb9b05b30672f98346f35808d89072d6ce Mon Sep 17 00:00:00 2001 From: Henrik Jess Nielsen Date: Fri, 30 Oct 2026 12:51:24 +0100 Subject: [PATCH 3/3] =?UTF-8?q?feat(stats):=20compute=20K=C3=B8dportioner?= =?UTF-8?q?=20and=20Aftensmadsdage=20from=20the=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both tiles were hardcoded. Parse the quantity strings (6 × ½ kg, 3 kg, ~700g, 2 stk.) live: Kødportioner = total Kød & fisk weight / 500g; Aftensmadsdage = meat portions + pasta/tortelloni packs. Recomputed on load and whenever a quantity changes, so the trip's food volume is visible while editing. Defaults now read ~30 portions / ~36 dinners. --- templates/index.html | 45 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/templates/index.html b/templates/index.html index 4cd7d6a..8b10d7c 100644 --- a/templates/index.html +++ b/templates/index.html @@ -199,12 +199,12 @@
Aftensmadsdage
-
~40
-
fra én tur
+
—
+
kød + pasta-retter
Kødportioner
-
24
+
—
à 500g i fryseren
@@ -523,10 +523,47 @@ function updateQty(input) { input.classList.toggle('modified', input.value.trim() !== '' && input.value.trim() !== defaultQty); const price = parseFloat(row.querySelector('.item-actual input').value); const checked = row.querySelector('input[type=checkbox]').checked ? 1 : 0; + computeMeals(); // meat portions / dinner days react to qty clearTimeout(debounceTimers[key + '_qty']); debounceTimers[key + '_qty'] = setTimeout(() => saveToServer(key, isNaN(price) ? null : price, checked), 600); } +// Parse a Danish quantity string ("6 × ½ kg", "3 kg", "~700g", "2 stk.") into +// kilograms / pack count, for the meat-portions and dinner-days estimates. +function qtyToKg(s) { + if (!s) return 0; + s = s.toLowerCase().replace(/~/g, '').replace(',', '.') + .replace(/½/g, '0.5').replace(/¼/g, '0.25').replace(/¾/g, '0.75'); + let m = s.match(/([\d.]+)\s*[×x]\s*([\d.]+)\s*kg/); + if (m) return parseFloat(m[1]) * parseFloat(m[2]); + m = s.match(/([\d.]+)\s*[×x]\s*([\d.]+)\s*g\b/); + if (m) return parseFloat(m[1]) * parseFloat(m[2]) / 1000; + m = s.match(/([\d.]+)\s*kg/); + if (m) return parseFloat(m[1]); + m = s.match(/([\d.]+)\s*g\b/); + if (m) return parseFloat(m[1]) / 1000; + return 0; +} +function qtyToPacks(s) { + const m = (s || '').match(/([\d.]+)\s*stk/i); + return m ? parseFloat(m[1]) : 0; +} +function curQty(row) { + const inp = row.querySelector('.item-qty input'); + return inp ? (inp.value.trim() || inp.placeholder) : ''; +} +function computeMeals() { + let meatKg = 0; + document.querySelectorAll('#sec-koed .item-row').forEach(r => { meatKg += qtyToKg(curQty(r)); }); + let packs = 0; + document.querySelectorAll('#sec-pasta .item-row').forEach(r => { packs += qtyToPacks(curQty(r)); }); + const portions = Math.round(meatKg / 0.5); + const dp = document.getElementById('stat-portions'); + const dd = document.getElementById('stat-days'); + if (dp) dp.textContent = portions > 0 ? portions : '—'; + if (dd) dd.textContent = (portions + Math.round(packs)) > 0 ? (portions + Math.round(packs)) : '—'; +} + function recalcAll() { const sections = document.querySelectorAll('.items-table'); let totalActual = 0; let hasAny = false; @@ -553,6 +590,8 @@ function recalcAll() { let est = 0; document.querySelectorAll('[data-est]').forEach(r => { est += parseFloat(r.dataset.est) || 0; }); document.getElementById('stat-est').textContent = est > 0 ? Math.round(est).toLocaleString('da-DK') : '—'; + + computeMeals(); } // Item modal