Class: Avo::Fields::EditComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
ResourcesHelper
Defined in:
app/components/avo/fields/edit_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, form: nil, displayed_in_modal: false) ⇒ EditComponent

Returns a new instance of EditComponent.



9
10
11
12
13
14
15
16
# File 'app/components/avo/fields/edit_component.rb', line 9

def initialize(field: nil, resource: nil, index: 0, form: nil, displayed_in_modal: false)
  @field = field
  @resource = resource
  @index = index
  @form = form
  @displayed_in_modal = displayed_in_modal
  @view = :edit
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



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

def field
  @field
end

#viewObject (readonly)

Returns the value of attribute view.



7
8
9
# File 'app/components/avo/fields/edit_component.rb', line 7

def view
  @view
end

Instance Method Details

#classes(extra_classes = "") ⇒ Object



18
19
20
# File 'app/components/avo/fields/edit_component.rb', line 18

def classes(extra_classes = "")
  helpers.input_classes("#{@field.get_html(:classes, view: view, element: :input)} #{extra_classes}", has_error: @field.model_errors.include?(@field.id))
end

#render?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'app/components/avo/fields/edit_component.rb', line 22

def render?
  !field.computed
end