Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report page showing gender stats for a country #337

Merged
merged 18 commits into from
Jun 30, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix issue with incorrectly closed div tags
When there was only one item the div.row wasn't getting closed
correctly, which was breaking the page layout. This change uses
Enumerable#each_slice rather than the array index to correctly close
tags.
  • Loading branch information
chrismytton committed Jun 29, 2016
commit 5c3e9cbf2a4be56e0df1f12a030c4f3da0c9d3ab
21 changes: 10 additions & 11 deletions views/report.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
</p>

<div class="report-legislatures">
<% @country.legislatures.each_with_index do |legislature, i|
stats = @legislature_stats[legislature.slug][:totals]
total = stats[:overall][:total].to_f
male = stats[:overall][:male].to_f
female = stats[:overall][:female].to_f
total = male + female
%>
<% if i % 2 == 0 %>
<% @country.legislatures.each_slice(2) do |legislatures| %>
<div class="row">
<% end %>
<% legislatures.each do |legislature| %>
<%
stats = @legislature_stats[legislature.slug][:totals]
total = stats[:overall][:total].to_f
male = stats[:overall][:male].to_f
female = stats[:overall][:female].to_f
total = male + female
%>
<div class="col-sm-6">

<a class="list__item country" href="#<%= legislature.slug %>" data-scroll-to-id>
Expand All @@ -42,10 +42,9 @@
</a>

</div>
<% if i % 2 != 0 %>
<% end %>
</div>
<% end %>
<% end %>
</div>
</div>
</div>
Expand Down