Merge pull request #1394 from consul/polls-index

polls index
This commit is contained in:
Raimond Garcia
2017-02-03 18:33:30 +01:00
committed by GitHub
4 changed files with 123 additions and 6 deletions

View File

@@ -1368,6 +1368,73 @@ ul.ballot-list {
.poll {
padding: $line-height;
position: relative;
.icon-poll-answer {
border-top: 0;
border-bottom: 60px solid transparent;
height: 0;
position: absolute;
right: 0;
top: 0;
width: 0;
&.can-answer:after,
&.cant-answer:after,
&.not-logged-in:after,
&.already-answer:after,
&.unverified:after {
font-family: "icons" !important;
left: 34px;
position: absolute;
top: 5px;
}
&.can-answer {
border-right: 60px solid $info-bg;
&:after {
color: $color-info;
content: "\6c";
}
}
&.cant-answer {
border-right: 60px solid $alert-bg;
&:after {
color: $color-alert;
content: "\74";
}
}
&.not-logged-in {
border-right: 60px solid $info-bg;
&:after {
color: $color-info;
content: "\6f";
}
}
&.unverified {
border-right: 60px solid $warning-bg;
&:after {
color: $color-warning;
content: "\6f";
}
}
&.already-answer {
border-right: 60px solid $success-bg;
&:after {
color: $color-success;
content: "\59";
}
}
}
.dates {
color: $text-medium;
@@ -1375,6 +1442,7 @@ ul.ballot-list {
@include breakpoint(medium) {
float: right;
margin-right: $line-height;
}
}

View File

@@ -1,20 +1,59 @@
<% poll_group.each do |poll| %>
<div class="poll">
<% if poll.answerable_by?(current_user) && poll.votable_by?(current_user) %>
<%= link_to poll,
class: "icon-poll-answer can-answer",
title: t("polls.index.can_answer") do %>
<span class="sr-only">
<%= t("polls.index.can_answer") %>
</span>
<% end %>
<% elsif current_user.nil? %>
<%= link_to new_user_session_path,
class: "icon-poll-answer not-logged-in",
title: t("polls.index.cant_answer_not_logged_in") do %>
<span class="sr-only">
<%= t("polls.index.cant_answer_not_logged_in") %>
</span>
<% end %>
<% elsif current_user.unverified? %>
<%= link_to verification_path,
class: "icon-poll-answer unverified",
title: t("polls.index.cant_answer_verify") do %>
<span class="sr-only">
<%= t("polls.index.cant_answer_verify") %>
</span>
<% end %>
<% elsif !poll.votable_by?(current_user) %>
<div class="icon-poll-answer already-answer" title="<%= t("polls.index.already_answer") %>">
<span class="sr-only"><%= t("polls.index.already_answer") %></span>
</div>
<% else %>
<div class="icon-poll-answer cant-answer" title="<%= t("polls.index.cant_answer") %>">
<span class="sr-only"><%= t("polls.index.cant_answer") %></span>
</div>
<% end %>
<div class="row">
<div class="small-12 column">
<div class="dates"><%= poll_dates(poll) %></div>
<h4 class="inline-block"><%= link_to poll.name, poll %></h4>
<ul>
<% if poll.questions.count == 1 %>
<% poll.questions.each do |question| %>
<li><%= link_to question.title, question_path(question) %></li>
<h4 class="inline-block"><%= link_to question.title, poll %></h4>
<% end %>
</ul>
<% else %>
<h4 class="inline-block"><%= link_to poll.name, poll %></h4>
<ul>
<% poll.questions.each do |question| %>
<li><%= link_to question.title, question_path(question) %></li>
<% end %>
</ul>
<% end %>
<% if poll.geozones.any? %>
<p class="inline-block">
<p>
<small><%= t("polls.index.geozone_info") %></small>
</p>
<% end %>
<ul class="no-bullet tags inline-block">
<ul class="no-bullet tags">
<% poll.geozones.each do |g| %>
<li class="inline-block"><span><%= g.name %></span></li>
<% end %>