activeadmin-plugins / active_admin_datetimepicker

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

inputs value converted to date on active_admin 2.0 #57

Closed senid231 closed 5 years ago

senid231 commented 5 years ago

after submit filters we see only date (without time) in inputs value

this patch fix the issue

module DateTimeRangeInputPatch
  def input_html_options(input_name = gt_input_name, placeholder = gt_input_placeholder)
    super.tap do |options|
      options[:value] = current_value_for(input_name)
    end
  end

  def current_value_for(input_name)
    @object.public_send(input_name).to_s.to_time.strftime("%F %T")
  rescue
    ''
  end
end

ActiveAdmin::Inputs::Filters::DateTimeRangeInput.include DateTimeRangeInputPatch
senid231 commented 5 years ago

gem version 0.7.1

workgena commented 5 years ago

Check the following:

  1. The database column type is TIMESTAMP or DATETIME
  2. Html id attribute should end with _datetime

Here is some test cases it 'submit filter form' do:

https://github.com/activeadmin-plugins/active_admin_datetimepicker/blob/9b4051bc56caa9ef893a2bd66669c0a50c41ea2d/spec/filters_and_edit_form_spec.rb#L57-L61

workgena commented 5 years ago

And try 0.7.2 diff

Fivell commented 5 years ago

@workgena it is q_time_start_lteq

Fivell commented 5 years ago

time_start timestamp without time zone NOT NULL,

workgena commented 5 years ago

Does the error exist on 0.7.2 ?

senid231 commented 5 years ago

@workgena 0.7.2 works fine

thanks