Fix automatically syncing amounts when editing simple transaction
This commit is contained in:
parent
ca7cbf6481
commit
9f72404aed
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user