From 1ae4caa0ef50571a7df45c1554745ce18eb626c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 22 Feb 2025 17:32:54 +0100 Subject: [PATCH] Only render successful icon on successful proposals Not doing so made it trickier to define a flex layout, since the icon-successful element is given a `position: absolute`, but only for successful proposals, while for unsuccessful proposals it was taking the standard `position: static` value. We're also reusing the `successful?` method instead of rewriting it in the view, and fixing a small issue where the icon wasn't displayed for proposals having the exact needed votes (we were using `>` instead of `>=` in the condition). Note that legislation proposals use the method `Proposal.votes_needed_for_success`, which is probaby a mistake caused by copying the code from the proposal view. Fixing this issue is out of the scope of this commit (and pull request), though. --- app/views/legislation/proposals/_proposal.html.erb | 4 +++- app/views/proposals/_proposal.html.erb | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/views/legislation/proposals/_proposal.html.erb b/app/views/legislation/proposals/_proposal.html.erb index a2a985f44..ece4edb35 100644 --- a/app/views/legislation/proposals/_proposal.html.erb +++ b/app/views/legislation/proposals/_proposal.html.erb @@ -2,7 +2,9 @@ class="proposal clear <%= ("successful" if proposal.total_votes > Proposal.votes_needed_for_success) %>" data-type="proposal">
"> -
+ <% if proposal.total_votes > Proposal.votes_needed_for_success %> +
+ <% end %> <% if proposal.image.present? %>
diff --git a/app/views/proposals/_proposal.html.erb b/app/views/proposals/_proposal.html.erb index 425d75537..e4f89698a 100644 --- a/app/views/proposals/_proposal.html.erb +++ b/app/views/proposals/_proposal.html.erb @@ -1,9 +1,10 @@
Proposal.votes_needed_for_success) %>" + class="proposal clear <%= ("successful" if proposal.successful?) %>" data-type="proposal">
"> -
+ <% if proposal.successful? %> +
+ <% end %> <% if proposal.image.present? %>