Unifies budget_headings_helper

This commit is contained in:
kikito
2016-12-06 18:03:03 +01:00
parent 0564392964
commit 34071a0f9f
2 changed files with 5 additions and 11 deletions

View File

@@ -1,15 +1,9 @@
module BudgetHeadingsHelper module BudgetHeadingsHelper
def budget_heading_select_options(budget) def budget_heading_select_options(budget)
budget.headings.map {|heading| [heading.name, heading.id]} budget.headings.includes(:group).order('budget_groups.name', 'budget_headings.name').map do |heading|
end ["#{heading.group.name}: #{heading.name}", heading.id]
end
def multiple_budgets_heading_select_options(headings)
headings.map { |heading| ["#{heading.budget.name} - #{heading.group.name} - #{heading.name}", heading.id] }
end
def budget_scoped_heading_select_options(budget)
budget.headings.includes(:group).order("group_id ASC, budget_headings.name ASC").map {|heading| [heading.group.name + ': ' + heading.name, heading.id]}
end end
end end

View File

@@ -23,7 +23,7 @@
</div> </div>
<div class="small-12 column"> <div class="small-12 column">
<%= f.select :heading_id, budget_scoped_heading_select_options(@budget), include_blank: t("admin.budget_investments.edit.select_heading") %> <%= f.select :heading_id, budget_heading_select_options(@budget), include_blank: t("admin.budget_investments.edit.select_heading") %>
</div> </div>
</div> </div>
@@ -66,4 +66,4 @@
<% end %> <% end %>
<hr> <hr>
<%# render 'valuation/budget_investments/written_by_valuators' %> <%# render 'valuation/budget_investments/written_by_valuators' %>