Extract methods in user investment table actions
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
<div class="user-budget-investment-table-actions">
|
||||
<% if can? :update, investment %>
|
||||
<%= link_to t("shared.edit"), edit_budget_investment_path(investment.budget, investment),
|
||||
class: "button hollow" %>
|
||||
<%= edit_link %>
|
||||
<% end %>
|
||||
|
||||
<% if can? :destroy, investment %>
|
||||
<%= button_to t("shared.delete"), budget_investment_path(investment.budget, investment),
|
||||
method: :delete, class: "button hollow alert",
|
||||
data: { confirm: t("users.show.delete_alert") } %>
|
||||
<%= destroy_button %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -5,4 +5,20 @@ class Users::BudgetInvestmentTableActionsComponent < ApplicationComponent
|
||||
def initialize(investment)
|
||||
@investment = investment
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def edit_link
|
||||
link_to t("shared.edit"),
|
||||
edit_budget_investment_path(investment.budget, investment),
|
||||
class: "button hollow"
|
||||
end
|
||||
|
||||
def destroy_button
|
||||
button_to t("shared.delete"),
|
||||
budget_investment_path(investment.budget, investment),
|
||||
method: :delete,
|
||||
class: "button hollow alert",
|
||||
data: { confirm: t("users.show.delete_alert") }
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user