Class: YummyGuide::Administrate::Filters::DateRange

Inherits:
Base
  • Object
show all
Defined in:
lib/yummy_guide/administrate/filters.rb

Instance Attribute Summary

Attributes inherited from Base

#name, #options

Instance Method Summary collapse

Methods inherited from Base

#initialize, #label_text, #visible?, #with_name, with_options

Constructor Details

This class inherits a constructor from YummyGuide::Administrate::Filters::Base

Instance Method Details

#row(view_context, form, _scope, current_values, locals) ⇒ Object



234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/yummy_guide/administrate/filters.rb', line 234

def row(view_context, form, _scope, current_values, locals)
  from_name = (options[:from] || :"start_#{name}").to_sym
  to_name = (options[:to] || :"end_#{name}").to_sym

  view_context.(:tr) do
    view_context.safe_join([
      label_cell(view_context, form, locals),
      view_context.(:td) do
        view_context.safe_join([
          form.date_field(from_name, value: current_values[from_name.to_s].presence || evaluate_option(options[:from_default], view_context, locals)),
          view_context.(:span, ""),
          form.date_field(to_name, value: current_values[to_name.to_s].presence || evaluate_option(options[:to_default], view_context, locals))
        ])
      end,
      clear_cell(view_context)
    ])
  end
end