Class: Avo::Index::FieldWrapperComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Avo::Index::FieldWrapperComponent
- Defined in:
- app/components/avo/index/field_wrapper_component.rb
Instance Attribute Summary collapse
-
#view ⇒ Object
readonly
Returns the value of attribute view.
Instance Method Summary collapse
- #classes ⇒ Object
-
#initialize(field: nil, resource: nil, dash_if_blank: true, center_content: false, flush: false, **args) ⇒ FieldWrapperComponent
constructor
A new instance of FieldWrapperComponent.
- #stimulus_attributes ⇒ Object
- #style ⇒ Object
Constructor Details
#initialize(field: nil, resource: nil, dash_if_blank: true, center_content: false, flush: false, **args) ⇒ FieldWrapperComponent
Returns a new instance of FieldWrapperComponent.
6 7 8 9 10 11 12 13 14 15 |
# File 'app/components/avo/index/field_wrapper_component.rb', line 6 def initialize(field: nil, resource: nil, dash_if_blank: true, center_content: false, flush: false, **args) @field = field @resource = resource @dash_if_blank = dash_if_blank @center_content = center_content @classes = args[:class].present? ? args[:class] : "" @args = args @flush = flush @view = Avo::ViewInquirer.new("index") end |
Instance Attribute Details
#view ⇒ Object (readonly)
Returns the value of attribute view.
4 5 6 |
# File 'app/components/avo/index/field_wrapper_component.rb', line 4 def view @view end |
Instance Method Details
#classes ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/components/avo/index/field_wrapper_component.rb', line 17 def classes result = @classes unless @flush result += " py-3" end result += " #{@field.get_html(:classes, view: view, element: :wrapper)}" result end |
#stimulus_attributes ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/components/avo/index/field_wrapper_component.rb', line 33 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 |
#style ⇒ Object
29 30 31 |
# File 'app/components/avo/index/field_wrapper_component.rb', line 29 def style @field.get_html(:style, view: view, element: :wrapper) end |