Class: Avo::Edit::FieldWrapperComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/avo/edit/field_wrapper_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(field: nil, dash_if_blank: true, full_width: false, displayed_in_modal: false, form: nil, resource: {}, label: nil, **args) ⇒ FieldWrapperComponent

Returns a new instance of FieldWrapperComponent.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/components/avo/edit/field_wrapper_component.rb', line 4

def initialize(field: nil, dash_if_blank: true, full_width: false, displayed_in_modal: false, form: nil, resource: {}, label: nil, **args)
  @field = field
  @dash_if_blank = dash_if_blank
  @classes = args[:class].present? ? args[:class] : ""
  @args = args
  @displayed_in_modal = displayed_in_modal
  @form = form
  @resource = resource
  @model = resource.present? ? resource.model : nil
  @full_width = full_width
  @label = label

  if (@index != 0) || @displayed_in_modal
    @classes += " border-t"
  end
end

Instance Method Details

#labelObject



21
22
23
# File 'app/components/avo/edit/field_wrapper_component.rb', line 21

def label
  @label || @field.name
end