module ActiveScaffold::Bridges::Shared::DateBridge::HumanConditionHelpers

Public Instance Methods

active_scaffold_human_condition_date_bridge(column, value) click to toggle source
# File lib/active_scaffold/bridges/shared/date_bridge.rb, line 70
def active_scaffold_human_condition_date_bridge(column, value)
  case value[:opt]
  when 'RANGE'
    range_type, range = value[:range].downcase.split('_')
    format = active_scaffold_human_condition_date_bridge_range_format(range_type, range)
    from, to = controller.class.date_bridge_from_to(column, value)
    "#{column.active_record_class.human_attribute_name(column.name)} = #{as_(value[:range].downcase).downcase} (#{I18n.l(from, :format => format)})"
  when 'PAST', 'FUTURE'
    from, to = controller.class.date_bridge_from_to(column, value)
    "#{column.active_record_class.human_attribute_name(column.name)} #{as_('BETWEEN'.downcase).downcase} #{I18n.l(from)} - #{I18n.l(to)}"
  else
    from, to = controller.class.date_bridge_from_to(column, value)
    "#{column.active_record_class.human_attribute_name(column.name)} #{as_(value[:opt].downcase).downcase} #{I18n.l(from)} #{value[:opt] == 'BETWEEN' ? '- ' + I18n.l(to) : ''}"
  end
end
active_scaffold_human_condition_date_bridge_range_format(range_type, range) click to toggle source
# File lib/active_scaffold/bridges/shared/date_bridge.rb, line 86
def active_scaffold_human_condition_date_bridge_range_format(range_type, range)
  case range
  when 'week'
    first_day_of_week = I18n.translate 'active_scaffold.date_picker_options.firstDay'
    if first_day_of_week == 1
      '%W %Y'
    else
      '%U %Y'
    end
  when 'month'
    '%b %Y'
  when 'year'
    '%Y'
  else
    I18n.translate 'date.formats.default'
  end
end