activeadmin-plugins / active_admin_datetimepicker

:calendar: active_admin_datetimepicker gem
MIT License
73 stars 47 forks source link

Add data datepicker_options for DateTimeRangeInput, default time form… #6

Closed workgena closed 9 years ago

workgena commented 9 years ago

Fix bug when DateTimeRangeInput does not has datepicker_options. In same way as single-DateTimePickerInput.

Fivell commented 9 years ago

@workgena , can you pls make it more DRY?

workgena commented 9 years ago

@Fivell, check new version

Fivell commented 9 years ago

@workgena , please squash you commits in single one

workgena commented 9 years ago

With this PR now it is possible to override options. For example if you need date-time with seconds, all you need is to add file

/config/initializer/active_admin_datetimepicker.rb
# This if for fornt-end javascript side
ActiveAdminDatetimepicker::Base.default_datetime_picker_options = {
    format: 'Y-m-d H:i:s',
    defaultDate: proc { DateTime.now.utc.strftime('%y-%m-%d') }
}
# This if for backend(Ruby)
ActiveAdminDatetimepicker::Base.format = "%Y-%m-%d %H:%M:%S"

"default_datetime_picker_options" is XDSoft's DateTime picker options. So you can pass any other options same way. Full options list: http://xdsoft.net/jqplugins/datetimepicker/

I recomend add this to README.

Fivell commented 9 years ago

:+1: