Class: ClockPickerInput

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

Instance Method Summary collapse

Instance Method Details

#class_nameObject



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

def class_name
  "clockpicker"
end

#icon_clockObject



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

def icon_clock
  "<span class='prefix'><i class='far fa-clock'></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/clock_picker_input.rb', line 6

def input(_wrapper_options)
  template.(: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/clock_picker_input.rb', line 19

def input_column(_wrapper_options = {})
  html_options = input_html_options
  html_options[:class] ||= []
  html_options[:class] << class_name
  template.(:div, class: "small-9 columns") do
    datestamp = @builder.object.public_send(attribute_name)
    value = datestamp.present? ? I18n.l(datestamp, format: :time) : ""
    template.concat @builder.text_field(attribute_name, html_options.merge(value: value))
  end
end

#input_typeObject



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

def input_type
  :string
end

#prefix_column(_wrapper_options = {}) ⇒ Object



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

def prefix_column(_wrapper_options = {})
  template.(:div, class: "small-3 input-group-addon columns") do
    template.concat(icon_clock)
  end
end