Changes in datetimepicker to accepts formats in options
This commit is contained in:
parent
897ed49d2e
commit
d24bd176cc
|
@ -34,8 +34,8 @@ module OrbitFormHelper
|
|||
|
||||
def date_picker(object_name, method, options)
|
||||
custom = {}
|
||||
custom[:format] = 'yyyy-MM-dd'
|
||||
custom[:value] = display_date(options[:value]) if options[:value]
|
||||
custom[:format] = options[:format] || 'yyyy/MM'
|
||||
custom[:value] = format_value(options[:value], custom[:format]) if options[:value]
|
||||
custom[:picker_class] = 'date_picker'
|
||||
custom[:label] = options[:label] || I18n.t('datetime_picker.date.label')
|
||||
custom[:placeholder] = options[:placeholder] || I18n.t('datetime_picker.date.placeholder')
|
||||
|
@ -44,8 +44,8 @@ module OrbitFormHelper
|
|||
|
||||
def default_picker(object_name, method, options)
|
||||
custom = {}
|
||||
custom[:format] = 'yyyy-MM-dd hh:mm'
|
||||
custom[:value] = display_date_time(options[:value]) if options[:value]
|
||||
custom[:format] = options[:format] || 'yyyy/MM/dd hh:mm'
|
||||
custom[:value] = format_value(options[:value], custom[:format]) if options[:value]
|
||||
custom[:picker_class] = 'default_picker'
|
||||
custom[:label] = options[:label] || I18n.t('datetime_picker.default.label')
|
||||
custom[:placeholder] = options[:placeholder] || I18n.t('datetime_picker.default.placeholder')
|
||||
|
@ -54,8 +54,8 @@ module OrbitFormHelper
|
|||
|
||||
def time_picker(object_name, method, options)
|
||||
custom = {}
|
||||
custom[:format] = 'hh:mm'
|
||||
custom[:value] = display_time(options[:value]) if options[:value]
|
||||
custom[:format] = options[:format] || 'hh:mm'
|
||||
custom[:value] = format_value(options[:value], custom[:format]) if options[:value]
|
||||
custom[:picker_class] = 'time_picker'
|
||||
custom[:label] = options[:label] || I18n.t('datetime_picker.time.label')
|
||||
custom[:placeholder] = options[:placeholder] || I18n.t('datetime_picker.time.placeholder')
|
||||
|
@ -93,6 +93,10 @@ module OrbitFormHelper
|
|||
end
|
||||
end
|
||||
|
||||
def format_value(value, format)
|
||||
value.strftime(format.gsub('yyyy', '%Y').gsub('MM', '%m').gsub('dd', '%d').gsub('hh', '%H').gsub('mm', '%M'))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
module Orbit::FormBuilder
|
||||
|
|
|
@ -3,10 +3,10 @@ en:
|
|||
datetime_picker:
|
||||
date:
|
||||
label: Date
|
||||
placeholder: "YYYY-MM-DD"
|
||||
placeholder: "YYYY/MM/DD"
|
||||
default:
|
||||
label: Date and time
|
||||
placeholder: "YYYY-MM-DD HH:MM"
|
||||
placeholder: "YYYY/MM/DD HH:MM"
|
||||
separated:
|
||||
label: Date and time
|
||||
time:
|
||||
|
|
|
@ -3,10 +3,10 @@ zh_tw:
|
|||
datetime_picker:
|
||||
date:
|
||||
label: 日期
|
||||
placeholder: "YYYY-MM-DD"
|
||||
placeholder: "YYYY/MM/DD"
|
||||
default:
|
||||
label: 日期和時間
|
||||
placeholder: "YYYY-MM-DD HH:MM"
|
||||
placeholder: "YYYY/MM/DD HH:MM"
|
||||
separated:
|
||||
label: 日期和時間
|
||||
time:
|
||||
|
|
Reference in New Issue