From: Christian Heller Date: Sun, 23 Mar 2025 10:19:02 +0000 (+0100) Subject: Fix indentation. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%22https:/validator.w3.org/condition?a=commitdiff_plain;h=f58405eecc993c91d78736d508e266cba6d5839a;p=ledgplom Fix indentation. --- diff --git a/src/templates/edit_structured.tmpl b/src/templates/edit_structured.tmpl index 262551e..8673746 100644 --- a/src/templates/edit_structured.tmpl +++ b/src/templates/edit_structured.tmpl @@ -92,67 +92,67 @@ function update_form() { } function add_td_input(name, value, size=20, colspan=1) { return add_input(setup_input_td(tr, colspan), name, value, size); - } - - // movement buttons - const td_btns_updown = add_td(tr); - if (i > 0) { - [{label: '^', earlier_idx: i-1, enabled: i > 1}, - {label: 'v', earlier_idx: i, enabled: i && i+1 < dat_lines.length} - ].forEach((kwargs) => { - add_button(td_btns_updown, kwargs.label, ! kwargs.enabled, function() { - const other_line = dat_lines[kwargs.earlier_idx]; - dat_lines.splice(kwargs.earlier_idx, 1); - dat_lines.splice(kwargs.earlier_idx + 1, 0, other_line); - }); - }); - } - - // actual input lines - if (dat_line.is_intro) { - const td = setup_input_td(tr, 3); - const date_input = add_input(td, 'date', dat_line.booked.date, 10) - date_input.classList.add('date_input'); - add_input(td, 'target', dat_line.booked.target, 37) - } else if (!dat_line.error) { // i.e. valid TransferLine - const acc_input = add_td_input('account', dat_line.booked.account, 30); - acc_input.setAttribute ('list', 'all_accounts'); - acc_input.autocomplete = 'off'; - // not using input[type=number] cuz no minimal step size, therefore regex test instead - const amt_input = add_td_input('amount', dat_line.booked.amount == 'None' ? '' : dat_line.booked.amount, 12); - amt_input.pattern = '^-?[0-9]+(\.[0-9]+)?$'; - amt_input.classList.add("number_input"); - // ensure integer amounts at least line up with double-digit decimals - if (amt_input.value.match(/^-?[0-9]+$/)) { amt_input.value += '.00'; } - // imply that POST handler will set '€' currency if unset, but amount set - const curr_input = add_td_input('currency', dat_line.booked.currency, 3); - curr_input.placeholder = '€'; - } else { - add_td_input('error', dat_line.code, 20, 3) - } - add_td_input('comment', dat_line.comment, 40); - - // line deletion and addition buttons - td_add_del = add_td(tr); - add_button(td_add_del, 'add new', false, function() { - new_line = {error: '', comment: '', booked: {account: '', amount: '', currency: ''}}; - dat_lines.splice(i + 1, 0, new_line); - }); - if (i > 0) { - add_button(td_add_del, 'delete', i > 0 ? false : true, function() { - dat_lines.splice(i, 1); - }); - } - - // add error explanation row if necessary - if (dat_line.error) { - const tr = document.createElement("tr"); - table.appendChild(tr); - const td = add_td(tr, 3); - tr.appendChild(document.createElement("td")); - td.textContent = dat_line.error; - tr.classList.add("warning"); - } + } + + // movement buttons + const td_btns_updown = add_td(tr); + if (i > 0) { + [{label: '^', earlier_idx: i-1, enabled: i > 1}, + {label: 'v', earlier_idx: i, enabled: i && i+1 < dat_lines.length} + ].forEach((kwargs) => { + add_button(td_btns_updown, kwargs.label, ! kwargs.enabled, function() { + const other_line = dat_lines[kwargs.earlier_idx]; + dat_lines.splice(kwargs.earlier_idx, 1); + dat_lines.splice(kwargs.earlier_idx + 1, 0, other_line); + }); + }); + } + + // actual input lines + if (dat_line.is_intro) { + const td = setup_input_td(tr, 3); + const date_input = add_input(td, 'date', dat_line.booked.date, 10) + date_input.classList.add('date_input'); + add_input(td, 'target', dat_line.booked.target, 37) + } else if (!dat_line.error) { // i.e. valid TransferLine + const acc_input = add_td_input('account', dat_line.booked.account, 30); + acc_input.setAttribute ('list', 'all_accounts'); + acc_input.autocomplete = 'off'; + // not using input[type=number] cuz no minimal step size, therefore regex test instead + const amt_input = add_td_input('amount', dat_line.booked.amount == 'None' ? '' : dat_line.booked.amount, 12); + amt_input.pattern = '^-?[0-9]+(\.[0-9]+)?$'; + amt_input.classList.add("number_input"); + // ensure integer amounts at least line up with double-digit decimals + if (amt_input.value.match(/^-?[0-9]+$/)) { amt_input.value += '.00'; } + // imply that POST handler will set '€' currency if unset, but amount set + const curr_input = add_td_input('currency', dat_line.booked.currency, 3); + curr_input.placeholder = '€'; + } else { + add_td_input('error', dat_line.code, 20, 3) + } + add_td_input('comment', dat_line.comment, 40); + + // line deletion and addition buttons + td_add_del = add_td(tr); + add_button(td_add_del, 'add new', false, function() { + new_line = {error: '', comment: '', booked: {account: '', amount: '', currency: ''}}; + dat_lines.splice(i + 1, 0, new_line); + }); + if (i > 0) { + add_button(td_add_del, 'delete', i > 0 ? false : true, function() { + dat_lines.splice(i, 1); + }); + } + + // add error explanation row if necessary + if (dat_line.error) { + const tr = document.createElement("tr"); + table.appendChild(tr); + const td = add_td(tr, 3); + tr.appendChild(document.createElement("td")); + td.textContent = dat_line.error; + tr.classList.add("warning"); + } } // make all rows alternate background color for better readability