Move investments executions view to a component

Note that we're changing the component so it uses `polymorphic_path`;
that way we don't have to pass the `@budget` variable to the component.
We could also use `budget_investment_path investment.budget, investment`
instead.
This commit is contained in:
Javi Martín
2024-03-10 19:14:41 +01:00
parent 1057f41d61
commit e3a2a42534
3 changed files with 10 additions and 3 deletions

View File

@@ -0,0 +1,26 @@
<% investments_by_heading.each do |heading, investments| %>
<h4 id="<%= heading.name.parameterize %>">
<%= heading.name %> (<%= investments.count %>)
</h4>
<div class="row" data-equalizer-on="medium" data-equalizer>
<% investments.each do |investment| %>
<div class="small-12 medium-6 large-4 column end margin-bottom">
<div class="budget-execution" data-equalizer-watch>
<%= render Budgets::Executions::ImageComponent.new(investment) %>
<div class="budget-execution-info">
<div class="budget-execution-content">
<h5>
<%= link_to investment.title,
polymorphic_path(investment, anchor: "tab-milestones") %>
</h5>
<span class="author"><%= investment.author.name %></span>
</div>
<p class="price margin-top text-center">
<strong><%= investment.formatted_price %></strong>
</p>
</div>
</div>
</div>
<% end %>
</div>
<% end %>

View File

@@ -0,0 +1,7 @@
class Budgets::Executions::InvestmentsComponent < ApplicationComponent
attr_reader :investments_by_heading
def initialize(investments_by_heading)
@investments_by_heading = investments_by_heading
end
end