Extract view into component

This commit is contained in:
Senén Rodero Rodríguez
2023-01-16 12:10:11 +01:00
parent 7b30ab7e61
commit 569138cbae
3 changed files with 27 additions and 19 deletions

View File

@@ -0,0 +1,19 @@
<table>
<thead>
<tr>
<th><%= t("management.budgets.table_name") %></th>
<th><%= t("management.budgets.table_phase") %></th>
<th><%= t("management.budgets.table_actions") %></th>
</tr>
</thead>
<tbody>
<tr id="<%= dom_id(budget) %>">
<td><%= budget.name %></td>
<td><%= budget.current_phase.name %></td>
<td align="right">
<%= link_to t("management.budgets.print_investments"),
print_management_budget_investments_path(budget) %>
</td>
</tr>
</tbody>
</table>

View File

@@ -0,0 +1,7 @@
class Management::Budgets::PrintInvestments::TableComponent < ApplicationComponent
attr_reader :budget
def initialize(budget)
@budget = budget
end
end

View File

@@ -1,21 +1,3 @@
<h2><%= t("management.budgets.print_investments") %></h2>
<table>
<thead>
<tr>
<th><%= t("management.budgets.table_name") %></th>
<th><%= t("management.budgets.table_phase") %></th>
<th><%= t("management.budgets.table_actions") %></th>
</tr>
</thead>
<tbody>
<tr id="<%= dom_id(@budget) %>">
<td><%= @budget.name %></td>
<td><%= @budget.current_phase.name %></td>
<td align="right">
<%= link_to t("management.budgets.print_investments"),
print_management_budget_investments_path(@budget) %>
</td>
</tr>
</tbody>
</table>
<%= render Management::Budgets::PrintInvestments::TableComponent.new(@budget) %>