Class: DatePickerInput

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

Direct Known Subclasses

DatetimePickerInput

Instance Method Summary collapse

Instance Method Details

#class_nameObject



38
39
40
# File 'app/inputs/date_picker_input.rb', line 38

def class_name
  "datepicker"
end

#icon_calendarObject



30
31
32
# File 'app/inputs/date_picker_input.rb', line 30

def icon_calendar
  "<span class='prefix'><i class='far fa-calendar'></i></span>".html_safe
end

#input(_wrapper_options) ⇒ Object

Note that where we use ‘wrapper: :clockpicker` or `wrapper: horizontal_clockpicker`, #input is not called and we call #prefix_column and #input_column directly.



6
7
8
9
10
11
# File 'app/inputs/date_picker_input.rb', line 6

def input(_wrapper_options)
  template.tag.div(class: "row collapse #{class_name}-wrapper") do
    template.concat prefix_column
    template.concat input_column
  end
end

#input_column(_wrapper_options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'app/inputs/date_picker_input.rb', line 19

def input_column(_wrapper_options = {})
  html_options = input_html_options
  html_options[:class] ||= []
  html_options[:class] << class_name
  template.tag.div(class: "small-10 columns") do
    datestamp = @builder.object.public_send(attribute_name)
    value = format_date(datestamp)
    template.concat @builder.text_field(attribute_name, html_options.merge(value: value))
  end
end

#input_typeObject



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

def input_type
  :string
end

#prefix_column(_wrapper_options = {}) ⇒ Object



13
14
15
16
17
# File 'app/inputs/date_picker_input.rb', line 13

def prefix_column(_wrapper_options = {})
  template.tag.div(class: "small-2 columns") do
    template.concat icon_calendar
  end
end