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_icon_source, #polaris_inversed_colors
Methods included from OptionHelper
#append_option, #prepend_option
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean
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.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/components/polaris/choice_list_component.rb', line 28 def initialize( title: nil, title_hidden: false, form: nil, attribute: nil, name: nil, selected: [], disabled: false, error: nil, **system_arguments ) @title = title @error = error @form = form @attribute = attribute @name = name @selected = selected @disabled = disabled @system_arguments = system_arguments @system_arguments[:tag] = "fieldset" @system_arguments[:classes] = class_names( @system_arguments[:classes], "Polaris-ChoiceList", "Polaris-ChoiceList--titleHidden": title_hidden ) end |
Instance Method Details
#items ⇒ Object
56 57 58 |
# File 'app/components/polaris/choice_list_component.rb', line 56 def items checkboxes.presence || end |
#multiple_choice_allowed? ⇒ Boolean
64 65 66 |
# File 'app/components/polaris/choice_list_component.rb', line 64 def multiple_choice_allowed? checkboxes.any? end |
#renders? ⇒ Boolean
60 61 62 |
# File 'app/components/polaris/choice_list_component.rb', line 60 def renders? items.any? end |