From: Christian Heller Date: Fri, 14 Feb 2025 21:38:23 +0000 (+0100) Subject: Add string replacement button to structured edit view. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/%7B%7Bprefix%7D%7D/process?a=commitdiff_plain;h=HEAD;p=ledgplom Add string replacement button to structured edit view. --- diff --git a/src/templates/edit_structured.tmpl b/src/templates/edit_structured.tmpl index ad7450e..298510c 100644 --- a/src/templates/edit_structured.tmpl +++ b/src/templates/edit_structured.tmpl @@ -157,6 +157,24 @@ function update_form() { }); } +function replace() { + const from = document.getElementById("replace_from").value; + const to = document.getElementById("replace_to").value; + dat_lines.forEach((dat_line) => { + dat_line.comment = dat_line.comment.replaceAll(from, to); + if ('code' in dat_line) { + dat_line.code = dat_line.code.replaceAll(from, to); + } + ['account', 'amount', 'currency'].forEach((key) => { + if (key in dat_line.booking_line) { + dat_line.booking_line[key] = dat_line.booking_line[key].replaceAll(from, to); + } + }); + }); + taint(); + update_form(); +} + window.onload = update_form; {% endblock %} @@ -164,6 +182,12 @@ window.onload = update_form; {% block content %}
{{ macros.edit_bar("raw", id) }} + +from + +to + +