Class: TimePickerInput
- Inherits:
-
SimpleForm::Inputs::StringInput
- Object
- SimpleForm::Inputs::StringInput
- TimePickerInput
- Defined in:
- app/inputs/time_picker_input.rb
Overview
SimpleForm input wrapper: time-only flatpickr picker. Shows the time in
12-hour AM/PM format to the user but submits 24-hour HH:MM to the server
(what Event#start_time_of_day and friends expect).
Instance Method Summary collapse
Instance Method Details
#input(wrapper_options) ⇒ Object
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/time_picker_input.rb', line 6 def input() [:type] = :text [:placeholder] ||= 'HH:MM AM' [:'data-input'] = '' [:class] = [[:class], 'pe-5'].compact.join(' ') style_css = .delete(:style) controller_data = { controller: 'date-picker', 'date-picker-enable-time-value': true, 'date-picker-no-calendar-value': true, 'date-picker-format-value': 'H:i', 'date-picker-alt-format-value': 'h:i K' } out = ActiveSupport::SafeBuffer.new out << template.content_tag(:div, class: 'time_picker_wrapper date-picker_wrapper_single d-flex align-items-center position-relative', style: style_css, data: controller_data) do template.concat super() template.concat clear_btn end out end |