Class: Polaris::ChoiceListComponent
- Defined in:
- app/components/polaris/choice_list_component.rb
Constant Summary
Constants included from ViewHelper
ViewHelper::POLARIS_HELPERS, ViewHelper::POLARIS_TEXT_STYLES
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Method Summary collapse
-
#initialize(title: nil, title_hidden: false, form: nil, attribute: nil, name: nil, selected: [], disabled: false, error: nil, **system_arguments) ⇒ ChoiceListComponent
constructor
A new instance of ChoiceListComponent.
- #items ⇒ Object
- #multiple_choice_allowed? ⇒ Boolean
- #renders? ⇒ Boolean
Methods included from ViewHelper
#polaris_body_styles, #polaris_html_classes, #polaris_html_styles, #polaris_icon_source
Methods included from StylesListHelper
Methods included from OptionHelper
#append_option, #prepend_option
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #fetch_or_fallback_nested
Methods included from ClassNameHelper
Constructor Details
#initialize(title: nil, title_hidden: false, form: nil, attribute: nil, name: nil, selected: [], disabled: false, error: nil, **system_arguments) ⇒ ChoiceListComponent
Returns a new instance of ChoiceListComponent.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/components/polaris/choice_list_component.rb', line 29 def initialize( title: nil, title_hidden: false, form: nil, attribute: nil, name: nil, selected: [], disabled: false, error: nil, **system_arguments ) @title = title @title_hidden = title_hidden @error = error @form = form @attribute = attribute @name = name @selected = selected @disabled = disabled @system_arguments = system_arguments @system_arguments[:as] = :fieldset @system_arguments[:gap] = {xs: "4", md: "0"} end |
Instance Method Details
#items ⇒ Object
54 55 56 |
# File 'app/components/polaris/choice_list_component.rb', line 54 def items checkboxes.presence || end |
#multiple_choice_allowed? ⇒ Boolean
62 63 64 |
# File 'app/components/polaris/choice_list_component.rb', line 62 def multiple_choice_allowed? checkboxes.any? end |
#renders? ⇒ Boolean
58 59 60 |
# File 'app/components/polaris/choice_list_component.rb', line 58 def renders? items.any? end |