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
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/active_scaffold/bridges/shared/date_bridge.rb', line 47 def active_scaffold_date_bridge_trend_tag(column, , ) trend_controls = [ text_field_tag("#{[:name]}[number]", [:number_value], :class => 'text-input', :size => 10, :autocomplete => 'off'), select_tag("#{[:name]}[unit]", (active_scaffold_search_date_bridge_trend_units(column), [:unit_value]), :class => 'text-input') ] content_tag('span', safe_join(trend_controls, ' '), :id => "#{[:id]}_trend", :class => 'search-date-trend', :style => [:show] ? nil : 'display: 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) safe_join , ' '.html_safe # rubocop:disable Rails/OutputSafety 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::DATE_COMPARATORS.collect { |comp| [as_(comp.downcase.to_sym), comp] } + ActiveScaffold::Finder::NUMERIC_COMPARATORS.collect { |comp| [as_(comp.downcase.to_sym), comp] } end |
#active_scaffold_search_date_bridge_comparator_tag(column, options, current_search) ⇒ Object
23 24 25 26 |
# File 'lib/active_scaffold/bridges/shared/date_bridge.rb', line 23 def active_scaffold_search_date_bridge_comparator_tag(column, , current_search) choices = ((column), current_search['opt']) select_tag("#{[:name]}[opt]", choices, :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
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/active_scaffold/bridges/shared/date_bridge.rb', line 28 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, safe_join([' - ', active_scaffold_search_date_bridge_calendar_control(column, , current_search, 'to')]), :id => "#{[:id]}_between", :class => 'as_search_range_between', :style => current_search['opt'] == 'BETWEEN' ? nil : 'display: none') ] content_tag('span', safe_join(numeric_controls), :id => "#{[:id]}_numeric", :class => 'search-date-numeric', :style => ActiveScaffold::Finder::NUMERIC_COMPARATORS.include?(current_search['opt']) ? nil : 'display: none') end |
#active_scaffold_search_date_bridge_range_tag(column, options, current_search) ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/active_scaffold/bridges/shared/date_bridge.rb', line 65 def active_scaffold_search_date_bridge_range_tag(column, , current_search) values = ActiveScaffold::Finder::DATE_RANGES.collect { |range| [as_(range.downcase.to_sym), range] } range_controls = select_tag("#{[:name]}[range]", (values, current_search['range']), :class => 'text-input', :id => nil) content_tag('span', range_controls, :id => "#{[:id]}_range", :class => 'search-date-range', :style => ('display: none' unless current_search['opt'] == 'RANGE')) end |
#active_scaffold_search_date_bridge_trend_tag(column, options, current_search) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/active_scaffold/bridges/shared/date_bridge.rb', line 40 def active_scaffold_search_date_bridge_trend_tag(column, , current_search) active_scaffold_date_bridge_trend_tag(column, , :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
59 60 61 62 63 |
# File 'lib/active_scaffold/bridges/shared/date_bridge.rb', line 59 def active_scaffold_search_date_bridge_trend_units(column) = ActiveScaffold::Finder::DATE_UNITS.collect { |unit| [as_(unit.downcase.to_sym), unit] } = ActiveScaffold::Finder::TIME_UNITS.collect { |unit| [as_(unit.downcase.to_sym), unit] } + if column_datetime?(column) end |
#column_datetime?(column) ⇒ Boolean
75 76 77 |
# File 'lib/active_scaffold/bridges/shared/date_bridge.rb', line 75 def column_datetime?(column) (!column.column.nil? && %i[datetime time].include?(column.column.type)) end |