Module: ActiveScaffold::Bridges::DatePicker::DatePickerBridge

Included in:
Config::Core
Defined in:
lib/active_scaffold/bridges/date_picker/ext.rb

Instance Method Summary collapse

Instance Method Details

#initialize(model_id) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/active_scaffold/bridges/date_picker/ext.rb', line 3

def initialize(model_id)
  super
  return unless ActiveScaffold::Bridges::DatePicker.default_ui

  types = %i[date datetime timestamp timestamptz]
  date_picker_fields = _columns.filter_map { |c| {name: c.name.to_sym, type: c.type} if types.include?(c.type) }
  # check to see if file column was used on the model
  return if date_picker_fields.empty?

  # automatically set the forum_ui to a date_picker or datetime_picker
  date_picker_fields.each do |field|
    col_config = columns[field[:name]]
    col_config.form_ui = (field[:type] == :date ? :date_picker : :datetime_picker)
  end
end