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