Module: ActiveScaffold::Bridges::DatePicker::Helper::SearchColumnHelpers

Defined in:
lib/active_scaffold/bridges/date_picker/helper.rb

Instance Method Summary collapse

Instance Method Details

#active_scaffold_search_date_picker_field(column, options, current_search, name, ui_options: column.options) ⇒ Object



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/active_scaffold/bridges/date_picker/helper.rb', line 153

def active_scaffold_search_date_picker_field(column, options, current_search, name, ui_options: column.options)
  value =
    if current_search.is_a? Hash
      conversion = column.search_ui == :date_picker ? :to_date : :to_time
      controller.class.condition_value_for_datetime(column, current_search[name], conversion, ui_method: :search_ui, ui_options: ui_options)
    else
      current_search
    end
  options = ui_options.merge(options).except!(:include_blank, :discard_time, :discard_date, :value)
  options = active_scaffold_input_text_options(options)
  format = datepicker_format(options, column.search_ui)
  options[:class] << " #{column.search_ui}"
  options[:style] = 'display: none' if options[:show] == false # hide only if asked to hide
  options[:data] = datepicker_format_options(column, format).reverse_merge!(options[:data] || {})
  value = l(value, format: format) if value
  options = options.merge(id: "#{options[:id]}_#{name}", name: "#{options[:name]}[#{name}]", object: nil)
  text_field_tag("#{options[:name]}[#{name}]", value, options)
end