Allow custom URLs in links to actions

There were a couple of cases where these links didn't point to the
default actions.
This commit is contained in:
Javi Martín
2020-06-09 17:20:00 +02:00
parent 738646a565
commit b1f9ca4ad5
13 changed files with 53 additions and 48 deletions

View File

@@ -1,7 +1,7 @@
class Admin::TableActionsComponent < ApplicationComponent
attr_reader :record, :options
def initialize(record, **options)
def initialize(record = nil, **options)
@record = record
@options = options
end
@@ -16,7 +16,15 @@ class Admin::TableActionsComponent < ApplicationComponent
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