Fix automatically syncing amounts when editing simple transaction

This commit is contained in:
RunasSudo 2024-04-06 18:55:27 +11:00
parent ca7cbf6481
commit 9f72404aed
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -97,7 +97,7 @@
{{ 'Edit' if transaction and transaction.id else 'New' }} transaction {{ 'Edit' if transaction and transaction.id else 'New' }} transaction
</h1> </h1>
<form method="POST"> <form method="POST" id="edit-transaction-form">
<table class="min-w-full"> <table class="min-w-full">
<thead> <thead>
<tr class="border-b border-gray-300"> <tr class="border-b border-gray-300">
@ -220,19 +220,14 @@
} }
function changeAmount(el) { function changeAmount(el) {
let amountInputs = document.querySelectorAll('input[name="amount"]'); let amountInputs = document.querySelectorAll('#edit-transaction-form input[name="amount"]');
if (amountInputs.length === 2) { if (amountInputs.length === 2) {
// Get other input
let otherInput;
for (inp of amountInputs) { for (inp of amountInputs) {
if (inp !== el) { if (inp !== el) {
otherInput = inp; // Update other input with amount
break; inp.value = el.value;
} }
} }
// Update other input with amount
otherInput.value = el.value;
} }
} }
</script> </script>