Class: Avo::FieldWrapperComponent
Instance Method Summary
collapse
#add_stimulus_attributes_for, #get_stimulus_controllers, #stimulus_data_attributes
Instance Method Details
#after_initialize ⇒ Object
24
25
26
27
|
# File 'app/components/avo/field_wrapper_component.rb', line 24
def after_initialize
@action = @field.action
@classes = @args.dig(:class) || ""
end
|
#classes(extra_classes = "") ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/components/avo/field_wrapper_component.rb', line 29
def classes( = "")
class_names("field-wrapper",
@classes,
,
@field.width_class,
@field.get_html(:classes, view: @view, element: :wrapper),
{
"field-wrapper--stacked": stacked?,
"field-wrapper--full-width": full_width?,
"field-wrapper--density-#{@density}": @density && @density != :default,
})
end
|
#data ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'app/components/avo/field_wrapper_component.rb', line 68
def data
attributes = {
field_id: @field.id,
field_type: @field.type,
**@data
}
wrapper_data_attributes = @field.get_html :data, view: @view, element: :wrapper
if wrapper_data_attributes.present?
attributes.merge! wrapper_data_attributes
end
if @resource.present?
add_stimulus_attributes_for(@resource, attributes)
end
if @action.present?
add_stimulus_attributes_for(@action, attributes)
end
attributes
end
|
#full_width? ⇒ Boolean
104
105
106
|
# File 'app/components/avo/field_wrapper_component.rb', line 104
def full_width?
@full_width
end
|
#help ⇒ Object
56
57
58
|
# File 'app/components/avo/field_wrapper_component.rb', line 56
def help
Avo::ExecutionContext.new(target: @help || @field.help, record: record, resource: @resource, view: @view).handle
end
|
#label ⇒ Object
46
47
48
|
# File 'app/components/avo/field_wrapper_component.rb', line 46
def label
@label || @field.name
end
|
#label_for ⇒ Object
50
51
52
|
# File 'app/components/avo/field_wrapper_component.rb', line 50
def label_for
@label_for || @field.form_field_label
end
|
#label_help ⇒ Object
60
61
62
|
# File 'app/components/avo/field_wrapper_component.rb', line 60
def label_help
Avo::ExecutionContext.new(target: @label_help || @field.label_help, record: record, resource: @resource, view: @view).handle
end
|
#record ⇒ Object
64
65
66
|
# File 'app/components/avo/field_wrapper_component.rb', line 64
def record
@resource.present? ? @resource.record : nil
end
|
#render_dash? ⇒ Boolean
108
109
110
|
# File 'app/components/avo/field_wrapper_component.rb', line 108
def render_dash?
@field.value.blank? && @dash_if_blank
end
|
#stacked? ⇒ Boolean
93
94
95
96
97
98
99
100
101
102
|
# File 'app/components/avo/field_wrapper_component.rb', line 93
def stacked?
return @stacked unless @stacked.nil?
return @field.stacked unless @field.stacked.nil?
Avo.configuration.field_wrapper_layout == :stacked
end
|
#style ⇒ Object
42
43
44
|
# File 'app/components/avo/field_wrapper_component.rb', line 42
def style
"#{@style} #{@field.get_html(:style, view: @view, element: :wrapper)}"
end
|