Extract budget investment's info to a component

This commit is contained in:
decabeza
2020-04-21 12:38:29 +02:00
committed by Javi Martín
parent 4c23f639be
commit bbb4e04c7c
3 changed files with 32 additions and 23 deletions

View File

@@ -0,0 +1,24 @@
<p class="investment-project-info">
<%= l investment.created_at.to_date %>
<% if investment.author.hidden? || investment.author.erased? %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<span class="author">
<%= t("budgets.investments.show.author_deleted") %>
</span>
<% else %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<span class="author">
<%= investment.author.name %>
</span>
<% if investment.author.official? %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<span class="label round level-<%= investment.author.official_level %>">
<%= investment.author.official_position %>
</span>
<% end %>
<% end %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<%= investment.heading.name %>
</p>

View File

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

View File

@@ -21,30 +21,8 @@
<% cache [locale_and_user_status(investment), "index", investment, investment.author] do %>
<h3><%= link_to investment.title, namespaced_budget_investment_path(investment) %></h3>
<p class="investment-project-info">
<%= l investment.created_at.to_date %>
<%= render Budgets::Investments::InfoComponent.new(investment) %>
<% if investment.author.hidden? || investment.author.erased? %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<span class="author">
<%= t("budgets.investments.show.author_deleted") %>
</span>
<% else %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<span class="author">
<%= investment.author.name %>
</span>
<% if investment.author.official? %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<span class="label round level-<%= investment.author.official_level %>">
<%= investment.author.official_position %>
</span>
<% end %>
<% end %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<%= investment.heading.name %>
</p>
<div class="investment-project-description">
<%= wysiwyg(investment.description) %>
<div class="truncate"></div>