class UiBibz::Ui::Core::Forms::Dates::DatePickerField

Create a DatePickerField

This element is an extend of UiBibz::Ui::Core::Component.

Attributes

Options

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

Signatures

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

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

Examples

UiBibz::Ui::Core::Forms::Dates::DatePickerField.new('date', { prepend: 'Prepend content', append: 'Append content' }, { class: 'test' })

UiBibz::Ui::Core::Forms::Dates::DatePickerField.new({ date_today_highlight: true, calendar_weeks: true, range: 'to' }, { class: 'test' }) do
  'date'
end

Helper

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

Public Instance Methods

pre_render() click to toggle source

Render html tag

# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 50
def pre_render
  date_picker_field_html_tag
end

Private Instance Methods

autoclose() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 125
def autoclose
  add_html_data('date_autoclose') if options[:autoclose]
end
calendar_weeks() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 121
def calendar_weeks
  add_html_data('date_calendar_weeks') if options[:calendar_weeks]
end
component_html_classes() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 89
def component_html_classes
  super << %w[date_picker form-control]
end
component_html_data() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 70
def component_html_data
  super
  date_locale
  provide
  format
  today_btn
  today_highlight
  calendar_weeks
  autoclose
  dates_disabled
  toggle_active
  days_of_week_disabled
  days_of_week_highlighted
  multiple
  display_mode
  display_mode_min
  display_mode_max
end
component_html_options() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 93
def component_html_options
  super.merge({ disabled: options[:state] == :disabled })
end
date_locale() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 97
def date_locale
  add_html_data 'date_locale', value: I18n.locale.to_s
end
date_picker_field_html_tag() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 56
def date_picker_field_html_tag
  if options[:range]
    UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new(class: 'input-daterange').tap do |sf|
      sf.addon @options[:append] unless @options[:append].nil?
      sf.text_field content[0], nil, html_options
      sf.addon options[:range]
      sf.text_field content[1], nil, html_options
      sf.addon @options[:prepend] unless @options[:prepend].nil?
    end.render
  else
    UiBibz::Ui::Core::Forms::Texts::TextField.new(content, options, html_options).render
  end
end
dates_disabled() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 129
def dates_disabled
  add_html_data('dates_disabled', value: [options[:dates_disabled]].flatten) if options[:dates_disabled]
end
days_of_week_disabled() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 149
def days_of_week_disabled
  add_html_data('date_days_of_week_disabled', value: [options[:days_of_week_disabled]].flatten) if options[:days_of_week_disabled]
end
days_of_week_highlighted() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 153
def days_of_week_highlighted
  add_html_data('date_days_of_week_highlighted', value: [options[:days_of_week_highlighted]].flatten) if options[:days_of_week_highlighted]
end
display_mode() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 137
def display_mode
  add_html_data('date_start_view', value: views[options[:display_mode]]) if options[:display_mode]
end
display_mode_max() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 145
def display_mode_max
  add_html_data('date_max_view_mode', value: views[options[:display_mode_max]]) if options[:display_mode_max]
end
display_mode_min() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 141
def display_mode_min
  add_html_data('date_min_view_mode', value: views[options[:display_mode_min]]) if options[:display_mode_min]
end
format() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 105
def format
  add_html_data 'date_format', value: picker_pattern
end
multiple() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 157
def multiple
  add_html_data('date_multidate', value: options[:multiple]) if options[:multiple]
end
picker_pattern() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 109
def picker_pattern
  options[:format] || I18n.t('datepicker.pformat', default: 'yyyy-mm-dd')
end
provide() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 101
def provide
  add_html_data 'provide', value: 'datepicker'
end
size() click to toggle source

:lg, :sm or :xs

# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 162
def size
  "input-group-#{options[:size]}" if options[:size]
end
status() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 166
def status
  "has-#{options[:status]}" if options[:status]
end
today_btn() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 113
def today_btn
  add_html_data 'date_today_btn', value: 'linked'
end
today_highlight() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 117
def today_highlight
  add_html_data('date_today_highlight') if options[:today_highlight]
end
toggle_active() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 133
def toggle_active
  add_html_data('date_toggle_active')
end
views() click to toggle source
# File lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb, line 170
def views
  {
    days: 0,
    months: 1,
    years: 2,
    decades: 3,
    centuries: 4
  }
end