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

#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_select_all_input, #item_selector_init, #item_selector_input, #resource_grid, #resource_table

Constructor Details

#initialize(field: nil, resource: nil, index: 0, form: nil, compact: false, stacked: false, multiple: false, **kwargs) ⇒ EditComponent

Returns a new instance of EditComponent.



15
16
17
18
19
20
21
22
23
24
# File 'app/components/avo/fields/edit_component.rb', line 15

def initialize(field: nil, resource: nil, index: 0, form: nil, compact: false, stacked: false, multiple: false, **kwargs)
  @compact = compact
  @field = field
  @form = form
  @index = index
  @multiple = multiple
  @resource = resource
  @stacked = stacked
  @view = :edit
end

Instance Attribute Details

#compactObject (readonly)

Returns the value of attribute compact.



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

def compact
  @compact
end

#fieldObject (readonly)

Returns the value of attribute field.



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

def field
  @field
end

#formObject (readonly)

Returns the value of attribute form.



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

def form
  @form
end

#indexObject (readonly)

Returns the value of attribute index.



9
10
11
# File 'app/components/avo/fields/edit_component.rb', line 9

def index
  @index
end

#multipleObject (readonly)

Returns the value of attribute multiple.



10
11
12
# File 'app/components/avo/fields/edit_component.rb', line 10

def multiple
  @multiple
end

#resourceObject (readonly)

Returns the value of attribute resource.



11
12
13
# File 'app/components/avo/fields/edit_component.rb', line 11

def resource
  @resource
end

#stackedObject (readonly)

Returns the value of attribute stacked.



12
13
14
# File 'app/components/avo/fields/edit_component.rb', line 12

def stacked
  @stacked
end

#viewObject (readonly)

Returns the value of attribute view.



13
14
15
# File 'app/components/avo/fields/edit_component.rb', line 13

def view
  @view
end

Instance Method Details

#classes(extra_classes = "") ⇒ Object



26
27
28
# File 'app/components/avo/fields/edit_component.rb', line 26

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

#field_wrapper_argsObject



34
35
36
37
38
39
40
41
42
43
44
# File 'app/components/avo/fields/edit_component.rb', line 34

def field_wrapper_args
  {
    compact: compact,
    field: field,
    form: form,
    index: index,
    resource: resource,
    stacked: stacked,
    view: view
  }
end

#render?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'app/components/avo/fields/edit_component.rb', line 30

def render?
  !field.computed
end