Refactor by creating a helper method for generating sorting links [#2931]

This commit is contained in:
Anna Anks Nowak
2018-12-30 23:18:11 +01:00
committed by Javi Martín
parent ea3319ae6f
commit 22059379f5
2 changed files with 8 additions and 3 deletions

View File

@@ -9,6 +9,11 @@ module BudgetInvestmentsHelper
params.map { |af| t("admin.budget_investments.index.filters.#{af}") }.join(', ') params.map { |af| t("admin.budget_investments.index.filters.#{af}") }.join(', ')
end end
def link_to_investments_sorted_by(column)
sorting_option = budget_investments_sorting_options.select { |so| so[1] == column.downcase }.flatten
link_to t(sorting_option[0]), admin_budget_budget_investments_path(sort_by: sorting_option[1])
end
def investments_minimal_view_path def investments_minimal_view_path
budget_investments_path(id: @heading.group.to_param, budget_investments_path(id: @heading.group.to_param,
heading_id: @heading.to_param, heading_id: @heading.to_param,

View File

@@ -35,9 +35,9 @@
<table class="table-for-mobile"> <table class="table-for-mobile">
<thead> <thead>
<tr> <tr>
<th><%= link_to t("admin.budget_investments.index.list.id"), admin_budget_budget_investments_path(sort_by: "id") %></th> <th><%= link_to_investments_sorted_by t("admin.budget_investments.index.list.id") %></th>
<th class="small-3"><%= link_to t("admin.budget_investments.index.list.title"), admin_budget_budget_investments_path(sort_by: "title") %></th> <th class="small-3"><%= link_to_investments_sorted_by t("admin.budget_investments.index.list.title") %></th>
<th><%= link_to t("admin.budget_investments.index.list.supports"), admin_budget_budget_investments_path(sort_by: "supports") %></th> <th><%= link_to_investments_sorted_by t("admin.budget_investments.index.list.supports") %></th>
<th><%= t("admin.budget_investments.index.list.admin") %></th> <th><%= t("admin.budget_investments.index.list.admin") %></th>
<th> <th>
<%= t("admin.budget_investments.index.list.valuation_group") %> <%= t("admin.budget_investments.index.list.valuation_group") %>