Skip to content

Commit

Permalink
Improve line breaking in contra account selection
Browse files Browse the repository at this point in the history
Adds custom rendering functions to allow word breaks at colons (subaccount
separators)

Fixes #40
  • Loading branch information
joshuabach committed Dec 30, 2023
1 parent 00515b0 commit 602033e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/gnucash_web/templates/forms.j2
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,20 @@
Select an account to transfer money to / from
</div>
<script>
function renderAccountNameBreakable(divClass, text) {
return "<div class=\""+divClass+"\">"+text.replaceAll(":", ":<wbr>")+"</div>";
}
document.addEventListener("DOMContentLoaded", function() {
$("select#{{ id }}_transaction-contra_account_name").removeClass("form-select");
$("select#{{ id }}_transaction-contra_account_name").selectize({
maxItems: 1,
items: ["{{ config.PRESELECTED_CONTRA_ACCOUNT }}"],
render: {
item: function(contra_account, escape) { return renderAccountNameBreakable("item", contra_account.text) },
option: function(contra_account, escape) { return renderAccountNameBreakable("option", contra_account.text) },
},
onType: function(text) {
// Workaround for https://github.com/selectize/selectize.js/issues/113
{# Workaround for https://github.com/selectize/selectize.js/issues/113 #}
if (text.length <= 1) {
this.clear();
}
Expand Down

0 comments on commit 602033e

Please sign in to comment.