Class: Avo::FieldWrapperComponent
Constant Summary
Concerns::FindAssociationField::ASSOCIATIONS
Instance Method Summary
collapse
#add_stimulus_attributes_for, #get_stimulus_controllers, #stimulus_data_attributes
#component_name, #has_with_trial
#find_association_field
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
41
42
43
44
|
# File 'app/components/avo/field_wrapper_component.rb', line 29
def classes( = "")
class_names("field-wrapper relative flex flex-col grow pb-2 md:pb-0 leading-tight h-full",
@classes,
,
@field.get_html(:classes, view: @view, element: :wrapper),
{
"min-h-14": !short?,
"min-h-10": short?,
"field-wrapper-size-compact": compact?,
"field-wrapper-size-regular": !compact?,
"field-width-full": full_width?,
"field-width-regular": !full_width?,
"field-wrapper-layout-stacked": stacked?,
"field-wrapper-layout-inline md:flex-row md:items-center": !stacked?
})
end
|
#compact? ⇒ Boolean
104
105
106
|
# File 'app/components/avo/field_wrapper_component.rb', line 104
def compact?
@compact
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
112
113
114
|
# File 'app/components/avo/field_wrapper_component.rb', line 112
def full_width?
@full_width
end
|
#help ⇒ Object
60
61
62
|
# File 'app/components/avo/field_wrapper_component.rb', line 60
def help
Avo::ExecutionContext.new(target: @help || @field.help, record: record, resource: @resource, view: @view).handle
end
|
#label ⇒ Object
50
51
52
|
# File 'app/components/avo/field_wrapper_component.rb', line 50
def label
@label || @field.name
end
|
#label_for ⇒ Object
54
55
56
|
# File 'app/components/avo/field_wrapper_component.rb', line 54
def label_for
@label_for || @field.form_field_label
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
116
117
118
119
120
121
122
|
# File 'app/components/avo/field_wrapper_component.rb', line 116
def render_dash?
if @field.type == "boolean"
@field.value.nil?
else
@field.value.blank? && @dash_if_blank
end
end
|
#short? ⇒ Boolean
108
109
110
|
# File 'app/components/avo/field_wrapper_component.rb', line 108
def short?
@short
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
46
47
48
|
# File 'app/components/avo/field_wrapper_component.rb', line 46
def style
"#{@style} #{@field.get_html(:style, view: @view, element: :wrapper)}"
end
|