Class: Playbook::PbSelect::Select

Inherits:
KitBase
  • Object
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

Methods included from Playbook::Props

#initialize, #prop

Methods included from Playbook::PbKitHelper

#pb_rails

Instance Method Details

#classnameObject



19
20
21
# File 'app/pb_kits/playbook/pb_select/select.rb', line 19

def classname
  generate_classname("pb_select")
end

#disabled_optionsObject



40
41
42
43
44
45
46
47
# File 'app/pb_kits/playbook/pb_select/select.rb', line 40

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_arrayObject



27
28
29
# File 'app/pb_kits/playbook/pb_select/select.rb', line 27

def options_to_array
  options.map { |option| [option[:value_text] || option[:value], option[:value]] }
end

#select_wrapper_classObject



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

#selectedObject



31
32
33
34
35
36
37
38
# File 'app/pb_kits/playbook/pb_select/select.rb', line 31

def selected
  selections = options.map { |option| option[:value] if option[:selected] == true }.compact
  if selections.empty?
    nil
  else
    selections
  end
end