Allow using table actions in different namespaces

This way we can reuse it in sections like SDGManagement and URLs will be
automatically generated as expected.
This commit is contained in:
Javi Martín
2021-01-07 17:49:24 +01:00
parent 2968275a1c
commit c66a5a30ef
10 changed files with 63 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
class Admin::TableActionsComponent < ApplicationComponent
include TableActionLink
attr_reader :record, :options
delegate :namespace, to: :helpers
def initialize(record = nil, **options)
@record = record
@@ -18,7 +19,7 @@ class Admin::TableActionsComponent < ApplicationComponent
end
def edit_path
options[:edit_path] || admin_polymorphic_path(record, action: :edit)
options[:edit_path] || namespaced_polymorphic_path(namespace, record, action: :edit)
end
def edit_options
@@ -30,7 +31,7 @@ class Admin::TableActionsComponent < ApplicationComponent
end
def destroy_path
options[:destroy_path] || admin_polymorphic_path(record)
options[:destroy_path] || namespaced_polymorphic_path(namespace, record)
end
def destroy_options