diff --git a/app/javascript/controllers/transaction_form_controller.js b/app/javascript/controllers/transaction_form_controller.js deleted file mode 100644 index d4ad50b1..00000000 --- a/app/javascript/controllers/transaction_form_controller.js +++ /dev/null @@ -1,22 +0,0 @@ -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') - } - } -} diff --git a/app/views/transactions/_form.html.erb b/app/views/transactions/_form.html.erb index 2104f6c9..481c3603 100644 --- a/app/views/transactions/_form.html.erb +++ b/app/views/transactions/_form.html.erb @@ -1,6 +1,6 @@ <%# locals: (entry:, income_categories:, expense_categories:) %> -<%= styled_form_with model: entry, url: transactions_path, class: "space-y-4", data: { controller: "transaction-form" } do |f| %> +<%= styled_form_with model: entry, url: transactions_path, class: "space-y-4" do |f| %> <% if entry.errors.any? %> <%= render "shared/form_errors", model: entry %> <% end %> @@ -8,7 +8,7 @@
<%= render "shared/transaction_type_tabs", active_tab: params[:nature] == "inflow" ? "income" : "expense", account_id: params[:account_id] %> - <%= f.hidden_field :nature, value: params[:nature] || "outflow", data: { "transaction-form-target": "natureField" } %> + <%= f.hidden_field :nature, value: params[:nature] || "outflow" %> <%= f.hidden_field :entryable_type, value: "Transaction" %>