Extract component to render an execution

Note that, in order to be consistent with the name of the component,
we're renaming the `budget-execution` class to
`budget-executions-investment`.
This commit is contained in:
Javi Martín
2024-03-10 21:57:11 +01:00
parent 764d22f57a
commit 75b03791b1
6 changed files with 78 additions and 71 deletions

View File

@@ -5,21 +5,7 @@
<div class="budgets-executions-heading-investments">
<% investments.each do |investment| %>
<div class="budget-execution">
<%= 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>
<%= render Budgets::Executions::InvestmentComponent.new(investment) %>
<% end %>
</div>
</div>

View File

@@ -0,0 +1,15 @@
<div class="budget-executions-investment">
<%= 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>

View File

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