<h3 class="inline-block"><%= t('admin.budgets.show.groups', count: groups.count) %></h3>
<% if groups.blank? %>
  <div class="callout primary">
    <%= t("admin.budgets.form.no_groups") %>
    <strong><%= link_to t("admin.budgets.form.add_group"), "#",
                class: "js-toggle-link",
                data: { "toggle-selector" => "#new-group-form" } %></strong>
  </div>
<% else %>
  <%= link_to t("admin.budgets.form.add_group"), "#", class: "button float-right js-toggle-link", data: { "toggle-selector" => "#new-group-form" } %>
<% end %>

<%= render 'admin/budgets/group_form', budget: @budget, group: Budget::Group.new, id: "new-group-form", button_title: t("admin.budgets.form.create_group"), css_class: '' %>

<% groups.each do |group| %>
  <div id="<%= dom_id(group) %>">
    <%= render "admin/budgets/group", group: group, headings: group.headings %>
  </div>
<% end %>

<h3 class="inline-block"><%= t('admin.budgets.show.groups', count: groups.count) %></h3>
<% if groups.blank? %>
  <div class="callout primary">
    <%= t("admin.budgets.form.no_groups") %>
    <strong><%= link_to t("admin.budgets.form.add_group"), "#",
                class: "js-toggle-link",
                data: { "toggle-selector" => "#new-group-form" } %></strong>
  </div>
<% else %>
  <%= link_to t("admin.budgets.form.add_group"), "#", class: "button float-right js-toggle-link", data: { "toggle-selector" => "#new-group-form" } %>
<% end %>

<%= render 'admin/budgets/group_form', budget: @budget, group: Budget::Group.new, id: "new-group-form", button_title: t("admin.budgets.form.create_group"), css_class: '' %>

<% groups.each do |group| %>
  <div id="<%= dom_id(group) %>">
    <%= render "admin/budgets/group", group: group, headings: group.headings.order(:id) %>
  </div>
<% end %>

Order budget headings by id
Order budget headings by id

To maintain order after editing a heading’s name

We should probably add timestamps to `groups` and `headings` and order
by `created_at` instead

Could have done it in a separate PR, but gotta keep moving to other
priority issues. Creating issue for timestamps to do correctly and with
tests :relieved:
