From bb7bc37a3ec1c95c3268624b86495be45bc87ec7 Mon Sep 17 00:00:00 2001 From: ydb5755 Date: Tue, 29 Oct 2024 15:24:05 +0200 Subject: [PATCH] split up secitons for lines with parents and those without enable update vendor on enter --- app/static/line_items_by_month.js | 61 +++++++++++++++++--------- app/templates/line_items_by_month.html | 60 +++++++++++++++++++++++-- 2 files changed, 98 insertions(+), 23 deletions(-) diff --git a/app/static/line_items_by_month.js b/app/static/line_items_by_month.js index 62c03d5..b422b31 100644 --- a/app/static/line_items_by_month.js +++ b/app/static/line_items_by_month.js @@ -1,14 +1,15 @@ const monthSelector = document.getElementById('month-selector'); const tableBody = document.getElementById('table-body'); +const childTableBody = document.getElementById('child-table-body'); var reassignButtons = document.getElementsByClassName('reassign-button'); -function startEditMode(id){ +async function startEditMode(id){ for(let i = 0; i < reassignButtons.length; i++){ reassignButtons[i].disabled = true; } - const handleKeydown = (e) => { + const handleKeydown = async (e) => { if (e.key === 'Enter') { document.removeEventListener('keydown', handleKeydown); const vendor = document.getElementById(`vendor-line-${id}`); @@ -17,7 +18,8 @@ function startEditMode(id){ if (vendorInput.parentNode) { vendorInput.parentNode.removeChild(vendorInput); } - + var result = await fetch(`/update_vendor/${id}/${vendor.innerText}`, {method:'POST'}); + var data = await result.json(); for(let i = 0; i < reassignButtons.length; i++){ reassignButtons[i].disabled = false; } @@ -41,24 +43,43 @@ async function displayMonthLineItems(dateString){ var result = await fetch(`/get_month_line_items/${month}/${year}`, {method:'POST'}); var data = await result.json(); tableBody.innerHTML = '' + childTableBody.innerHTML = '' data.forEach(li => { - const row = ` - - ${li.id} - ${li.parent_line_item_id || ''} - ${li.amount} - ${li.currency_type} - ${li.vendor} - ${li.date} - ${li.confirmation_code} - ${li.note || ''} - - Click to split line - - `; - - // Insert the row into the table body - tableBody.insertAdjacentHTML('beforeend', row); + if (!li.parent_line_item_id){ + const row = ` + + ${li.id} + ${li.amount} + ${li.currency_type} + ${li.vendor} + ${li.date} + ${li.confirmation_code} + ${li.note || ''} + + Click to split line + + `; + + // Insert the row into the table body + tableBody.insertAdjacentHTML('beforeend', row); + } else { + const row = ` + + ${li.id} + ${li.parent_line_item_id} + ${li.amount} + ${li.currency_type} + ${li.vendor} + ${li.date} + ${li.confirmation_code} + ${li.note || ''} + + + `; + + // Insert the row into the table body + childTableBody.insertAdjacentHTML('beforeend', row); + } }); addListenersToReassignButtons(); diff --git a/app/templates/line_items_by_month.html b/app/templates/line_items_by_month.html index 0356472..83049a8 100644 --- a/app/templates/line_items_by_month.html +++ b/app/templates/line_items_by_month.html @@ -5,7 +5,7 @@
{% if files %} -
+
File available in static folder for upload - New files must be formatted with the following columns in this order - Date, Vendor, Note, Confirmation Code, Charge, Deposit @@ -36,7 +36,35 @@
{% endif %} -
+
+
+ Add Line Item +
+
+ +
+
+ + + + + + + + + + + + +
+
+ +
+ + +
+
+
Line Items
@@ -54,7 +82,6 @@ ID - Parent LineItem ID Amount Currency Type Vendor @@ -72,6 +99,33 @@
+
+
+ Child Line Items +
+
+
+ + + + + + + + + + + + + + + + + +
IDParent LineItem IDAmountCurrency TypeVendorDateConfirmation CodeNoteReassign Vendor
Loading...
+
+
+