From cef9bf600cc2946304fada34c7ab02ef12716fde Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Fri, 3 Feb 2017 12:34:34 +0100 Subject: [PATCH 1/4] shows question as title if poll has only one question --- app/views/polls/_poll_group.html.erb | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/app/views/polls/_poll_group.html.erb b/app/views/polls/_poll_group.html.erb index 20770014b..d9ffb1d33 100644 --- a/app/views/polls/_poll_group.html.erb +++ b/app/views/polls/_poll_group.html.erb @@ -3,18 +3,24 @@
<%= poll_dates(poll) %>
-

<%= link_to poll.name, poll %>

-
    + <% if poll.questions.count == 1 %> <% poll.questions.each do |question| %> -
  • <%= link_to question.title, question_path(question) %>
  • +

    <%= link_to question.title, question_path(question) %>

    <% end %> -
- <% if poll.geozones.any? %> -

- <%= t("polls.index.geozone_info") %> -

+ <% else %> +

<%= link_to poll.name, poll %>

+
    + <% poll.questions.each do |question| %> +
  • <%= link_to question.title, question_path(question) %>
  • + <% end %> +
<% end %> -
    + <% if poll.geozones.any? %> + + <%= t("polls.index.geozone_info") %> + + <% end %> +
      <% poll.geozones.each do |g| %>
    • <%= g.name %>
    • <% end %> From 6728fe6751b3d6327c2caea33d614d20e22a35a7 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Fri, 3 Feb 2017 14:23:26 +0100 Subject: [PATCH 2/4] adds icons of answerable on polls index --- app/assets/stylesheets/participation.scss | 58 +++++++++++++++++++++++ app/views/polls/_poll_group.html.erb | 29 +++++++++++- config/locales/en.yml | 4 ++ config/locales/es.yml | 4 ++ 4 files changed, 93 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 8c1529531..e849afc81 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -1368,6 +1368,63 @@ 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, + &.unverified:after { + font-family: "icons" !important; + left: 34px; + position: absolute; + top: 5px; + } + + &.can-answer { + border-right: 60px solid $success-bg; + + &:after { + color: $color-success; + content: "\59"; + } + } + + &.cant-answer { + border-right: 60px solid $warning-bg; + + &:after { + color: $color-warning; + content: "\76"; + } + } + + &.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"; + } + } + } .dates { color: $text-medium; @@ -1375,6 +1432,7 @@ ul.ballot-list { @include breakpoint(medium) { float: right; + margin-right: $line-height; } } diff --git a/app/views/polls/_poll_group.html.erb b/app/views/polls/_poll_group.html.erb index d9ffb1d33..8784de066 100644 --- a/app/views/polls/_poll_group.html.erb +++ b/app/views/polls/_poll_group.html.erb @@ -1,5 +1,30 @@ <% poll_group.each do |poll| %>
      + <% if poll.answerable_by?(current_user) && poll.votable_by?(current_user) %> +
      "> + <%= t("polls.index.can_answer") %> +
      + <% 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 %> + + <%= t("polls.index.cant_answer_not_logged_in") %> + + <% end %> + <% elsif current_user.unverified? %> + <%= link_to verification_path, + class: "icon-poll-answer unverified", + title: t("polls.index.cant_answer_verify") do %> + + <%= t("polls.index.cant_answer_verify") %> + + <% end %> + <% else %> +
      "> + <%= t("polls.index.cant_answer") %> +
      + <% end %>
      <%= poll_dates(poll) %>
      @@ -16,9 +41,9 @@
    <% end %> <% if poll.geozones.any? %> - +

    <%= t("polls.index.geozone_info") %> - +

    <% end %>
      <% poll.geozones.each do |g| %> diff --git a/config/locales/en.yml b/config/locales/en.yml index dd1d12976..78be150cd 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -406,6 +406,10 @@ en: no_geozone_restricted: "All city" geozone_restricted: "Districts" geozone_info: "Only can participate people in the Census of: " + can_answer: "You can participate in this poll!" + cant_answer: "This poll is not available on your geozone" + cant_answer_not_logged_in: "You must sign in or sign up to participate" + cant_answer_verify: "You must verify your account in order to answer" show: dates_title: "Participation dates" cant_answer_not_logged_in: "You must %{signin} or %{signup} to participate." diff --git a/config/locales/es.yml b/config/locales/es.yml index 0ced2f9c8..273bfa93d 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -406,6 +406,10 @@ es: no_geozone_restricted: "Toda la ciudad" geozone_restricted: "Distritos" geozone_info: "Solo pueden participar las personas empadronadas en: " + can_answer: "¡Puedes participar en esta votación!" + cant_answer: "Esta votación no está disponible en tu zona" + cant_answer_not_logged_in: "Necesitas iniciar sesión o registrarte para participar" + cant_answer_verify: "Por favor verifica tu cuenta para poder responder" show: dates_title: "Fechas de participación" cant_answer_not_logged_in: "Necesitas %{signin} o %{signup} para participar." From 54472852caa5972c91c499d841af6cd5bd30f650 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Fri, 3 Feb 2017 14:26:56 +0100 Subject: [PATCH 3/4] changes link to poll on polls with one question --- app/views/polls/_poll_group.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/polls/_poll_group.html.erb b/app/views/polls/_poll_group.html.erb index 8784de066..a34191415 100644 --- a/app/views/polls/_poll_group.html.erb +++ b/app/views/polls/_poll_group.html.erb @@ -30,7 +30,7 @@
      <%= poll_dates(poll) %>
      <% if poll.questions.count == 1 %> <% poll.questions.each do |question| %> -

      <%= link_to question.title, question_path(question) %>

      +

      <%= link_to question.title, poll %>

      <% end %> <% else %>

      <%= link_to poll.name, poll %>

      From 46d9961c363379801357de35953aaee4a5137c6e Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Fri, 3 Feb 2017 17:43:44 +0100 Subject: [PATCH 4/4] adds icon if already answer poll --- app/assets/stylesheets/participation.scss | 22 ++++++++++++++++------ app/views/polls/_poll_group.html.erb | 14 +++++++++++--- config/locales/en.yml | 1 + config/locales/es.yml | 1 + 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index e849afc81..4726d0114 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -1382,6 +1382,7 @@ ul.ballot-list { &.can-answer:after, &.cant-answer:after, &.not-logged-in:after, + &.already-answer:after, &.unverified:after { font-family: "icons" !important; left: 34px; @@ -1390,20 +1391,20 @@ ul.ballot-list { } &.can-answer { - border-right: 60px solid $success-bg; + border-right: 60px solid $info-bg; &:after { - color: $color-success; - content: "\59"; + color: $color-info; + content: "\6c"; } } &.cant-answer { - border-right: 60px solid $warning-bg; + border-right: 60px solid $alert-bg; &:after { - color: $color-warning; - content: "\76"; + color: $color-alert; + content: "\74"; } } @@ -1424,6 +1425,15 @@ ul.ballot-list { content: "\6f"; } } + + &.already-answer { + border-right: 60px solid $success-bg; + + &:after { + color: $color-success; + content: "\59"; + } + } } .dates { diff --git a/app/views/polls/_poll_group.html.erb b/app/views/polls/_poll_group.html.erb index a34191415..d9a36bd47 100644 --- a/app/views/polls/_poll_group.html.erb +++ b/app/views/polls/_poll_group.html.erb @@ -1,9 +1,13 @@ <% poll_group.each do |poll| %>
      <% if poll.answerable_by?(current_user) && poll.votable_by?(current_user) %> -
      "> - <%= t("polls.index.can_answer") %> -
      + <%= link_to poll, + class: "icon-poll-answer can-answer", + title: t("polls.index.can_answer") do %> + + <%= t("polls.index.can_answer") %> + + <% end %> <% elsif current_user.nil? %> <%= link_to new_user_session_path, class: "icon-poll-answer not-logged-in", @@ -20,6 +24,10 @@ <%= t("polls.index.cant_answer_verify") %> <% end %> + <% elsif !poll.votable_by?(current_user) %> +
      "> + <%= t("polls.index.already_answer") %> +
      <% else %>
      "> <%= t("polls.index.cant_answer") %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 78be150cd..3f812fffb 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -410,6 +410,7 @@ en: cant_answer: "This poll is not available on your geozone" cant_answer_not_logged_in: "You must sign in or sign up to participate" cant_answer_verify: "You must verify your account in order to answer" + already_answer: "You already have participated in this poll" show: dates_title: "Participation dates" cant_answer_not_logged_in: "You must %{signin} or %{signup} to participate." diff --git a/config/locales/es.yml b/config/locales/es.yml index 273bfa93d..adeae8825 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -410,6 +410,7 @@ es: cant_answer: "Esta votación no está disponible en tu zona" cant_answer_not_logged_in: "Necesitas iniciar sesión o registrarte para participar" cant_answer_verify: "Por favor verifica tu cuenta para poder responder" + already_answer: "Ya has participado en esta votación" show: dates_title: "Fechas de participación" cant_answer_not_logged_in: "Necesitas %{signin} o %{signup} para participar."