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



11
12
13
14
# File 'app/components/avo/index/field_wrapper_component.rb', line 11

def after_initialize
  @view = Avo::ViewInquirer.new("index")
  @classes = @args.dig(:class) || ""
end

#classesObject



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

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)


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

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

#stimulus_attributesObject



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

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



28
29
30
# File 'app/components/avo/index/field_wrapper_component.rb', line 28

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