Fix separators in breakdown table view (#996)

* Fix separators in breakdown table view

Correct conditional logic for rendering column separators (rulers) in the reports breakdown table. The top-level check now compares idx to groups.size instead of group.size, and the subcategory check compares idx to group[:subcategories].size. This ensures separators are shown between categories and subcategories correctly, avoiding missing or extra rulers.

* Fix subcategory index variable name in partial

Rename the inner loop index from `idx` to `sub_idx` in app/views/reports/_breakdown_table.html.erb to avoid shadowing the outer `idx`. This ensures the conditional that renders the separator (`shared/ruler`) uses the correct index for subcategories, preventing incorrect rendering of separators between subcategory rows.

* Fix conditional block order in breakdown table

Reorder ERB tags to properly nest the subcategory conditional and the ruler render in the reports breakdown partial. This ensures the divider is only rendered between subcategories and prevents mismatched ERB/end tags that could break template rendering.
This commit is contained in:
Mark Hendriksen
2026-02-15 13:25:28 +01:00
committed by GitHub
parent e0ae71f33a
commit ebf89808f5

View File

@@ -37,21 +37,21 @@
color_class: color_class,
level: :category
%>
<% if idx < group.size - 1 %>
<% if idx < groups.size - 1 %>
<%= render "shared/ruler", classes: "mx-3 lg:mx-4" %>
<% end %>
<%# Render subcategories if present %>
<% if group[:subcategories].present? && group[:subcategories].any? %>
<% group[:subcategories].each_with_index do |subcategory, idx| %>
<% group[:subcategories].each_with_index do |subcategory, sub_idx| %>
<%= render "reports/category_row",
item: subcategory,
total: total,
color_class: color_class,
level: :subcategory
%>
<% end %>
<% if idx < group.size - 1 %>
<%= render "shared/ruler", classes: "mx-3 lg:mx-4" %>
<% if sub_idx < group[:subcategories].size - 1 %>
<%= render "shared/ruler", classes: "mx-3 lg:mx-4" %>
<% end %>
<% end %>
<% end %>
<% end %>