Files
nairobi/app/components/users/budget_investment_table_actions_component.rb
Javi Martín 2fb8eaf6c7 Add aria-labels to user investment actions
This way it'll be easier for people using screen readers to know which
link/button they're about to click.

Note that, at least for now, we aren't reusing the code en
`Admin::ActionComponent`. We might do so in the future if we implement
similar code in more parts of the public area.
2024-11-08 12:29:37 +01:00

31 lines
896 B
Ruby

class Users::BudgetInvestmentTableActionsComponent < ApplicationComponent
attr_reader :investment
use_helpers :can?
def initialize(investment)
@investment = investment
end
private
def edit_link
link_to t("shared.edit"),
edit_budget_investment_path(investment.budget, investment),
"aria-label": action_label(t("shared.edit")),
class: "button hollow"
end
def destroy_button
button_to t("shared.delete"),
budget_investment_path(investment.budget, investment),
method: :delete,
"aria-label": action_label(t("shared.delete")),
class: "button hollow alert",
data: { confirm: t("users.show.delete_alert") }
end
def action_label(action_text)
t("shared.actions.label", action: action_text, name: investment.title)
end
end