Files
nairobi/app/components/admin/table_actions_component.rb
Javi Martín 8c1140a1bf Use semantic HTML classes in table actions
Note the CSS could probably be improved to avoid duplication with other
button style definitions. However, that's fine because we're going to
change the style of the links soon.

For the same reason, I haven't bothered to style every single link the
way it was until now.
2020-11-03 14:58:02 +01:00

48 lines
1.0 KiB
Ruby

class Admin::TableActionsComponent < ApplicationComponent
include TableActionLink
attr_reader :record, :options
def initialize(record = nil, **options)
@record = record
@options = options
end
private
def actions
options[:actions] || [:edit, :destroy]
end
def edit_text
options[:edit_text] || t("admin.actions.edit")
end
def edit_path
options[:edit_path] || admin_polymorphic_path(record, action: :edit)
end
def edit_options
{ class: "edit-link" }.merge(options[:edit_options] || {})
end
def destroy_text
options[:destroy_text] || t("admin.actions.delete")
end
def destroy_path
options[:destroy_path] || admin_polymorphic_path(record)
end
def destroy_options
{
method: :delete,
class: "destroy-link",
data: { confirm: destroy_confirmation }
}.merge(options[:destroy_options] || {})
end
def destroy_confirmation
options[:destroy_confirmation] || t("admin.actions.confirm")
end
end