From: Christian Heller Date: Wed, 26 Feb 2025 16:25:58 +0000 (+0100) Subject: In /edit_structured disable replace button if un-applied changes. X-Git-Url: https://plomlompom.com/repos/booking/%7B%7Bdb.prefix%7D%7D/%7B%7Bprefix%7D%7D/add_task?a=commitdiff_plain;h=b3ecd628e2ad3f3134f6df04c9601faa111c49bd;p=ledgplom In /edit_structured disable replace button if un-applied changes. --- diff --git a/src/templates/_macros.tmpl b/src/templates/_macros.tmpl index a3187c9..35a4173 100644 --- a/src/templates/_macros.tmpl +++ b/src/templates/_macros.tmpl @@ -101,23 +101,27 @@ table.ledger tr > td:first-child { background-color: white; } function taint() { // activate buttons "apply", "revert" Array.from(document.getElementsByClassName("enable_on_change")).forEach((el) => { - el.disabled = false; + el.disabled = false; }); // deactivate Booking links - Array.from(document.getElementsByClassName("disable_on_change")).forEach((span) => { - let links_text = ''; - Array.from(span.childNodes).forEach((node) => { - links_text += node.textContent + ' '; - }); - span.innerHTML = ''; - const del = document.createElement("del"); - span.appendChild(del); - del.textContent = links_text; + Array.from(document.getElementsByClassName("disable_on_change")).forEach((el) => { + if (el.tagName == 'span') { + let links_text = ''; + Array.from(el.childNodes).forEach((node) => { + links_text += node.textContent + ' '; + }); + el.innerHTML = ''; + const del = document.createElement("del"); + el.appendChild(del); + del.textContent = links_text; + } else if (el.type == "button") { + el.disabled = true; + } }); // remove oninput handlers no longer needed (since we only ever go one way) ['input', 'textarea'].forEach((tag_name) => { Array.from(document.getElementsByTagName(tag_name)).forEach((el) => { - el.oninput = null; + el.oninput = null; }); }); } diff --git a/src/templates/edit_structured.tmpl b/src/templates/edit_structured.tmpl index 298510c..de2a226 100644 --- a/src/templates/edit_structured.tmpl +++ b/src/templates/edit_structured.tmpl @@ -147,8 +147,8 @@ function update_form() { table.appendChild(tr); const td = add_td(tr, 5); add_button(td, 'add line', false, function() { - new_line = {error: '', comment: '', booking_line: {account: '', amount: '', currency: ''}}; - dat_lines.push(new_line); + new_line = {error: '', comment: '', booking_line: {account: '', amount: '', currency: ''}}; + dat_lines.push(new_line); }); // make all rows alternate background color for better readability @@ -182,7 +182,7 @@ window.onload = update_form; {% block content %}
{{ macros.edit_bar("raw", id) }} - + from to