Sha256: e2bd73a56583db5addd5808b3ad822063d3fe0204fc355a790ef98e4b743e801

Contents?: true

Size: 895 Bytes

Versions: 26

Compression:

Stored size: 895 Bytes

Contents

# frozen_string_literal: true

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

  attr_reader :field
  attr_reader :parent_resource
  attr_reader :view

  def initialize(field: nil, resource: nil, reflection: nil, index: 0, parent_model: nil, parent_resource: nil)
    @field = field
    @resource = resource
    @index = index
    @parent_model = parent_model
    @parent_resource = parent_resource
    @view = :index
    @reflection = reflection
  end

  def resource_view_path
    args = {}

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

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

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

Version data entries

26 entries across 26 versions & 1 rubygems

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