Extact method to get the budget status HTML class

This commit is contained in:
Javi Martín
2021-04-21 13:32:16 +02:00
parent 9f671b9617
commit c50e04e9cb
2 changed files with 5 additions and 1 deletions

View File

@@ -20,7 +20,7 @@
<tbody> <tbody>
<% budgets.each do |budget| %> <% budgets.each do |budget| %>
<tr id="<%= dom_id(budget) %>" class="budget"> <tr id="<%= dom_id(budget) %>" class="budget">
<td class="<%= "budget-completed" if budget.finished? %>"> <td class="<%= status_html_class(budget) %>">
<%= status_text(budget) %> <%= status_text(budget) %>
<strong><%= budget.name %></strong> <strong><%= budget.name %></strong>
</td> </td>

View File

@@ -30,6 +30,10 @@ class Admin::Budgets::IndexComponent < ApplicationComponent
Admin::Budgets::DurationComponent.new(budget).duration Admin::Budgets::DurationComponent.new(budget).duration
end end
def status_html_class(budget)
"budget-completed" if budget.finished?
end
def status_text(budget) def status_text(budget)
if budget.finished? if budget.finished?
tag.span t("admin.budgets.index.table_completed") tag.span t("admin.budgets.index.table_completed")