Class: DatePickerInput

Inherits:
SimpleForm::Inputs::StringInput
  • Object
show all
Defined in:
app/inputs/date_picker_input.rb

Instance Method Summary collapse

Instance Method Details

#input(wrapper_options) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/inputs/date_picker_input.rb', line 2

def input(wrapper_options)
  floating = options.fetch(:floating, false)

  input_html_options[:type] = :text
  input_html_options[:placeholder] ||= 'MM/DD/YYYY'
  input_html_options[:'data-input'] = ''
  input_html_options[:class] = [input_html_options[:class], 'pe-5'].compact.join(' ')
  style_css = input_html_options.delete(:style)

  if floating
    input_html_options[:placeholder] ||= ' '
    input_html_options[:class] = [input_html_options[:class], 'form-control'].compact.join(' ')
    template.(:div, class: 'form-floating date_picker_wrapper date-picker_wrapper_single', style: style_css, data: { controller: 'date-picker' }) do
      template.concat super(wrapper_options)
      template.concat floating_label_tag
      template.concat clear_btn
    end
  else
    out = ActiveSupport::SafeBuffer.new
    out << template.(:div,
      class: 'date_picker_wrapper date-picker_wrapper_single d-flex align-items-center position-relative',
      style: style_css,
      data: { controller: 'date-picker' }) do
      template.concat super(wrapper_options)
      template.concat clear_btn
    end
    out
  end
end

#label(_wrapper_options = nil) ⇒ Object



32
33
34
35
36
# File 'app/inputs/date_picker_input.rb', line 32

def label(_wrapper_options = nil)
  return ''.html_safe if options.fetch(:floating, false)

  super
end