class UiBibz::Ui::Core::Forms::Selects::DropdownSelectField

Create a DropdownSelectField

This element is an extend of UiBibz::Ui::Core::Forms::Buttons::Button source : loudev.com/

Attributes

Options

You can add HTML attributes using the html_options. You can pass arguments in options attribute:

Signatures

UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new(content, options = {}, html_options = {}).render

UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new(options = {}, html_options = {}) do
  content
end.render

Examples

UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('fruits', { option_tags: list_of_fruits, searchable: true }, { class: 'test' })

UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new({ option_tags: list_of_fruits, select_all_option: true }, { class: 'test' }) do
  'fruits'
end

Helper

dropdown_select_field(content, options = {}, html_options = {})

Private Instance Methods

alignment() click to toggle source
# File lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb, line 146
def alignment
  "dropdown-menu-#{@options[:alignment]}" unless @options[:alignment].nil?
end
button_status() click to toggle source
# File lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb, line 159
def button_status
  ['btn', outline, options[:status] || :secondary].compact.join('-')
end
clickable_opt_group() click to toggle source
# File lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb, line 95
def clickable_opt_group
  add_html_data('enable_clickable_opt_groups') if options[:clickable_opt_group]
end
collapsible_opt_group() click to toggle source
# File lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb, line 99
def collapsible_opt_group
  add_html_data('enable_collapsible_opt_groups') if options[:collapsible_opt_group]
end
component_html_classes() click to toggle source
# File lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb, line 78
def component_html_classes
  [open, size, type, button_status, 'multi-select-field']
end
component_html_data() click to toggle source
# File lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb, line 82
def component_html_data
  super
  clickable_opt_group
  collapsible_opt_group
  searchable
  non_selected_text
  select_all_options
  number_displayed
  dropdown_menu_classes
  dropdown_classes
  n_selected_text
end
component_html_options() click to toggle source

See UiBibz::Ui::Core::Forms::Buttons::Button.initialize

# File lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb, line 69
def component_html_options
  super.merge({
                multiple: options[:multiple],
                disabled: options[:state] == :disabled,
                include_blank: false,
                prompt: false
              })
end
dropdown_classes() click to toggle source
dropdown_menu_classes() click to toggle source
n_selected_text() click to toggle source
# File lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb, line 108
def n_selected_text
  add_html_data('n_selected_text', value: options[:n_selected_text]) if options[:n_selected_text]
end
non_selected_text() click to toggle source
# File lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb, line 120
def non_selected_text
  add_html_data('non_selected_text', value: options[:non_selected_text]) if options[:non_selected_text]
end
number_displayed() click to toggle source
# File lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb, line 112
def number_displayed
  add_html_data('number_displayed') if options[:number_displayed]
end
open() click to toggle source
# File lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb, line 142
def open
  'show' if @options[:open]
end
outline() click to toggle source
# File lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb, line 163
def outline
  'outline' if options[:outline]
end
position() click to toggle source
# File lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb, line 134
def position
  "drop#{@options[:position] || 'down'}"
end
searchable() click to toggle source
# File lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb, line 103
def searchable
  add_html_data('enable_filtering') if options[:searchable]
  add_html_data('fuzzy_search') if options[:searchable] == :fuzzy
end
select_all_options() click to toggle source
# File lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb, line 116
def select_all_options
  add_html_data('include_select_all_option') if options[:select_all_options]
end
size() click to toggle source

:lg, :sm or :xs

# File lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb, line 155
def size
  "btn-#{options[:size]}" if options[:size]
end
theme() click to toggle source
# File lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb, line 138
def theme
  'dropdown-menu-dark' if @options[:theme]
end
type() click to toggle source
# File lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb, line 150
def type
  'btn-block' if options[:type] == :block
end