Merge pull request #1302 from consul/polls-front

Polls front
This commit is contained in:
Juanjo Bazán
2016-12-22 21:48:16 +01:00
committed by GitHub
14 changed files with 250 additions and 140 deletions

View File

@@ -79,6 +79,7 @@ $budget: #454372;
$budget-hover: #7571BF;
$highlight: #E7F2FC;
$light: #F5F7FA;
$featured: #FED900;
$footer-border: #BFC1C3;

View File

@@ -138,6 +138,10 @@ a {
padding-top: $line-height;
}
.light {
background: $light;
}
.highlight {
background: $highlight;
}
@@ -198,6 +202,30 @@ a {
}
}
.menu.vertical {
background: white;
margin: $line-height 0;
padding: $line-height;
li {
margin-bottom: $line-height;
a {
color: $text-medium;
padding: 0;
}
h2 {
font-size: $base-font-size;
}
&.active {
border-bottom: 2px solid $brand;
color: $brand;
}
}
}
.small {
font-size: $small-font-size;
}
@@ -430,6 +458,7 @@ header {
.input-group-button {
line-height: $line-height*1.5;
padding-bottom: 0;
button {
background: $border;
@@ -451,7 +480,6 @@ header {
}
.submenu {
background: white;
border-bottom: 1px solid $border;
clear: both;
margin-bottom: $line-height/2;
@@ -544,7 +572,8 @@ footer {
// 04. Tags
// --------
.tags a , .tag-cloud a, .categories a, .geozone a, .sidebar-links a {
.tags a , .tag-cloud a, .categories a, .geozone a, .sidebar-links a,
.tags span {
background: #ececec;
border-radius: rem-calc(6);
color: $text;

View File

@@ -6,6 +6,7 @@
// 04. List participation
// 05. Featured
// 06. Proposals successful
// 07. Polls
//
// 01. Votes and supports
@@ -945,37 +946,6 @@
// 06. Proposals successful
// -------------------------
.dark-heading {
background: #2D3E50;
color: white;
@include breakpoint(medium) {
padding-bottom: $line-height;
}
&.enquiries {
background: #2D3E50 image-url('heading_enquiries.jpg') no-repeat;
background-position: 70%;
}
p {
margin-bottom: 0;
&.title {
color: #FFD200;
}
}
.info {
background: #314253;
padding-top: $line-height;
@include breakpoint(medium) {
border-top: rem-calc(6) solid #FFD200;
}
}
}
.sucessfull-proposals-banner {
background: #2D3E50 image-url("ballot_tiny.gif") no-repeat;
background-position: 75% 0;
@@ -1045,3 +1015,50 @@
}
}
}
// 07. Polls
// ----------------------
.dark-heading {
background: #2D3E50;
color: white;
.title {
color: #FFD200;
}
.info {
background: #314253;
padding: $line-height;
@include breakpoint(medium) {
border-top: rem-calc(6) solid #FFD200;
}
a {
color: white;
text-decoration: underline;
}
}
&.poll-show {
min-height: $line-height*8;
}
}
.poll, .poll-question {
background: white;
border-bottom: 1px solid $border;
margin-bottom: $line-height/2;
padding: $line-height;
.date {
color: $brand;
font-size: $small-font-size;
}
h3 a {
color: $text;
}
}

View File

@@ -22,7 +22,7 @@
<%= setting['per_page_code'].try(:html_safe) %>
</head>
<body>
<div class="wrapper">
<div class="wrapper <%= yield (:wrapper_class) %>">
<%= render 'layouts/header' %>
<!--[if lt IE 9]>

View File

@@ -1,7 +1,31 @@
<%= render 'shared/filter_subnav', i18n_namespace: "polls.index" %>
<% provide :title do %><%= t("polls.index.title") %><% end %>
<% content_for :wrapper_class, "light" %>
<% @polls.each do |poll| %>
<%= link_to poll.name, poll %> (<%= poll_dates(poll) %>)
<% end %>
<div class="expanded no-margin-top dark-heading">
<div class="row">
<div class="small-12 medium-6 column padding">
<h1><%= t("polls.index.title") %></h1>
</div>
</div>
</div>
<%= paginate @polls %>
<div class="row">
<div class="small-12 medium-3 column">
<%= render 'shared/filter_subnav_vertical', i18n_namespace: "polls.index" %>
</div>
<div class="small-12 medium-9 column margin-top">
<% @polls.each do |poll| %>
<div class="poll">
<h3><%= poll.name %></h3>
<p><%= poll_dates(poll) %></p>
<%= link_to t("polls.index.button"),
poll,
class: "button",
title: t("polls.index.button") + " " + (poll.name) %>
</div>
<% end %>
<%= paginate @polls %>
</div>
</div>

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" %>

View File

@@ -1,54 +1,62 @@
<h1><%= @poll.name %></h1>
<p><strong><%= t("polls.show.dates_title") %>: <%= poll_dates(@poll) %></strong></p>
<% provide :title do %><%= @poll.name %><% end %>
<% content_for :wrapper_class, "light" %>
<% unless can?(:answer, @poll) %>
<div class="expanded no-margin-top dark-heading poll-show">
<div class="row">
<div class="small-12 medium-6 column padding">
<%= render "shared/back_link" %>
<h2><%= @poll.name %></h2>
</div>
<div class="small-12 medium-4 column padding info">
<p class="title">
<strong><%= t("polls.show.dates_title") %></strong>
</p>
<p>
<strong><%= poll_dates(@poll) %></strong>
</p>
</div>
</div>
</div>
<div class="row margin-top">
<div class="small-12 column">
<% if current_user.nil? %>
<div class="callout primary">
<%= t("polls.show.cant_answer_not_logged_in",
signin: link_to(t("polls.show.signin"), new_user_session_path, class: "probe-message"),
signup: link_to(t("polls.show.signup"), new_user_registration_path, class: "probe-message")).html_safe %>
</div>
<% elsif current_user.unverified? %>
<% unless can?(:answer, @poll) %>
<% if current_user.nil? %>
<div class="callout primary">
<%= t("polls.show.cant_answer_not_logged_in",
signin: link_to(t("polls.show.signin"), new_user_session_path, class: "probe-message"),
signup: link_to(t("polls.show.signup"), new_user_registration_path, class: "probe-message")).html_safe %>
</div>
<% elsif current_user.unverified? %>
<div class="callout warning">
<%= t('polls.show.cant_answer_verify_html',
verify_link: link_to(t('polls.show.verify_link'), verification_path)) %>
</div>
<% elsif @poll.incoming? %>
<div class="callout primary">
<%= t('polls.show.cant_answer_incoming') %>
</div>
<% elsif @poll.expired? %>
<div class="callout alert">
<%= t('polls.show.cant_answer_expired') %>
</div>
<% end %>
<% end %>
<% @answerable_questions.each do |question| %>
<%= render 'polls/questions/question', question: question %>
<% end %>
<% if can?(:answer, @poll) &&
@non_answerable_questions.present? %>
<div class="callout warning">
<%= t('polls.show.cant_answer_verify_html',
verify_link: link_to(t('polls.show.verify_link'), verification_path)) %>
</div>
<% elsif @poll.incoming? %>
<div class="callout primary">
<%= t('polls.show.cant_answer_incoming') %>
</div>
<% elsif @poll.expired? %>
<div class="callout alert">
<%= t('polls.show.cant_answer_expired') %>
<%= t('polls.show.cant_answer_wrong_geozone') %>
</div>
<% end %>
<% @non_answerable_questions.each do |question| %>
<%= render 'polls/questions/question', question: question %>
<% end %>
</div>
<% end %>
<% @answerable_questions.each do |question| %>
<div id="<%= dom_id(question) %>">
<%= link_to question.title, question_path(question) %>
<div class="row margin-top text-center" id="<%= dom_id(question) %>_answers">
<%= render 'polls/questions/answers', question: question %>
</div>
</div>
<% end %>
<% if can?(:answer, @poll) &&
@non_answerable_questions.present? %>
<div class="callout warning">
<%= t('polls.show.cant_answer_wrong_geozone') %>
</div>
<% end %>
<% @non_answerable_questions.each do |question| %>
<div id="<%= dom_id(question) %>">
<%= link_to question.title, question_path(question) %>
<div class="row margin-top text-center" id="<%= dom_id(question) %>_answers">
<%= render 'polls/questions/answers', question: question %>
</div>
</div>
<% end %>
</div>

View File

@@ -0,0 +1,14 @@
<ul class="menu vertical clear">
<li class="sr-only"><%= t("#{i18n_namespace}.filter") %>: </li>
<% @valid_filters.each do |filter| %>
<% if @current_filter == filter %>
<li class="active">
<h2><%= t("#{i18n_namespace}.filters.#{filter}") %></h2>
</li>
<% else %>
<li><%= link_to t("#{i18n_namespace}.filters.#{filter}"),
current_path_with_query_params(filter: filter, page: 1) %></li>
<% end %>
<% end %>
</ul>

View File

@@ -387,6 +387,8 @@ en:
current: "Open"
incoming: "Incoming"
expired: "Expired"
title: "Polls"
button: "Participate in this poll"
show:
dates_title: "Participation dates"
cant_answer_not_logged_in: "You must %{signin} or %{signup} to participate."

View File

@@ -387,6 +387,8 @@ es:
current: "Abiertas"
incoming: "Próximamente"
expired: "Terminadas"
title: "Votaciones"
button: "Participar en esta votación"
show:
dates_title: "Fechas de participación"
cant_answer_not_logged_in: "Necesitas %{signin} o %{signup} para participar."

View File

@@ -43,7 +43,7 @@ feature "Home" do
end
def ie_alert_box_xpath
"/html/body/div[@class='wrapper']/comment()[contains(.,'ie-callout')]"
"/html/body/div[@class='wrapper ']/comment()[contains(.,'ie-callout')]"
end
end
end

View File

@@ -10,7 +10,8 @@ feature 'Polls' do
visit polls_path
polls.each do |poll|
expect(page).to have_link(poll.name)
expect(page).to have_content(poll.name)
expect(page).to have_link("Participate in this poll")
end
end