Extract component to render a poll in the poll index
This is consistent with the way we've got partials to render debates, proposals and legislation processes on their index pages. Note that, while adding the tests for the status icon, we're keeping one system test because it also tests the process of voting. We're adding a new, similar component test, where the voter is created in the database, so all possible statuses are tested in the component.
This commit is contained in:
@@ -1,68 +1,3 @@
|
||||
<% poll_group.each do |poll| %>
|
||||
<div class="poll with-image">
|
||||
<% if !user_signed_in? %>
|
||||
<div class="icon-poll-answer not-logged-in" title="<%= t("polls.index.not_logged_in") %>">
|
||||
<span class="show-for-sr"><%= t("polls.index.not_logged_in") %></span>
|
||||
</div>
|
||||
<% elsif user_signed_in? %>
|
||||
<% if current_user.unverified? %>
|
||||
<div class="icon-poll-answer unverified" title="<%= t("polls.index.unverified") %>">
|
||||
<span class="show-for-sr"><%= t("polls.index.unverified") %></span>
|
||||
</div>
|
||||
<% elsif cannot?(:answer, poll) %>
|
||||
<div class="icon-poll-answer cant-answer" title="<%= t("polls.index.cant_answer") %>">
|
||||
<span class="show-for-sr"><%= t("polls.index.cant_answer") %></span>
|
||||
</div>
|
||||
<% elsif !poll.votable_by?(current_user) %>
|
||||
<div class="icon-poll-answer already-answer" title="<%= t("polls.index.already_answer") %>">
|
||||
<span class="show-for-sr"><%= t("polls.index.already_answer") %></span>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="row" data-equalizer data-equalize-on="medium">
|
||||
<div class="small-12 medium-3 column">
|
||||
<div class="image-container" data-equalizer-watch>
|
||||
<% if poll.image.present? %>
|
||||
<%= image_tag poll.image.variant(:large), alt: poll.image.title.unicode_normalize %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="small-12 medium-6 column" data-equalizer-watch>
|
||||
<div class="dates"></div>
|
||||
<% if poll.questions.one? %>
|
||||
<h4><%= link_to_poll poll.questions.first.title, poll %></h4>
|
||||
<%= poll_dates(poll) %>
|
||||
<% else %>
|
||||
<h4><%= link_to_poll poll.name, poll %></h4>
|
||||
<%= poll_dates(poll) %>
|
||||
|
||||
<ul class="margin-top">
|
||||
<% poll.questions.sort_for_list.each do |question| %>
|
||||
<li><%= question.title %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% if poll.geozones.any? %>
|
||||
<p>
|
||||
<small><%= t("polls.index.geozone_info") %></small>
|
||||
</p>
|
||||
<% end %>
|
||||
<ul class="tags">
|
||||
<% poll.geozones.each do |g| %>
|
||||
<li><span><%= g.name %></span></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<%= render SDG::TagListComponent.new(poll, limit: 5, linkable: false) %>
|
||||
</div>
|
||||
<div class="small-12 medium-3 column table" data-equalizer-watch>
|
||||
<div class="table-cell align-middle">
|
||||
<% if poll.expired? %>
|
||||
<%= link_to_poll t("polls.index.participate_button_expired"), poll, class: "button hollow expanded" %>
|
||||
<% else %>
|
||||
<%= link_to_poll t("polls.index.participate_button"), poll, class: "button hollow expanded" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%= render Polls::PollComponent.new(poll) %>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user