Module: AjaxDatatablesRails::Datatable::Column::DateFilter
- Included in:
- AjaxDatatablesRails::Datatable::Column
- Defined in:
- lib/ajax-datatables-rails/datatable/column/date_filter.rb
Defined Under Namespace
Classes: DateRange
Constant Summary collapse
- RANGE_DELIMITER =
'-'
Instance Method Summary collapse
-
#date_range_search ⇒ Object
Do a range search.
-
#delimiter ⇒ Object
Add delimiter option to handle range search.
- #empty_range_search? ⇒ Boolean
-
#range_end ⇒ Object
A range value is in form ‘<range_start><delimiter><range_end>’ This returns <range_end>.
-
#range_start ⇒ Object
A range value is in form ‘<range_start><delimiter><range_end>’ This returns <range_start>.
Instance Method Details
#date_range_search ⇒ Object
Do a range search
45 46 47 48 49 |
# File 'lib/ajax-datatables-rails/datatable/column/date_filter.rb', line 45 def date_range_search return nil if empty_range_search? table[field].between(DateRange.new(range_start_casted, range_end_casted)) end |
#delimiter ⇒ Object
Add delimiter option to handle range search
24 25 26 |
# File 'lib/ajax-datatables-rails/datatable/column/date_filter.rb', line 24 def delimiter @delimiter ||= @view_column.fetch(:delimiter, RANGE_DELIMITER) end |
#empty_range_search? ⇒ Boolean
40 41 42 |
# File 'lib/ajax-datatables-rails/datatable/column/date_filter.rb', line 40 def empty_range_search? (formatted_value == delimiter) || (range_start.blank? && range_end.blank?) end |
#range_end ⇒ Object
A range value is in form ‘<range_start><delimiter><range_end>’ This returns <range_end>
36 37 38 |
# File 'lib/ajax-datatables-rails/datatable/column/date_filter.rb', line 36 def range_end @range_end ||= formatted_value.split(delimiter)[1] end |
#range_start ⇒ Object
A range value is in form ‘<range_start><delimiter><range_end>’ This returns <range_start>
30 31 32 |
# File 'lib/ajax-datatables-rails/datatable/column/date_filter.rb', line 30 def range_start @range_start ||= formatted_value.split(delimiter)[0] end |