From 00bfcdf38f4c326aa11b9f2e886998aac2a7e304 Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 15 May 2020 10:37:10 +0200 Subject: [PATCH] Add supports info section on budgets index page --- app/assets/stylesheets/participation.scss | 49 ++++++++++++++++ app/helpers/budgets_helper.rb | 4 ++ app/views/budgets/_budget.html.erb | 2 + app/views/budgets/_investments_list.html.erb | 2 +- app/views/budgets/_supports_info.html.erb | 42 ++++++++++++++ config/locales/en/budgets.yml | 11 ++++ config/locales/es/budgets.yml | 11 ++++ spec/system/budgets/budgets_spec.rb | 61 ++++++++++++++++++++ 8 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 app/views/budgets/_supports_info.html.erb diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 6b8c89e04a9..7367b9c736c 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -2111,6 +2111,55 @@ } } +.supports-info { + + @include breakpoint(medium) { + + h2 { + font-size: rem-calc(48); + } + + h3 { + font-size: rem-calc(36); + } + } + + h2, + h3 { + font-weight: normal; + } + + .callout { + border: 6px solid #f4f4f4; + border-radius: rem-calc(12); + padding: $line-height; + + @include breakpoint(medium) { + padding: $line-height * 2 0 $line-height; + } + } + + .fa-thumbs-up { + color: $brand; + font-size: rem-calc(100); + padding: $line-height * 2 0; + } + + .fa-angle-double-down { + font-size: rem-calc(24); + } + + a { + + &.keep-scrolling { + color: $brand; + position: relative; + text-decoration: none; + text-transform: uppercase; + } + } +} + // 07. Proposals successful // ------------------------- diff --git a/app/helpers/budgets_helper.rb b/app/helpers/budgets_helper.rb index 7745fe192e4..73fc24f8dec 100644 --- a/app/helpers/budgets_helper.rb +++ b/app/helpers/budgets_helper.rb @@ -132,4 +132,8 @@ def class_for_form(resource) "hide" end end + + def budget_investments_total_supports(user) + Vote.where(votable_type: "Budget::Investment", voter_id: user.id).count + end end diff --git a/app/views/budgets/_budget.html.erb b/app/views/budgets/_budget.html.erb index d111c1fc182..f9beaf9f179 100644 --- a/app/views/budgets/_budget.html.erb +++ b/app/views/budgets/_budget.html.erb @@ -71,6 +71,8 @@ <%= render "groups_and_headings", budget: budget %> <% end %> + <%= render "supports_info", budget: budget %> + <% unless budget.informing? %>

<%= t("budgets.index.map") %>

diff --git a/app/views/budgets/_investments_list.html.erb b/app/views/budgets/_investments_list.html.erb index 6f84d0ddd1d..01ec2494e73 100644 --- a/app/views/budgets/_investments_list.html.erb +++ b/app/views/budgets/_investments_list.html.erb @@ -1,6 +1,6 @@ <% if @investments.any? %>
-
+

<%= t("budgets.show.investments_list") %>

diff --git a/app/views/budgets/_supports_info.html.erb b/app/views/budgets/_supports_info.html.erb new file mode 100644 index 00000000000..8dcdc2111b4 --- /dev/null +++ b/app/views/budgets/_supports_info.html.erb @@ -0,0 +1,42 @@ +<% if budget.selecting? %> +
+
+

<%= sanitize(t("budgets.index.supports_info.title")) %>

+ + + +

<%= t("budgets.index.supports_info.next") %>

+

<%= sanitize(t("budgets.index.supports_info.remember")) %>

+

<%= t("budgets.index.supports_info.different") %>

+
+ +
+

+ <% if current_user %> + <% if budget_investments_total_supports(current_user) == 1 %> + <%= sanitize(t("budgets.index.supports_info.supported_one")) %> + <% else %> + <%= sanitize(t("budgets.index.supports_info.supported", + count: budget_investments_total_supports(current_user))) %> + <% end %> + <% else %> + <%= sanitize(t("budgets.index.supports_info.supported_not_logged_in")) %> + <% end %> +

+ +
+

<%= t("budgets.index.supports_info.time", + phase_end_date: l(budget.current_phase.ends_at.to_date, format: :long)) %>

+ +

<%= t("budgets.index.supports_info.share") %>

+ +

+ + <%= t("budgets.index.supports_info.scrolling") %>
+ +
+

+
+
+
+<% end %> diff --git a/config/locales/en/budgets.yml b/config/locales/en/budgets.yml index edcffcbecb6..19b5f47a9a9 100644 --- a/config/locales/en/budgets.yml +++ b/config/locales/en/budgets.yml @@ -75,6 +75,17 @@ en: title: Help with participatory budgets description: With the participatory budgets the citizens decide to which projects is destined a part of the budget. milestones: Milestones + supports_info: + title: "It's time to support projects!" + next: "Support the projects you would like to see move on to the next phase." + remember: "Remember! You can only cast your support once for each project and each support is irreversible." + different: "You may support on as many different projects as you would like." + supported: "So far you supported %{count} projects." + supported_one: "So far you supported 1 project." + supported_not_logged_in: "Log in to start supporting projects." + time: "There's still time until %{phase_end_date} to support projects." + share: "You can share the projects you have supported on through social media and attract more attention and support to them!" + scrolling: "Keep scrolling to see all ideas" investments: form: title: "Create a budget investment" diff --git a/config/locales/es/budgets.yml b/config/locales/es/budgets.yml index 9fd5c787483..0c292e8296e 100644 --- a/config/locales/es/budgets.yml +++ b/config/locales/es/budgets.yml @@ -75,6 +75,17 @@ es: title: Ayuda sobre presupuestos participativos description: Con los presupuestos participativos la ciudadanía decide a qué proyectos va destinada una parte del presupuesto. milestones: Seguimiento de proyectos + supports_info: + title: "¡Es hora de apoyar proyectos!" + next: "Apoya proyectos que te gustaría ver en la siguiente fase." + remember: "¡Recuerda! Solo puedes emitir tu apoyo una vez por cada proyecto y cada apoyo es irreversible." + different: "Puedes apoyar tantos proyectos diferentes como quieras." + supported: "Hasta ahora has apoyado %{count} proyectos." + supported_one: "Hasta ahora has apoyado 1 proyecto." + supported_not_logged_in: "Entra y empieza a apoyar proyectos." + time: "Hay tiempo hasta el %{phase_end_date} para apoyar proyectos." + share: "Puedes compartir los proyectos que has apoyado en las redes sociales y ¡atraer más atención y apoyos para ellos!" + scrolling: "Sigue desplazándote para ver todas las ideas" investments: form: title: "Crear nuevo proyecto" diff --git a/spec/system/budgets/budgets_spec.rb b/spec/system/budgets/budgets_spec.rb index e0136bb3635..2e52ab7b093 100644 --- a/spec/system/budgets/budgets_spec.rb +++ b/spec/system/budgets/budgets_spec.rb @@ -469,6 +469,67 @@ end end end + + scenario "Show support info on selecting phase" do + budget = create(:budget) + group = create(:budget_group, budget: budget) + heading = create(:budget_heading, group: group) + + voter = create(:user, :level_two) + + %w[informing accepting reviewing valuating publishing_prices balloting reviewing_ballots + finished].each do |phase_name| + budget.update!(phase: phase_name) + + visit budget_path(budget) + + expect(page).not_to have_content "It's time to support projects!" + expect(page).not_to have_content "Support the projects you would like to see move on "\ + "to the next phase." + expect(page).not_to have_content "Remember! You can only cast your support once for each project "\ + "and each support is irreversible." + expect(page).not_to have_content "You may support on as many different projects as you would like." + expect(page).not_to have_content "So far you supported 0 projects." + expect(page).not_to have_content "Log in to start supporting projects." + expect(page).not_to have_content "There's still time until" + expect(page).not_to have_content "You can share the projects you have supported on through social "\ + "media and attract more attention and support to them!" + expect(page).not_to have_link "Keep scrolling to see all ideas" + end + + budget.update!(phase: "selecting") + visit budget_path(budget) + + expect(page).to have_content "It's time to support projects!" + expect(page).to have_content "Support the projects you would like to see move on "\ + "to the next phase." + expect(page).to have_content "Remember! You can only cast your support once for each project "\ + "and each support is irreversible." + expect(page).to have_content "You may support on as many different projects as you would like." + expect(page).to have_content "Log in to start supporting projects" + expect(page).to have_content "There's still time until" + expect(page).to have_content "You can share the projects you have supported on through social "\ + "media and attract more attention and support to them!" + expect(page).to have_link "Keep scrolling to see all ideas" + + login_as(voter) + + visit budget_path(budget) + + expect(page).to have_content "So far you supported 0 projects." + + create(:budget_investment, :selected, heading: heading, voters: [voter]) + + visit budget_path(budget) + + expect(page).to have_content "So far you supported 1 project." + + create_list(:budget_investment, 3, :selected, heading: heading, voters: [voter]) + + visit budget_path(budget) + + expect(page).to have_content "So far you supported 4 projects." + end end context "In Drafting phase" do