diff --git a/app.py b/app.py index a68b6f7..7d8498b 100644 --- a/app.py +++ b/app.py @@ -650,6 +650,7 @@ def view_list(list_id): percent=percent, expenses=expenses, total_expense=total_expense, + is_share=False ) @@ -675,6 +676,7 @@ def shared_list(token=None, list_id=None): receipt_files=receipt_files, expenses=expenses, total_expense=total_expense, + is_share=True ) @@ -1650,6 +1652,7 @@ def handle_request_full_list(data): "quantity": item.quantity, "purchased": item.purchased if not item.not_purchased else False, "not_purchased": item.not_purchased, + 'not_purchased_reason': item.not_purchased_reason, "note": item.note or "", } ) diff --git a/static/js/functions.js b/static/js/functions.js index e88c39a..8e57518 100644 --- a/static/js/functions.js +++ b/static/js/functions.js @@ -379,9 +379,6 @@ function updateListSmoothly(newItems) { const fragment = document.createDocumentFragment(); newItems.forEach(item => { - // 🔥 Logujemy każdy item - console.log('Item:', item.name, 'Purchased:', item.purchased, 'Not purchased:', item.not_purchased); - let li = existingItemsMap.get(item.id); let quantityBadge = ''; if (item.quantity && item.quantity > 1) { @@ -394,7 +391,7 @@ function updateListSmoothly(newItems) { li.id = `item-${item.id}`; } - // Ustaw klasy tła + // Klasy tła li.className = `list-group-item d-flex justify-content-between align-items-center flex-wrap clickable-item ${ item.purchased ? 'bg-success text-white' : item.not_purchased ? 'bg-warning text-dark' : 'item-not-checked' @@ -411,6 +408,7 @@ function updateListSmoothly(newItems) { `} ${item.name} ${quantityBadge} ${item.note ? `[ ${item.note} ]` : ''} + ${item.not_purchased_reason ? `[ Powód: ${item.not_purchased_reason} ]` : ''}
${item.not_purchased ? ` @@ -423,11 +421,23 @@ function updateListSmoothly(newItems) { onclick="markNotPurchasedModal(event, ${item.id})"> ⚠️ - + ${window.IS_SHARE ? ` + + ` : ''} `} + ${!window.IS_SHARE ? ` + + + ` : ''}
`; @@ -442,6 +452,7 @@ function updateListSmoothly(newItems) { applyHidePurchased(); } + document.addEventListener("DOMContentLoaded", function() { const receiptSection = document.getElementById("receiptSection"); const toggleBtn = document.querySelector('[data-bs-target="#receiptSection"]'); diff --git a/static/js/notes.js b/static/js/notes.js index 3ac767c..5899c09 100644 --- a/static/js/notes.js +++ b/static/js/notes.js @@ -1,13 +1,13 @@ let currentItemId = null; -function openNoteModal(event, itemId) { +window.openNoteModal = function (event, itemId) { event.stopPropagation(); currentItemId = itemId; - const noteEl = document.querySelector(`#item-${itemId} small`); - document.getElementById('noteText').value = noteEl ? noteEl.innerText : ""; + const noteEl = document.querySelector(`#item-${itemId} small.text-danger`); + document.getElementById('noteText').value = noteEl ? noteEl.innerText.replace(/\[|\]|Powód:/g, "").trim() : ""; const modal = new bootstrap.Modal(document.getElementById('noteModal')); modal.show(); -} +}; function submitNote(e) { e.preventDefault(); diff --git a/templates/list.html b/templates/list.html index 382a300..a9583cd 100644 --- a/templates/list.html +++ b/templates/list.html @@ -87,40 +87,58 @@ Lista: {{ list.title }}