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:
Javi Martín
2020-06-30 19:26:07 +02:00
parent 99dad7a7b6
commit ccb7695056
6 changed files with 12 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
class Admin::Budgets::TableActionsComponent < ApplicationComponent
include TableActionLink
attr_reader :budget
def initialize(budget)

View File

@@ -1,4 +1,5 @@
class Admin::HiddenTableActionsComponent < ApplicationComponent
include TableActionLink
attr_reader :record
def initialize(record)

View File

@@ -1,4 +1,5 @@
class Admin::Organizations::TableActionsComponent < ApplicationComponent
include TableActionLink
delegate :can?, to: :controller
attr_reader :organization

View File

@@ -1,4 +1,5 @@
class Admin::Roles::TableActionsComponent < ApplicationComponent
include TableActionLink
attr_reader :record, :actions
def initialize(record, actions: [:destroy])

View File

@@ -1,4 +1,5 @@
class Admin::TableActionsComponent < ApplicationComponent
include TableActionLink
attr_reader :record, :options
def initialize(record = nil, **options)

View File

@@ -0,0 +1,7 @@
module TableActionLink
extend ActiveSupport::Concern
def link_to(text, url, **options)
super(text, url, options)
end
end