mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-20 13:49:39 +02:00
Fix: Filter categories by transaction type in forms (#2082)
Changed transaction form to only display relevant categories based on transaction type (income or expense), improving usability and preventing misclassification. Created a shared transaction type tabs component for consistent navigation between expense, income, and transfer forms, providing a better user experience and reducing code duplication. Signed-off-by: Zach Gollwitzer <zach@maybe.co> Co-authored-by: Zach Gollwitzer <zach@maybe.co>
This commit is contained in:
parent
ce83418f0b
commit
71bc51ca15
10 changed files with 74 additions and 67 deletions
22
app/javascript/controllers/transaction_form_controller.js
Normal file
22
app/javascript/controllers/transaction_form_controller.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
import {Controller} from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["expenseCategories", "incomeCategories"]
|
||||
|
||||
connect() {
|
||||
this.updateCategories()
|
||||
}
|
||||
|
||||
updateCategories(event) {
|
||||
const natureField = this.element.querySelector('input[name="account_entry[nature]"]:checked')
|
||||
const natureValue = natureField ? natureField.value : 'outflow'
|
||||
|
||||
if (natureValue === 'inflow') {
|
||||
this.expenseCategoriesTarget.classList.add('hidden')
|
||||
this.incomeCategoriesTarget.classList.remove('hidden')
|
||||
} else {
|
||||
this.expenseCategoriesTarget.classList.remove('hidden')
|
||||
this.incomeCategoriesTarget.classList.add('hidden')
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue