From 71b91b50b433eee0e9936700ab027666f684fb49 Mon Sep 17 00:00:00 2001 From: ulfrxdev Date: Sun, 12 Apr 2026 00:04:07 +0200 Subject: [PATCH] Keep checked items in place within their category Co-Authored-By: Claude Opus 4.6 --- js/views/ShoppingList.js | 41 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/js/views/ShoppingList.js b/js/views/ShoppingList.js index 9334dc3..f1e3ba8 100644 --- a/js/views/ShoppingList.js +++ b/js/views/ShoppingList.js @@ -123,8 +123,6 @@ function renderBoard() { if (!root) return; const items = getKitchenItems(); - const unchecked = items.filter((i) => !i.checked); - const checked = items.filter((i) => i.checked); if (items.length === 0) { root.innerHTML = ` @@ -138,37 +136,20 @@ function renderBoard() { return; } - let html = ''; - - // Unchecked items grouped by category - if (unchecked.length > 0) { - const groups = groupItemsByCategory(unchecked); - html += groups.map(({ cat, items: catItems }) => { - const icon = CATEGORY_ICONS[cat] || 'fa-jar'; - return ` -
-
- -

${esc(categoryLabel(cat))}

- ${catItems.length} -
- ${catItems.map((item) => itemRowHtml(item)).join('')} -
`; - }).join(''); - } - - // Checked items at the bottom - if (checked.length > 0) { - html += ` -
+ const groups = groupItemsByCategory(items); + const html = groups.map(({ cat, items: catItems }) => { + const icon = CATEGORY_ICONS[cat] || 'fa-jar'; + const uncheckedCount = catItems.filter((i) => !i.checked).length; + return ` +
- -

Kupione

- ${checked.length} + +

${esc(categoryLabel(cat))}

+ ${uncheckedCount}/${catItems.length}
- ${checked.map((item) => itemRowHtml(item)).join('')} + ${catItems.map((item) => itemRowHtml(item)).join('')}
`; - } + }).join(''); root.innerHTML = html; bindRowEvents(root);