Add supports info section on budgets index page
This commit is contained in:
@@ -32,6 +32,8 @@
|
||||
<%= render Budgets::GroupsAndHeadingsComponent.new(budget) %>
|
||||
<% end %>
|
||||
|
||||
<%= render Budgets::SupportsInfoComponent.new(budget) %>
|
||||
|
||||
<% unless budget.informing? %>
|
||||
<div class="map inline">
|
||||
<h2><%= t("budgets.index.map") %></h2>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<% if investments.any? %>
|
||||
<section class="investments-list">
|
||||
<section id="investments_list" class="investments-list">
|
||||
<header>
|
||||
<h2><%= t("budgets.investments_list.title") %></h2>
|
||||
</header>
|
||||
|
||||
30
app/components/budgets/supports_info_component.html.erb
Normal file
30
app/components/budgets/supports_info_component.html.erb
Normal file
@@ -0,0 +1,30 @@
|
||||
<aside class="supports-info">
|
||||
<section>
|
||||
<header>
|
||||
<h2><%= sanitize(t("budgets.supports_info.title")) %></h2>
|
||||
</header>
|
||||
|
||||
<p><%= t("budgets.supports_info.next") %></p>
|
||||
<p><%= sanitize(t("budgets.supports_info.remember")) %></p>
|
||||
<p><%= t("budgets.supports_info.different") %></p>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<header>
|
||||
<h3><%= support_info_heading %></h3>
|
||||
</header>
|
||||
|
||||
<p><%= t("budgets.supports_info.time",
|
||||
phase_end_date: l(budget.current_phase.ends_at.to_date, format: :long)) %></p>
|
||||
|
||||
<p><%= t("budgets.supports_info.share") %></p>
|
||||
|
||||
<% if budget.single_heading? %>
|
||||
<p>
|
||||
<a href="#investments_list" class="keep-scrolling" data-smooth-scroll>
|
||||
<%= t("budgets.supports_info.scrolling") %><br>
|
||||
</a>
|
||||
</p>
|
||||
<% end %>
|
||||
</section>
|
||||
</aside>
|
||||
26
app/components/budgets/supports_info_component.rb
Normal file
26
app/components/budgets/supports_info_component.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
class Budgets::SupportsInfoComponent < ApplicationComponent
|
||||
delegate :current_user, to: :helpers
|
||||
attr_reader :budget
|
||||
|
||||
def initialize(budget)
|
||||
@budget = budget
|
||||
end
|
||||
|
||||
def render?
|
||||
budget.selecting?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def support_info_heading
|
||||
if current_user
|
||||
sanitize(t("budgets.supports_info.supported", count: total_supports))
|
||||
else
|
||||
sanitize(t("budgets.supports_info.supported_not_logged_in"))
|
||||
end
|
||||
end
|
||||
|
||||
def total_supports
|
||||
Vote.where(votable: budget.investments, voter: current_user).count
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user