Module: ActiveScaffold::Bridges::Shared::DateBridge::SearchColumnHelpers
- Defined in:
- lib/active_scaffold/bridges/shared/date_bridge.rb
Instance Method Summary collapse
- #active_scaffold_date_bridge_trend_tag(column, options, trend_options) ⇒ Object
- #active_scaffold_search_date_bridge(column, options) ⇒ Object
- #active_scaffold_search_date_bridge_comparator_options(column) ⇒ Object
- #active_scaffold_search_date_bridge_comparator_tag(column, options, current_search) ⇒ Object
- #active_scaffold_search_date_bridge_numeric_tag(column, options, current_search) ⇒ Object
- #active_scaffold_search_date_bridge_range_tag(column, options, current_search) ⇒ Object
- #active_scaffold_search_date_bridge_trend_tag(column, options, current_search) ⇒ Object
- #active_scaffold_search_date_bridge_trend_units(column) ⇒ Object
- #column_datetime?(column) ⇒ Boolean
Instance Method Details
#active_scaffold_date_bridge_trend_tag(column, options, trend_options) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/active_scaffold/bridges/shared/date_bridge.rb', line 43 def active_scaffold_date_bridge_trend_tag(column, , ) trend_controls = text_field_tag("#{[:name_prefix]}[#{column.name}][number]", [:number_value], :class => 'text-input', :size => 10, :autocomplete => 'off') << " " << select_tag("#{[:name_prefix]}[#{column.name}][unit]", (active_scaffold_search_date_bridge_trend_units(column), [:unit_value]), :class => 'text-input') content_tag("span", trend_controls.html_safe, :id => "#{[:id]}_trend", :style => "display:#{[:show] ? '' : 'none'}") end |
#active_scaffold_search_date_bridge(column, options) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/active_scaffold/bridges/shared/date_bridge.rb', line 6 def active_scaffold_search_date_bridge(column, ) current_search = {'from' => nil, 'to' => nil, 'opt' => 'BETWEEN', 'number' => 1, 'unit' => 'DAYS', 'range' => nil} current_search.merge!([:value]) unless [:value].nil? = [] << active_scaffold_search_date_bridge_comparator_tag(column, , current_search) << active_scaffold_search_date_bridge_trend_tag(column, , current_search) << active_scaffold_search_date_bridge_numeric_tag(column, , current_search) << active_scaffold_search_date_bridge_range_tag(column, , current_search) .join(" ").html_safe end |
#active_scaffold_search_date_bridge_comparator_options(column) ⇒ Object
18 19 20 21 |
# File 'lib/active_scaffold/bridges/shared/date_bridge.rb', line 18 def (column) = ActiveScaffold::Finder::DateComparators.collect {|comp| [as_(comp.downcase.to_sym), comp]} + ActiveScaffold::Finder::NumericComparators.collect {|comp| [as_(comp.downcase.to_sym), comp]} end |
#active_scaffold_search_date_bridge_comparator_tag(column, options, current_search) ⇒ Object
23 24 25 |
# File 'lib/active_scaffold/bridges/shared/date_bridge.rb', line 23 def active_scaffold_search_date_bridge_comparator_tag(column, , current_search) select_tag("#{[:name]}[opt]", ((column),current_search['opt']), :id => "#{[:id]}_opt", :class => "as_search_range_option as_search_date_time_option") end |
#active_scaffold_search_date_bridge_numeric_tag(column, options, current_search) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/active_scaffold/bridges/shared/date_bridge.rb', line 27 def active_scaffold_search_date_bridge_numeric_tag(column, , current_search) numeric_controls = "" << active_scaffold_search_date_bridge_calendar_control(column, , current_search, 'from') << content_tag(:span, (" - " + active_scaffold_search_date_bridge_calendar_control(column, , current_search, 'to')).html_safe, :id => "#{[:id]}_between", :class => "as_search_range_between", :style => "display:#{current_search['opt'] == 'BETWEEN' ? '' : 'none'}") content_tag("span", numeric_controls.html_safe, :id => "#{[:id]}_numeric", :style => "display:#{ActiveScaffold::Finder::NumericComparators.include?(current_search['opt']) ? '' : 'none'}") end |
#active_scaffold_search_date_bridge_range_tag(column, options, current_search) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/active_scaffold/bridges/shared/date_bridge.rb', line 57 def active_scaffold_search_date_bridge_range_tag(column, , current_search) range_controls = select_tag("search[#{column.name}][range]", ( ActiveScaffold::Finder::DateRanges.collect{|range| [as_(range.downcase.to_sym), range]}, current_search["range"]), :class => 'text-input') content_tag("span", range_controls.html_safe, :id => "#{[:id]}_range", :style => "display:#{(current_search['opt'] == 'RANGE') ? '' : 'none'}") end |
#active_scaffold_search_date_bridge_trend_tag(column, options, current_search) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/active_scaffold/bridges/shared/date_bridge.rb', line 35 def active_scaffold_search_date_bridge_trend_tag(column, , current_search) active_scaffold_date_bridge_trend_tag(column, , {:name_prefix => 'search', :number_value => current_search['number'], :unit_value => current_search["unit"], :show => (current_search['opt'] == 'PAST' || current_search['opt'] == 'FUTURE')}) end |
#active_scaffold_search_date_bridge_trend_units(column) ⇒ Object
51 52 53 54 55 |
# File 'lib/active_scaffold/bridges/shared/date_bridge.rb', line 51 def active_scaffold_search_date_bridge_trend_units(column) = ActiveScaffold::Finder::DateUnits.collect{|unit| [as_(unit.downcase.to_sym), unit]} = ActiveScaffold::Finder::TimeUnits.collect{|unit| [as_(unit.downcase.to_sym), unit]} + if column_datetime?(column) end |
#column_datetime?(column) ⇒ Boolean
64 65 66 |
# File 'lib/active_scaffold/bridges/shared/date_bridge.rb', line 64 def column_datetime?(column) (!column.column.nil? && [:datetime, :time].include?(column.column.type)) end |