Extract component for budget groups and headings
This commit is contained in:
committed by
Javi Martín
parent
45135bb87e
commit
16c582f282
@@ -0,0 +1,21 @@
|
||||
<div id="groups_and_headings" class="groups-and-headings">
|
||||
<% budget.groups.each do |group| %>
|
||||
<h2 id="<%= group.name.parameterize %>"><%= group.name %></h2>
|
||||
<ul class="no-bullet" data-equalizer data-equalizer-on="medium">
|
||||
<% group.headings.sort_by_name.each do |heading| %>
|
||||
<li class="heading small-12 medium-4 large-2" data-equalizer-watch>
|
||||
<% unless budget.informing? || budget.finished? %>
|
||||
<%= link_to budget_investments_path(budget.id,
|
||||
heading_id: heading.id) do %>
|
||||
<%= heading_name_and_price_html(heading) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div class="heading-name">
|
||||
<%= heading_name_and_price_html(heading) %>
|
||||
</div>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
</div>
|
||||
16
app/components/budgets/groups_and_headings_component.rb
Normal file
16
app/components/budgets/groups_and_headings_component.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class Budgets::GroupsAndHeadingsComponent < ApplicationComponent
|
||||
attr_reader :budget
|
||||
|
||||
def initialize(budget)
|
||||
@budget = budget
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def heading_name_and_price_html(heading)
|
||||
tag.div do
|
||||
concat(heading.name + " ")
|
||||
concat(tag.span(budget.formatted_heading_price(heading)))
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user