home · contact · privacy
Fix indentation.
authorChristian Heller <c.heller@plomlompom.de>
Sun, 23 Mar 2025 10:19:02 +0000 (11:19 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 23 Mar 2025 10:19:02 +0000 (11:19 +0100)
src/templates/edit_structured.tmpl

index 262551e8824836345f95d21c7566091d0d66cfdc..867374661f89d0ea2b327ed01952e27246d475d8 100644 (file)
@@ -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