diff --git a/app/assets/stylesheets/budgets/investments/sidebar.scss b/app/assets/stylesheets/budgets/investments/my_ballot.scss similarity index 100% rename from app/assets/stylesheets/budgets/investments/sidebar.scss rename to app/assets/stylesheets/budgets/investments/my_ballot.scss diff --git a/app/components/budgets/investments/my_ballot_component.html.erb b/app/components/budgets/investments/my_ballot_component.html.erb new file mode 100644 index 000000000..e44105a26 --- /dev/null +++ b/app/components/budgets/investments/my_ballot_component.html.erb @@ -0,0 +1,44 @@ +
+ + + <% if ballot.investments.by_heading(heading.id).count > 0 %> +

+ <%= sanitize(ballot.voted_info(heading)) %> +

+ <% elsif assigned_heading.present? %> +

+ <%= sanitize(t("budgets.investments.index.sidebar.different_heading_assigned", + heading_link: heading_link(assigned_heading, budget) + )) %> +
+ + <%= sanitize(t("budgets.investments.index.sidebar.change_ballot", + check_ballot: link_to(t("budgets.investments.index.sidebar.check_ballot_link"), + budget_ballot_path(budget)))) %> + +

+ <% else %> +

<%= t("budgets.investments.index.sidebar.zero") %>

+ <% end %> + +

+ <%= sanitize(ballot.change_vote_info( + link: link_to(t("budgets.investments.index.sidebar.change_vote_link"), + budget_ballot_path(budget)))) %> +

+ + + + <%= link_to t("budgets.investments.header.check_ballot"), + budget_ballot_path(budget), + class: "button hollow expanded" %> +
diff --git a/app/components/budgets/investments/my_ballot_component.rb b/app/components/budgets/investments/my_ballot_component.rb new file mode 100644 index 000000000..cbbfa2413 --- /dev/null +++ b/app/components/budgets/investments/my_ballot_component.rb @@ -0,0 +1,17 @@ +class Budgets::Investments::MyBallotComponent < ApplicationComponent + attr_reader :ballot, :heading, :investment_ids, :assigned_heading + delegate :heading_link, to: :helpers + + def initialize(ballot:, heading:, investment_ids:, assigned_heading:) + @ballot = ballot + @heading = heading + @investment_ids = investment_ids + @assigned_heading = assigned_heading + end + + private + + def budget + ballot.budget + end +end diff --git a/app/views/budgets/investments/_sidebar.html.erb b/app/views/budgets/investments/_sidebar.html.erb index bcd169918..83126cef7 100644 --- a/app/views/budgets/investments/_sidebar.html.erb +++ b/app/views/budgets/investments/_sidebar.html.erb @@ -13,50 +13,12 @@ <% end %> <% if @heading && can?(:show, @ballot) %> -
- - - <% if @ballot.investments.by_heading(@heading.id).count > 0 %> -

- <%= sanitize(@ballot.voted_info(@heading)) %> -

- <% elsif @assigned_heading.present? %> -

- <%= sanitize(t("budgets.investments.index.sidebar.different_heading_assigned", - heading_link: heading_link(@assigned_heading, @budget) - )) %> -
- - <%= sanitize(t("budgets.investments.index.sidebar.change_ballot", - check_ballot: link_to(t("budgets.investments.index.sidebar.check_ballot_link"), - budget_ballot_path(@budget)))) %> - -

- <% else %> -

<%= t("budgets.investments.index.sidebar.zero") %>

- <% end %> - -

- <%= sanitize(@ballot.change_vote_info( - link: link_to(t("budgets.investments.index.sidebar.change_vote_link"), - budget_ballot_path(@budget)))) %> -

- - - - <%= link_to t("budgets.investments.header.check_ballot"), - budget_ballot_path(@budget), - class: "button hollow expanded" %> -
+ <%= render Budgets::Investments::MyBallotComponent.new( + ballot: @ballot, + heading: @heading, + investment_ids: @investment_ids, + assigned_heading: @assigned_heading + ) %> <% end %> <%= render Budgets::Investments::ContentBlocksComponent.new(@heading) %>