Class: Tailwinds::Form::MultiselectComponent
- Inherits:
-
TailwindComponent
- Object
- ViewComponent::Base
- Tramway::BaseComponent
- TailwindComponent
- Tailwinds::Form::MultiselectComponent
- Defined in:
- app/components/tailwinds/form/multiselect_component.rb
Overview
Tailwind-styled multi-select field
Constant Summary
Constants inherited from TailwindComponent
TailwindComponent::SIZE_CLASSES
Instance Method Summary collapse
Methods included from Tramway::Helpers::ViewsHelper
#tramway_back_button, #tramway_badge, #tramway_button, #tramway_cell, #tramway_container, #tramway_flash, #tramway_form_for, #tramway_header, #tramway_row, #tramway_table, #tramway_title
Methods included from Tramway::Helpers::ComponentHelper
Methods included from Tramway::Helpers::DecorateHelper
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name) ⇒ Object (private)
72 73 74 75 76 77 78 79 80 |
# File 'app/components/tailwinds/form/multiselect_component.rb', line 72 def method_missing(method_name, *, &) component = component_name(method_name) if method_name.to_s.include?('_') && Object.const_defined?(component) render(component.constantize.new(*, &)) else super end end |
Instance Method Details
#before_render ⇒ Object
9 10 11 12 13 |
# File 'app/components/tailwinds/form/multiselect_component.rb', line 9 def before_render @collection = collection.map do |(text, value)| { text:, value: } end.to_json end |
#controller ⇒ Object
22 23 24 25 26 27 |
# File 'app/components/tailwinds/form/multiselect_component.rb', line 22 def controller controllers = [:multiselect] controllers << external_action.split('->').last.split('#').first if external_action controllers += external_controllers controllers.join(' ') end |
#multiselect_hash ⇒ Object
15 16 17 18 19 20 |
# File 'app/components/tailwinds/form/multiselect_component.rb', line 15 def multiselect_hash { controller:, selected_item_template:, multiselect_selected_items_value:, dropdown_container:, item_container:, items:, action:, select_as_input:, placeholder:, value:, on_change: }.transform_keys { |key| key.to_s.gsub('_', '-') } end |