Changes in datetimepicker to accepts formats in options
This commit is contained in:
1 parent
897ed49d2e
commit
d24bd176cc
3 files changed
+14
-10
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user