Move executions image partial to a component
This way it'll be easier to write tests for it. We also get rid of another helper file :).
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
<% milestone = first_milestone_with_image(investment) %>
|
|
||||||
|
|
||||||
<% if milestone&.image.present? %>
|
<% if milestone&.image.present? %>
|
||||||
<%= image_tag milestone.image.variant(:large), alt: milestone.image.title %>
|
<%= image_tag milestone.image.variant(:large), alt: milestone.image.title %>
|
||||||
<% elsif investment.image.present? %>
|
<% elsif investment.image.present? %>
|
||||||
14
app/components/budgets/executions/image_component.rb
Normal file
14
app/components/budgets/executions/image_component.rb
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
class Budgets::Executions::ImageComponent < ApplicationComponent
|
||||||
|
attr_reader :investment
|
||||||
|
|
||||||
|
def initialize(investment)
|
||||||
|
@investment = investment
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def milestone
|
||||||
|
investment.milestones.order_by_publication_date
|
||||||
|
.select { |milestone| milestone.image.present? }.last
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
module BudgetExecutionsHelper
|
|
||||||
def first_milestone_with_image(investment)
|
|
||||||
investment.milestones.order_by_publication_date
|
|
||||||
.select { |milestone| milestone.image.present? }.last
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
<div class="small-12 medium-6 large-4 column end margin-bottom">
|
<div class="small-12 medium-6 large-4 column end margin-bottom">
|
||||||
<div class="budget-execution">
|
<div class="budget-execution">
|
||||||
<%= link_to budget_investment_path(@budget, investment, anchor: "tab-milestones"), data: { "equalizer-watch": true } do %>
|
<%= link_to budget_investment_path(@budget, investment, anchor: "tab-milestones"), data: { "equalizer-watch": true } do %>
|
||||||
<%= render "image", investment: investment %>
|
<%= render Budgets::Executions::ImageComponent.new(investment) %>
|
||||||
<div class="budget-execution-info">
|
<div class="budget-execution-info">
|
||||||
<div class="budget-execution-content">
|
<div class="budget-execution-content">
|
||||||
<h5><%= investment.title %></h5>
|
<h5><%= investment.title %></h5>
|
||||||
|
|||||||
Reference in New Issue
Block a user