Class: Playbook::PbSelect::Select
- Inherits:
-
KitBase
- Object
- ViewComponent::Base
- KitBase
- Playbook::PbSelect::Select
show all
- Defined in:
- app/pb_kits/playbook/pb_select/select.rb
Instance Method Summary
collapse
Methods inherited from KitBase
#object
Methods included from ZIndex
included
Methods included from Spacing
included, #max_width_options, #max_width_props, #max_width_values, #spacing_options, #spacing_props, #spacing_values
Methods included from Classnames
#generate_classname, #generate_classname_without_spacing, included
#initialize, #prop
#pb_rails
#pb_form_with
Instance Method Details
#classname ⇒ Object
19
20
21
|
# File 'app/pb_kits/playbook/pb_select/select.rb', line 19
def classname
generate_classname("pb_select", select_margin_bottom, separator: " ")
end
|
#disabled_options ⇒ Object
44
45
46
47
48
49
50
51
|
# File 'app/pb_kits/playbook/pb_select/select.rb', line 44
def disabled_options
disabled_options = options.map { |option| option[:value] if option[:disabled] == true }.compact
if disabled_options.empty?
nil
else
disabled_options
end
end
|
#options_to_array ⇒ Object
31
32
33
|
# File 'app/pb_kits/playbook/pb_select/select.rb', line 31
def options_to_array
options.map { |option| [option[:value_text] || option[:value], option[:value]] }
end
|
#select_margin_bottom ⇒ Object
27
28
29
|
# File 'app/pb_kits/playbook/pb_select/select.rb', line 27
def select_margin_bottom
margin.present? || margin_bottom.present? ? nil : "mb_sm"
end
|
#select_wrapper_class ⇒ Object
23
24
25
|
# File 'app/pb_kits/playbook/pb_select/select.rb', line 23
def select_wrapper_class
"pb_select_kit_wrapper" + error_class
end
|
#selected ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'app/pb_kits/playbook/pb_select/select.rb', line 35
def selected
selections = options.map { |option| option[:value] if option[:selected] == true }.compact
if selections.empty?
nil
else
selections
end
end
|