Use a custom link_to method for table actions
This way we'll be able to change the behavior of these links without changing the view nor affecting the rest of the application.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
class Admin::Budgets::TableActionsComponent < ApplicationComponent
|
||||
include TableActionLink
|
||||
attr_reader :budget
|
||||
|
||||
def initialize(budget)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admin::HiddenTableActionsComponent < ApplicationComponent
|
||||
include TableActionLink
|
||||
attr_reader :record
|
||||
|
||||
def initialize(record)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admin::Organizations::TableActionsComponent < ApplicationComponent
|
||||
include TableActionLink
|
||||
delegate :can?, to: :controller
|
||||
attr_reader :organization
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admin::Roles::TableActionsComponent < ApplicationComponent
|
||||
include TableActionLink
|
||||
attr_reader :record, :actions
|
||||
|
||||
def initialize(record, actions: [:destroy])
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admin::TableActionsComponent < ApplicationComponent
|
||||
include TableActionLink
|
||||
attr_reader :record, :options
|
||||
|
||||
def initialize(record = nil, **options)
|
||||
|
||||
7
app/components/concerns/table_action_link.rb
Normal file
7
app/components/concerns/table_action_link.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
module TableActionLink
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def link_to(text, url, **options)
|
||||
super(text, url, options)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user