Group investment search form methods together

We had helper methods all over the place which were only used in one
view. Since we're going to change some of them to use the budget as a
parameter, they don't belong in those helpers anymore.

Note the method `budget_heading_select_options` is used in more places,
so we're keeping it where it was.
This commit is contained in:
Javi Martín
2020-09-08 16:28:39 +02:00
parent e4c1a8cf45
commit 4a5d4b3c0b
4 changed files with 21 additions and 21 deletions

View File

@@ -12,4 +12,25 @@ module AdminBudgetInvestmentsHelper
def init_advanced_menu
params[:advanced_filters] = [] unless params[:advanced_filters]
end
def admin_select_options
Administrator.with_user.map { |v| [v.description_or_name, v.id] }.sort_by { |a| a[0] }
end
def valuator_or_group_select_options
valuator_group_select_options + valuator_select_options
end
def valuator_select_options
Valuator.order("description ASC").order("users.email ASC").includes(:user).
map { |v| [v.description_or_email, "valuator_#{v.id}"] }
end
def valuator_group_select_options
ValuatorGroup.order("name ASC").map { |g| [g.name, "group_#{g.id}"] }
end
def investment_tags_select_options(budget, context)
budget.investments.tags_on(context).order(:name).pluck(:name)
end
end

View File

@@ -84,10 +84,6 @@ module AdminHelper
options
end
def admin_select_options
Administrator.with_user.map { |v| [v.description_or_name, v.id] }.sort_by { |a| a[0] }
end
def admin_submit_action(resource)
resource.persisted? ? "edit" : "new"
end

View File

@@ -59,10 +59,6 @@ module BudgetsHelper
Budget::Ballot.find_by(user: current_user, budget: @budget)
end
def investment_tags_select_options(budget, context)
budget.investments.tags_on(context).order(:name).pluck(:name)
end
def unfeasible_or_unselected_filter
["unselected", "unfeasible"].include?(@current_filter)
end

View File

@@ -1,17 +1,4 @@
module ValuationHelper
def valuator_or_group_select_options
valuator_group_select_options + valuator_select_options
end
def valuator_select_options
Valuator.order("description ASC").order("users.email ASC").includes(:user).
map { |v| [v.description_or_email, "valuator_#{v.id}"] }
end
def valuator_group_select_options
ValuatorGroup.order("name ASC").map { |g| [g.name, "group_#{g.id}"] }
end
def explanation_field(field)
simple_format_no_tags_no_sanitize(sanitize_and_auto_link(field)) if field.present?
end