improves styles to polls questions views

This commit is contained in:
Alberto Garcia Cabeza
2016-12-22 18:31:51 +01:00
parent 8cbd39df69
commit 6dd3320425
3 changed files with 63 additions and 51 deletions

View File

@@ -1,46 +1,22 @@
<div class="poll-question-answers">
<% if can? :answer, question %>
<div class="small-12 small-centered text-center column">
<% question.valid_answers.each do |answer| %>
<% if @answers_by_question_id[question.id] == answer %>
<span class="button" title="<%= t("poll_questions.show.voted", answer: answer)%>">
<%= answer %>
</span>
<% else %>
<%= link_to answer,
answer_question_path(question, answer: answer),
method: :post,
remote: true,
title: t("poll_questions.show.vote_answer", answer: answer),
class: "button secondary hollow" %>
<% end %>
<% end %>
</div>
<% else %>
<div class="small-12 column">
<% if current_user.nil? %>
<div class="callout primary">
<%= t("poll_questions.show.not_logged_in",
signin: link_to(t("poll_questions.show.signin"), new_user_session_path, class: "probe-message"),
signup: link_to(t("poll_questions.show.signup"), new_user_registration_path, class: "probe-message")).html_safe %>
</div>
<% elsif current_user.unverified? %>
<div class="callout warning">
<%= t('poll_questions.show.cant_answer_verify_html',
verify_link: link_to(t('poll_questions.show.verify_link'), verification_path)) %>
</div>
<% question.valid_answers.each do |answer| %>
<% if @answers_by_question_id[question.id] == answer %>
<span class="button" title="<%= t("poll_questions.show.voted", answer: answer)%>">
<%= answer %>
</span>
<% else %>
<div class="callout warning">
<%= t('poll_questions.show.cant_answer_wrong_geozone') %>
</div>
<%= link_to answer,
answer_question_path(question, answer: answer),
method: :post,
remote: true,
title: t("poll_questions.show.vote_answer", answer: answer),
class: "button secondary hollow" %>
<% end %>
<div class="row">
<div class="small-12 small-centered text-center column">
<% question.valid_answers.each do |answer| %>
<span class="button disabled"><%= answer %></span>
<% end %>
</div>
</div>
</div>
<% end %>
<% else %>
<% question.valid_answers.each do |answer| %>
<span class="button disabled"><%= answer %></span>
<% end %>
<% end %>
</div>
</div>

View File

@@ -0,0 +1,9 @@
<div id="<%= dom_id(question) %>" class="poll-question">
<h3>
<%= link_to question.title, question_path(question) %>
</h3>
<div id="<%= dom_id(question) %>_answers">
<%= render 'polls/questions/answers', question: question %>
</div>
</div>

View File

@@ -1,3 +1,5 @@
<% provide :title do %><%= @question.title %><% end %>
<div class="expanded no-margin-top dark-heading">
<div class="row">
<div class="small-12 medium-9 column padding">
@@ -13,31 +15,58 @@
<p><%= @question.summary %></p>
<ul class="tags">
<ul class="no-bullet margin-top tags">
<% @question.geozones.each do |g| %>
<li><%= g.name %></li>
<li class="inline-block"><span><%= g.name %></span></li>
<% end %>
</ul>
</div>
<div class="small-12 medium-3 column info">
<p>
<span class="title author"><%= t('poll_questions.show.author') %></span><br>
<%= link_to @question.author.name, @question.author %>
<span class="title">
<strong><%= t('poll_questions.show.author') %></strong>
</span>
</p>
<p>
<%= link_to @question.author.name, @question.author, class: "margin-bottom" %>
</p>
<p>
<span class="title"><%= t('poll_questions.show.dates_title') %></span><br>
<span class="date"><%= poll_dates(@question.poll) %></span>
<span class="title">
<strong><%= t('poll_questions.show.dates_title') %></strong>
</p>
<p><%= poll_dates(@question.poll) %></p>
</div>
</div>
</div>
<% if @question.poll.current? %>
<div class="row margin-top text-center" id="<%= dom_id(@question) %>_answers">
<div class="row margin-top">
<div class="small-12 column">
<% if current_user.nil? %>
<div class="callout primary">
<%= t("poll_questions.show.not_logged_in",
signin: link_to(t("poll_questions.show.signin"), new_user_session_path, class: "probe-message"),
signup: link_to(t("poll_questions.show.signup"), new_user_registration_path, class: "probe-message")).html_safe %>
</div>
<% elsif current_user.unverified? %>
<div class="callout warning">
<%= t('poll_questions.show.cant_answer_verify_html',
verify_link: link_to(t('poll_questions.show.verify_link'), verification_path)) %>
</div>
<% else %>
<div class="callout warning">
<%= t('poll_questions.show.cant_answer_wrong_geozone') %>
</div>
<% end %>
</div>
<%= render "answers", question: @question %>
<div id="<%= dom_id(@question) %>_answers">
<div class="small-12 small-centered text-center column">
<%= render "answers", question: @question %>
</div>
</div>
</div>
<% elsif @question.poll.incoming? %>
<%= t('poll_questions.show.cant_answer_expired') %>
@@ -52,6 +81,4 @@
</div>
</div>
<%= render "comments" %>