Sha256: e17de48c26d3db3cf2f8ba0f95a29775b4905dc996dff31990c6a8e3df1c7cb8

Contents?: true

Size: 929 Bytes

Versions: 185

Compression:

Stored size: 929 Bytes

Contents

# frozen_string_literal: true

class Avo::Index::Ordering::ButtonsComponent < Avo::Index::Ordering::BaseComponent
  def initialize(resource: nil, reflection: nil, view_type: nil)
    @resource = resource
    @reflection = reflection
    @view_type = view_type
  end

  def render?
    has_with_trial(:resource_ordering) && can_order_any? && view_type_is_table? && enabled_in_view?
  end

  private

  def can_order_any?
    order_actions.present?
  end

  def view_type_is_table?
    @view_type.to_sym == :table
  end

  def display_inline?
    ordering[:display_inline]
  end

  def enabled_in_view?
    in_association = @reflection.present?

    if in_association
      visible_on_option.include? :association
    else
      visible_on_option.include? :index
    end
  end

  def visible_on_option
    return [] if ordering.nil?

    [ordering[:visible_on]].flatten
  end

  def ordering
    @resource.class.ordering
  end
end

Version data entries

185 entries across 185 versions & 1 rubygems

Version Path
avo-2.53.0 app/components/avo/index/ordering/buttons_component.rb
avo-2.52.0 app/components/avo/index/ordering/buttons_component.rb
avo-2.49.0 app/components/avo/index/ordering/buttons_component.rb
avo-2.48.0 app/components/avo/index/ordering/buttons_component.rb
avo-2.47.0 app/components/avo/index/ordering/buttons_component.rb
avo-2.46.0 app/components/avo/index/ordering/buttons_component.rb
avo-2.45.0 app/components/avo/index/ordering/buttons_component.rb
avo-2.44.0 app/components/avo/index/ordering/buttons_component.rb
avo-2.43.0 app/components/avo/index/ordering/buttons_component.rb
avo-2.42.2 app/components/avo/index/ordering/buttons_component.rb
avo-2.42.1 app/components/avo/index/ordering/buttons_component.rb
avo-2.42.0 app/components/avo/index/ordering/buttons_component.rb
avo-2.41.0 app/components/avo/index/ordering/buttons_component.rb
avo-2.40.0 app/components/avo/index/ordering/buttons_component.rb
avo-2.39.0 app/components/avo/index/ordering/buttons_component.rb
avo-2.38.0 app/components/avo/index/ordering/buttons_component.rb
avo-2.37.2 app/components/avo/index/ordering/buttons_component.rb
avo-2.37.1 app/components/avo/index/ordering/buttons_component.rb
avo-2.37.0 app/components/avo/index/ordering/buttons_component.rb
avo-2.36.3 app/components/avo/index/ordering/buttons_component.rb