diff --git a/app/components/budgets/investments/votes_component.html.erb b/app/components/budgets/investments/votes_component.html.erb
new file mode 100644
index 000000000..efe3e63cc
--- /dev/null
+++ b/app/components/budgets/investments/votes_component.html.erb
@@ -0,0 +1,56 @@
+<% reason = investment.reason_for_not_being_selectable_by(current_user) %>
+<% voting_allowed = true unless reason.presence == :not_voting_allowed %>
+<% user_voted_for = voted_for?(investment_votes, investment) %>
+
+
+
+
">
+ <%= t("budgets.investments.investment.supports", count: investment.total_votes) %>
+
+
+
+ <% if user_voted_for %>
+
+ <%= t("budgets.investments.investment.already_supported") %>
+
+ <% elsif investment.should_show_votes? %>
+ <%= link_to vote_url,
+ class: "button button-support small expanded",
+ title: t("budgets.investments.investment.support_title"),
+ method: "post",
+ remote: (display_support_alert? ? false : true),
+ data: (display_support_alert? ? {
+ confirm: t("budgets.investments.investment.confirm_group", count: investment.group.max_votable_headings) } : nil),
+ "aria-hidden" => css_for_aria_hidden(reason) do %>
+ <%= t("budgets.investments.investment.give_support") %>
+ <% end %>
+ <% end %>
+
+
+ <% if reason.present? && !user_voted_for %>
+
+
+
+ <%= sanitize(t("votes.budget_investments.#{reason}",
+ count: investment.group.max_votable_headings,
+ verify_account: link_to_verify_account,
+ signin: link_to_signin,
+ signup: link_to_signup,
+ supported_headings: (current_user && current_user.headings_voted_within_group(investment.group).map(&:name).sort.to_sentence)
+ )) %>
+
+
+
+ <% end %>
+
+ <% if user_voted_for && setting["twitter_handle"] %>
+
+ <%= render "shared/social_share",
+ title: investment.title,
+ image_url: image_absolute_url(investment.image, :thumb),
+ url: budget_investment_url(investment.budget, investment),
+ description: investment.title,
+ mobile: investment.title %>
+
+ <% end %>
+
diff --git a/app/components/budgets/investments/votes_component.rb b/app/components/budgets/investments/votes_component.rb
new file mode 100644
index 000000000..c8c9a12d3
--- /dev/null
+++ b/app/components/budgets/investments/votes_component.rb
@@ -0,0 +1,23 @@
+class Budgets::Investments::VotesComponent < ApplicationComponent
+ attr_reader :investment, :investment_votes, :vote_url
+ delegate :current_user, :voted_for?, :image_absolute_url,
+ :link_to_verify_account, :link_to_signin, :link_to_signup, to: :helpers
+
+ def initialize(investment, investment_votes:, vote_url:)
+ @investment = investment
+ @investment_votes = investment_votes
+ @vote_url = vote_url
+ end
+
+ private
+
+ def display_support_alert?
+ current_user &&
+ !current_user.voted_in_group?(investment.group) &&
+ investment.group.headings.count > 1
+ end
+
+ def css_for_aria_hidden(reason)
+ reason.present? ? "true" : ""
+ end
+end
diff --git a/app/helpers/accessibility_helper.rb b/app/helpers/accessibility_helper.rb
deleted file mode 100644
index b53ada9ad..000000000
--- a/app/helpers/accessibility_helper.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-module AccessibilityHelper
- def css_for_aria_hidden(reason)
- reason.present? ? "true" : ""
- end
-end
diff --git a/app/helpers/budgets_helper.rb b/app/helpers/budgets_helper.rb
index e07b73192..f7c196bbb 100644
--- a/app/helpers/budgets_helper.rb
+++ b/app/helpers/budgets_helper.rb
@@ -54,12 +54,6 @@ module BudgetsHelper
end
end
- def display_support_alert?(investment)
- current_user &&
- !current_user.voted_in_group?(investment.group) &&
- investment.group.headings.count > 1
- end
-
def budget_subnav_items_for(budget)
{
results: t("budgets.results.link"),
diff --git a/app/views/budgets/investments/_votes.html.erb b/app/views/budgets/investments/_votes.html.erb
index c2924b990..d134506c1 100644
--- a/app/views/budgets/investments/_votes.html.erb
+++ b/app/views/budgets/investments/_votes.html.erb
@@ -1,56 +1,5 @@
-<% reason = investment.reason_for_not_being_selectable_by(current_user) %>
-<% voting_allowed = true unless reason.presence == :not_voting_allowed %>
-<% user_voted_for = voted_for?(investment_votes, investment) %>
-
-
-
-
">
- <%= t("budgets.investments.investment.supports", count: investment.total_votes) %>
-
-
-
- <% if user_voted_for %>
-
- <%= t("budgets.investments.investment.already_supported") %>
-
- <% elsif investment.should_show_votes? %>
- <%= link_to vote_url,
- class: "button button-support small expanded",
- title: t("budgets.investments.investment.support_title"),
- method: "post",
- remote: (display_support_alert?(investment) ? false : true),
- data: (display_support_alert?(investment) ? {
- confirm: t("budgets.investments.investment.confirm_group", count: investment.group.max_votable_headings) } : nil),
- "aria-hidden" => css_for_aria_hidden(reason) do %>
- <%= t("budgets.investments.investment.give_support") %>
- <% end %>
- <% end %>
-
-
- <% if reason.present? && !user_voted_for %>
-
-
-
- <%= sanitize(t("votes.budget_investments.#{reason}",
- count: investment.group.max_votable_headings,
- verify_account: link_to_verify_account,
- signin: link_to_signin,
- signup: link_to_signup,
- supported_headings: (current_user && current_user.headings_voted_within_group(investment.group).map(&:name).sort.to_sentence)
- )) %>
-
-
-
- <% end %>
-
- <% if user_voted_for && setting["twitter_handle"] %>
-
- <%= render "shared/social_share",
- title: investment.title,
- image_url: image_absolute_url(investment.image, :thumb),
- url: budget_investment_url(investment.budget, investment),
- description: investment.title,
- mobile: investment.title %>
-
- <% end %>
-
+<%= render Budgets::Investments::VotesComponent.new(
+ investment,
+ investment_votes: investment_votes,
+ vote_url: vote_url
+) %>