<% end %>
<% end %>
- <% if Avo.configuration.resource_controls_on_the_right? %>
+ <% if @resource.resource_controls_render_on_the_right? %>
<%= render resource_controls_component %>
diff --git a/app/views/avo/partials/_table_header.html.erb b/app/views/avo/partials/_table_header.html.erb
index 32ff1e622c..bafb43bc09 100644
--- a/app/views/avo/partials/_table_header.html.erb
+++ b/app/views/avo/partials/_table_header.html.erb
@@ -26,7 +26,7 @@
<% end %>
<% end %>
- <% if Avo.configuration.resource_controls_on_the_left? %>
+ <% if @resource.resource_controls_render_on_the_left? %>
|
|
@@ -100,7 +100,7 @@
<% end %>
<% end %>
<% end %>
- <% if Avo.configuration.resource_controls_on_the_right? %>
+ <% if @resource.resource_controls_render_on_the_right? %>
|
diff --git a/lib/avo/concerns/controls_placement.rb b/lib/avo/concerns/controls_placement.rb
new file mode 100644
index 0000000000..5ad97b25dd
--- /dev/null
+++ b/lib/avo/concerns/controls_placement.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+module Avo
+ module Concerns
+ module ControlsPlacement
+ extend ActiveSupport::Concern
+
+ def controls_placement_calculated
+ @controls_placement_calculated ||= controls_placement || Avo.configuration.resource_controls_placement
+ end
+
+ def resource_controls_render_on_the_right?
+ controls_placement_calculated == :right || resource_controls_render_on_both_sides?
+ end
+
+ def resource_controls_render_on_the_left?
+ controls_placement_calculated == :left || resource_controls_render_on_both_sides?
+ end
+
+ private
+
+ def resource_controls_render_on_both_sides?
+ controls_placement_calculated == :both
+ end
+ end
+ end
+end
diff --git a/lib/avo/configuration/resource_configuration.rb b/lib/avo/configuration/resource_configuration.rb
index b1591ed5d6..1ab6944653 100644
--- a/lib/avo/configuration/resource_configuration.rb
+++ b/lib/avo/configuration/resource_configuration.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
module Avo
class Configuration
module ResourceConfiguration
@@ -8,14 +10,6 @@ def resource_controls_placement=(val)
def resource_controls_placement
@resource_controls_placement_instance || :right
end
-
- def resource_controls_on_the_left?
- resource_controls_placement == :left
- end
-
- def resource_controls_on_the_right?
- resource_controls_placement == :right
- end
end
end
end
diff --git a/lib/avo/resources/base.rb b/lib/avo/resources/base.rb
index d1e4f3700b..b14f2f26b1 100644
--- a/lib/avo/resources/base.rb
+++ b/lib/avo/resources/base.rb
@@ -15,6 +15,7 @@ class Base
include Avo::Concerns::HasHelpers
include Avo::Concerns::Hydration
include Avo::Concerns::Pagination
+ include Avo::Concerns::ControlsPlacement
# Avo::Current methods
delegate :context, to: Avo::Current
@@ -78,6 +79,7 @@ def current_user
class_attribute :components, default: {}
class_attribute :default_sort_column, default: :created_at
class_attribute :default_sort_direction, default: :desc
+ class_attribute :controls_placement, default: nil
# EXTRACT:
class_attribute :ordering