Files
nairobi/app/components/admin/table_actions_component.rb
Javi Martín b1f9ca4ad5 Allow custom URLs in links to actions
There were a couple of cases where these links didn't point to the
default actions.
2020-10-19 18:56:02 +02:00

31 lines
631 B
Ruby

class Admin::TableActionsComponent < ApplicationComponent
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 destroy_text
options[:destroy_text] || t("admin.actions.delete")
end
def destroy_path
options[:destroy_path] || admin_polymorphic_path(record)
end
end