Class: Avo::FieldWrapperComponent
Constant Summary
Concerns::FindAssociationField::ASSOCIATIONS
Instance Method Summary
collapse
#add_stimulus_attributes_for, #get_stimulus_controllers, #stimulus_data_attributes
#component_name, #hotkey_badge
#a_button, #a_link, #body_classes, #button_classes, #chart_color, #container_classes, #d, #decode_filter_params, #e, #editor_file_path, #editor_url, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #mount_path, #number_to_social, #possibly_rails_authentication?, #render_license_warning, #root_path_without_url, #rtl?, #text_direction, #ui, #wrap_in_modal
#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_selector_data_attributes, #record_path, #record_title, #resource_for_record, #resource_grid, #resource_show_path, #resource_table
#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
|
# 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?,
})
end
|
#data ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'app/components/avo/field_wrapper_component.rb', line 67
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
103
104
105
|
# File 'app/components/avo/field_wrapper_component.rb', line 103
def full_width?
@full_width
end
|
#help ⇒ Object
55
56
57
|
# File 'app/components/avo/field_wrapper_component.rb', line 55
def help
Avo::ExecutionContext.new(target: @help || @field.help, record: record, resource: @resource, view: @view).handle
end
|
#label ⇒ Object
45
46
47
|
# File 'app/components/avo/field_wrapper_component.rb', line 45
def label
@label || @field.name
end
|
#label_for ⇒ Object
49
50
51
|
# File 'app/components/avo/field_wrapper_component.rb', line 49
def label_for
@label_for || @field.form_field_label
end
|
#label_help ⇒ Object
59
60
61
|
# File 'app/components/avo/field_wrapper_component.rb', line 59
def label_help
Avo::ExecutionContext.new(target: @label_help || @field.label_help, record: record, resource: @resource, view: @view).handle
end
|
#record ⇒ Object
63
64
65
|
# File 'app/components/avo/field_wrapper_component.rb', line 63
def record
@resource.present? ? @resource.record : nil
end
|
#render_dash? ⇒ Boolean
107
108
109
|
# File 'app/components/avo/field_wrapper_component.rb', line 107
def render_dash?
@field.value.blank? && @dash_if_blank
end
|
#stacked? ⇒ Boolean
92
93
94
95
96
97
98
99
100
101
|
# File 'app/components/avo/field_wrapper_component.rb', line 92
def stacked?
return @stacked unless @stacked.nil?
return @field.stacked unless @field.stacked.nil?
Avo.configuration.field_wrapper_layout == :stacked
end
|
#style ⇒ Object
41
42
43
|
# File 'app/components/avo/field_wrapper_component.rb', line 41
def style
"#{@style} #{@field.get_html(:style, view: @view, element: :wrapper)}"
end
|