Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions lib/active_admin_datetimepicker/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ def input_html_data
end

def input_html_options(input_name = nil, placeholder = nil)
options = {}
options[:class] = [self.options[:class], html_class].compact.join(' ')
options[:data] ||= input_html_data
options[:data].merge!(datepicker_options: datetime_picker_options)
options[:value] ||= input_value(input_name)
options[:maxlength] = 19
options
super().tap do |options|
options[:class] = [self.options[:class], html_class].compact.join(' ')
options[:data] ||= input_html_data
options[:data].merge!(datepicker_options: datetime_picker_options)
options[:value] ||= input_value(input_name)
options[:maxlength] = 19
options[:placeholder] = placeholder unless placeholder.nil?
end
end

def input_value(input_name = nil)
Expand Down
3 changes: 3 additions & 0 deletions spec/filters_and_edit_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

expect(page.find('input#q_birthday_gteq').value).to start_with(date_from)
expect(page.find('input#q_birthday_lteq').value).to start_with(date_to)
expect(page).to have_css('input#q_birthday_gteq[placeholder="From"]')
expect(page).to have_css('input#q_birthday_lteq[placeholder="To"]')
end
end

Expand All @@ -59,6 +61,7 @@
it 'can set birthday' do
date_birthday = Date.today.beginning_of_month.strftime("%Y-%m-%d")
expect(page.find('#author_birthday').value).to start_with(date_birthday)
expect(page).to have_css('#author_birthday[placeholder="Formtastic placeholder"]')
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/support/admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def add_author_resource(options = {}, &block)

f.inputs 'General' do
f.input :name
f.input :birthday, as: :date_time_picker
f.input :birthday, as: :date_time_picker, input_html: { placeholder: 'Formtastic placeholder' }
end

f.actions
Expand Down