Sha256: bc2ca2110635a7716bb2f6d87ecbe3cb3275d16b8158518f9a1db8f7705bf31f

Contents?: true

Size: 977 Bytes

Versions: 76

Compression:

Stored size: 977 Bytes

Contents

# frozen_string_literal: true

class Avo::Fields::IndexComponent < Avo::BaseComponent
  include Avo::ResourcesHelper

  attr_reader :field
  attr_reader :kwargs
  attr_reader :parent_resource
  attr_reader :view

  def initialize(field: nil, resource: nil, reflection: nil, index: 0, parent_record: nil, parent_resource: nil, **kwargs)
    @field = field
    @resource = resource
    @index = index
    @kwargs = kwargs
    @parent_record = parent_record
    @parent_resource = parent_resource
    @view = Avo::ViewInquirer.new("index")
    @reflection = reflection
  end

  def resource_view_path
    args = {}

    if @parent_record.present?
      args = {
        via_resource_class: @parent_resource.class,
        via_record_id: @parent_record.to_param
      }
    end

    helpers.resource_view_path(record: @resource.record, resource: parent_or_child_resource, **args)
  end

  def field_wrapper_args
    {
      field: @field,
      resource: @resource
    }
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
avo-3.14.3 app/components/avo/fields/index_component.rb
avo-3.14.2 app/components/avo/fields/index_component.rb
avo-3.14.1 app/components/avo/fields/index_component.rb
avo-3.14.0 app/components/avo/fields/index_component.rb
avo-3.13.7 app/components/avo/fields/index_component.rb
avo-3.13.6 app/components/avo/fields/index_component.rb
avo-3.13.5 app/components/avo/fields/index_component.rb
avo-3.13.4 app/components/avo/fields/index_component.rb
avo-3.13.3 app/components/avo/fields/index_component.rb
avo-3.13.2 app/components/avo/fields/index_component.rb
avo-3.13.1 app/components/avo/fields/index_component.rb
avo-3.13.0 app/components/avo/fields/index_component.rb
avo-3.12.0 app/components/avo/fields/index_component.rb
avo-3.11.10 app/components/avo/fields/index_component.rb
avo-3.11.9 app/components/avo/fields/index_component.rb
avo-3.11.8 app/components/avo/fields/index_component.rb
avo-3.11.7 app/components/avo/fields/index_component.rb
avo-3.11.6 app/components/avo/fields/index_component.rb
avo-3.11.5 app/components/avo/fields/index_component.rb
avo-3.11.4 app/components/avo/fields/index_component.rb