2024-06-20 13:32:44 -04:00
|
|
|
class Category::DropdownsController < ApplicationController
|
2024-05-22 12:31:25 +02:00
|
|
|
before_action :set_from_params
|
|
|
|
|
|
|
|
def show
|
|
|
|
@categories = categories_scope.to_a.excluding(@selected_category).prepend(@selected_category).compact
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
2024-08-23 10:06:24 -04:00
|
|
|
def set_from_params
|
|
|
|
if params[:category_id]
|
|
|
|
@selected_category = categories_scope.find(params[:category_id])
|
|
|
|
end
|
2024-05-22 12:31:25 +02:00
|
|
|
|
2024-08-23 10:06:24 -04:00
|
|
|
if params[:transaction_id]
|
|
|
|
@transaction = Current.family.transactions.find(params[:transaction_id])
|
|
|
|
end
|
2024-05-22 12:31:25 +02:00
|
|
|
end
|
|
|
|
|
2024-08-23 10:06:24 -04:00
|
|
|
def categories_scope
|
|
|
|
Current.family.categories.alphabetically
|
|
|
|
end
|
2024-05-22 12:31:25 +02:00
|
|
|
end
|