activeadmin-plugins / active_admin_datetimepicker

:calendar: active_admin_datetimepicker gem
MIT License
72 stars 48 forks source link

Problem for custom format #9

Closed cpfarher closed 8 years ago

cpfarher commented 8 years ago

When I try to use:

This if for front-end javascript side

ActiveAdminDatetimepicker::Base.default_datetime_picker_options = { defaultDate: proc { Time.current.strftime("%Y-%m-%d 00:00") } }

This if for backend(Ruby)

ActiveAdminDatetimepicker::Base.format = "%Y-%m-%d %H:%M:%S"

in initializers of active admin, I get this error:

/config/initializers/util.rb:8:in `<top (required)>': uninitialized constant ActiveAdminDatetimepicker::Base (NameError)

Fivell commented 8 years ago

@cpfarher , can you share test app with issue to reproduce ?

cpfarher commented 8 years ago

Sure, look at: https://github.com/cpfarher/testapp

Just run rails s

Here I put the code for the format: https://github.com/cpfarher/testapp/blob/master/config/initializers/init_datetimpicker.rb

workgena commented 8 years ago

@cpfarher some trouble with gem version. RubyGems has old version(0.1.0).

Solution: In you Gemfile use this

gem 'active_admin_datetimepicker', '0.1.1', github: 'activeadmin-plugins/active_admin_datetimepicker'

Feel free to ask about custom date-time format

Fivell commented 8 years ago

@workgena ,

Pushing gem to https://rubygems.org...
Successfully registered gem: active_admin_datetimepicker (0.1.1)
Fivell commented 8 years ago

@cpfarher , can you reproduce issue with 0.1.1 ?

cpfarher commented 8 years ago

Still with others problems, now: 1- Look at: http://localhost:3000/admin/events/new elaboration date does not respect the format: d/m/Y H:M when select a date.

If you save and then edit, the date was ok.

1- Uncaught RangeError: Maximum call stack size exceeded if not comment the lines in: https://github.com/cpfarher/testapp/blob/master/config/initializers/init_datetimpicker.rb#L2-L4 So for this code I couldn't pass parameters like mask, default date, etc.

thank you!

cpfarher commented 8 years ago

@Fivell yes, I update the gem to 0.1.1 and then appear the problems that I described above

suryadana commented 8 years ago

pleas help me i try use plugin error on. /var/lib/gems/2.1.0/gems/active_admin_datetimepicker-0.1.1/lib/active_admin_datetimepicker/inputs/filters/date_time_range_input.rb:4:in `module:Filters': uninitialized constant ActiveAdmin::Inputs::Filters::DateRangeInput (NameError)

Fivell commented 8 years ago

@surydana, looks like you're using old unsupported version of active admin

workgena commented 8 years ago

If you need different format - you can set it in initializers

# /config/initializers/init_datetimpicker.rb
# Example "11/03/2016 13:00"
ActiveAdminDatetimepicker::Base.default_datetime_picker_options = {
    format: 'd/m/Y H:i' # JS format
}
ActiveAdminDatetimepicker::Base.format = "%d/%m/%Y %H:%M" # Ruby format