Class: Avo::Fields::IndexComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
ResourcesHelper
Defined in:
app/components/avo/fields/index_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ResourcesHelper

#edit_field_wrapper, #filter_wrapper, #index_field_wrapper, #item_select_all_input, #item_selector_init, #item_selector_input, #resource_grid, #resource_table, #show_field_wrapper

Constructor Details

#initialize(field: nil, resource: nil, index: 0, parent_model: nil) ⇒ IndexComponent

Returns a new instance of IndexComponent.



8
9
10
11
12
13
14
# File 'app/components/avo/fields/index_component.rb', line 8

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

Instance Attribute Details

#viewObject (readonly)

Returns the value of attribute view.



6
7
8
# File 'app/components/avo/fields/index_component.rb', line 6

def view
  @view
end

Instance Method Details

#resource_pathObject



16
17
18
19
20
21
22
# File 'app/components/avo/fields/index_component.rb', line 16

def resource_path
  if @parent_model.present?
    helpers.resource_path(model: @resource.model, resource: @resource, via_resource_class: @parent_model.class, via_resource_id: @parent_model.id)
  else
    helpers.resource_path(model: @resource.model, resource: @resource)
  end
end