diff --git a/app/controllers/transactions/categories/deletions_controller.rb b/app/controllers/transactions/categories/deletions_controller.rb index c5960ebd8f6..3e67a7625ea 100644 --- a/app/controllers/transactions/categories/deletions_controller.rb +++ b/app/controllers/transactions/categories/deletions_controller.rb @@ -15,7 +15,7 @@ def create private def set_category - @category = Current.family.transaction_categories.find(params[:transaction_category_id]) + @category = Current.family.transaction_categories.find(params[:category_id]) end def set_replacement_category diff --git a/app/controllers/transactions/categories/dropdowns_controller.rb b/app/controllers/transactions/categories/dropdowns_controller.rb new file mode 100644 index 00000000000..806544678e1 --- /dev/null +++ b/app/controllers/transactions/categories/dropdowns_controller.rb @@ -0,0 +1,22 @@ +class Transactions::Categories::DropdownsController < ApplicationController + before_action :set_from_params + + def show + @categories = categories_scope.to_a.excluding(@selected_category).prepend(@selected_category).compact + end + + private + def set_from_params + if params[:category_id] + @selected_category = categories_scope.find(params[:category_id]) + end + + if params[:transaction_id] + @transaction = Current.family.transactions.find(params[:transaction_id]) + end + end + + def categories_scope + Current.family.transaction_categories.alphabetically + end +end diff --git a/app/views/transactions/categories/_menu.html.erb b/app/views/transactions/categories/_menu.html.erb index c7ec508f79d..a4c6d72405c 100644 --- a/app/views/transactions/categories/_menu.html.erb +++ b/app/views/transactions/categories/_menu.html.erb @@ -1,48 +1,15 @@ <%# locals: (transaction:) %>