Class: Avo::Fields::BooleanGroupField::EditComponent
- Inherits:
-
EditComponent
- Object
- ViewComponent::Base
- BaseComponent
- EditComponent
- Avo::Fields::BooleanGroupField::EditComponent
- Defined in:
- app/components/avo/fields/boolean_group_field/edit_component.rb
Constant Summary
Constants included from Concerns::FindAssociationField
Concerns::FindAssociationField::ASSOCIATIONS
Instance Attribute Summary
Attributes inherited from EditComponent
#field, #form, #full_width, #index, #kwargs, #multiple, #resource, #stacked, #view
Instance Method Summary collapse
-
#checked?(id) ⇒ Boolean
Get the state of each checkboxe from either the form that returns a validation error or from the model itself.
-
#initialize ⇒ EditComponent
constructor
A new instance of EditComponent.
Methods inherited from EditComponent
#classes, #disabled?, #field_wrapper_args, #render?
Methods included from ResourcesHelper
#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
Methods inherited from BaseComponent
Methods included from ApplicationHelper
#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
Methods included from Concerns::FindAssociationField
Constructor Details
#initialize ⇒ EditComponent
Returns a new instance of EditComponent.
4 5 6 7 8 9 10 11 12 |
# File 'app/components/avo/fields/boolean_group_field/edit_component.rb', line 4 def initialize(...) super # Initialize here to avoid multiple calls to @field.get_html for each option. @classes = "size-4 #{@field.get_html(:classes, view: view, element: :input)}" @data = @field.get_html(:data, view: view, element: :input) @style = @field.get_html(:style, view: view, element: :input) @form_scope = @form.object_name end |
Instance Method Details
#checked?(id) ⇒ Boolean
Get the state of each checkboxe from either the form that returns a validation error or from the model itself.
15 16 17 18 19 20 21 |
# File 'app/components/avo/fields/boolean_group_field/edit_component.rb', line 15 def checked?(id) if params[@form_scope].present? && params[@form_scope][@field.id.to_s].present? params[@form_scope][@field.id.to_s].include?(id.to_s) elsif @field.value.present? @field.value.with_indifferent_access[id] end end |