Class: Avo::Index::FieldWrapperComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/avo/index/field_wrapper_component.rb

Constant Summary

Constants included from Concerns::FindAssociationField

Concerns::FindAssociationField::ASSOCIATIONS

Instance Method Summary collapse

Methods inherited from BaseComponent

#has_with_trial

Methods included from Concerns::FindAssociationField

#find_association_field

Instance Method Details

#after_initializeObject



14
15
16
# File 'app/components/avo/index/field_wrapper_component.rb', line 14

def after_initialize
  @view = Avo::ViewInquirer.new("index")
end

#classesObject



18
19
20
21
22
23
24
25
26
27
28
# File 'app/components/avo/index/field_wrapper_component.rb', line 18

def classes
  result = @classes

  unless @flush
    result += " py-3"
  end

  result += " #{@field.get_html(:classes, view: @view, element: :wrapper)}"

  result
end

#render_dash?Boolean

Returns:

  • (Boolean)


49
50
51
52
53
54
55
# File 'app/components/avo/index/field_wrapper_component.rb', line 49

def render_dash?
  if @field.type == "boolean"
    @field.value.nil?
  else
    @field.value.blank? && @dash_if_blank
  end
end

#stimulus_attributesObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/components/avo/index/field_wrapper_component.rb', line 34

def stimulus_attributes
  attributes = {}

  @resource.get_stimulus_controllers.split(" ").each do |controller|
    attributes["#{controller}-target"] = "#{@field.id.to_s.underscore}_#{@field.type.to_s.underscore}_wrapper".camelize(:lower)
  end

  wrapper_data_attributes = @field.get_html :data, view: @view, element: :wrapper
  if wrapper_data_attributes.present?
    attributes.merge! wrapper_data_attributes
  end

  attributes
end

#styleObject



30
31
32
# File 'app/components/avo/index/field_wrapper_component.rb', line 30

def style
  @field.get_html(:style, view: @view, element: :wrapper)
end