Order headings by name and group

Note that we are relying on the existing `sort_by_name`[1] method in the `Budget::Heading` class.

This method sorts by DESC group name first and then ASC heading name.

[1] https://github.com/AyuntamientoMadrid/consul/pull/1875
This commit is contained in:
voodoorai2000
2019-03-07 15:10:51 +01:00
committed by Javi Martín
parent 7b2495845d
commit abb6eb18b0
4 changed files with 6 additions and 6 deletions

View File

@@ -8,6 +8,7 @@ module Budgets
def show
authorize! :read_results, @budget
@investments = Budget::Result.new(@budget, @heading).investments
@headings = @budget.headings.sort_by_name
end
private

View File

@@ -7,6 +7,7 @@ module Budgets
def show
authorize! :read_stats, @budget
@stats = load_stats
@headings = @budget.headings.sort_by_name
end
private

View File

@@ -46,10 +46,8 @@
<h3 class="margin-bottom">
<%= t("budgets.results.heading_selection_title") %>
</h3>
<ul class="menu vertical no-margin-top no-padding-top">
<% @budget.headings.order("id ASC").each do |heading| %>
<ul id="headings" class="menu vertical no-margin-top no-padding-top">
<% @headings.each do |heading| %>
<li>
<%= link_to heading.name,
budget_results_path(@budget, heading_id: heading.to_param),

View File

@@ -199,8 +199,8 @@
<th scope="col" class="tiny"><%= t("budgets.stats.percent_heading_census_html") %></th>
</tr>
</thead>
<tbody>
<% @budget.headings.order("id ASC").each do |heading| %>
<tbody id="headings">
<% @headings.each do |heading| %>
<tr id="<%= heading.name.parameterize %>">
<td class="border-left">
<strong><%= heading.name %></strong>