wice_grid_mongoid 6.0.9 → 6.0.10

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 6.0.9
1
+ 6.0.10
@@ -14,9 +14,10 @@ module Wice
14
14
  end
15
15
  end
16
16
 
17
- # class FilterConditionsGeneratorCustomFilter < FilterConditionsGenerator #:nodoc:
17
+ class FilterConditionsGeneratorCustomFilter < FilterConditionsGenerator #:nodoc:
18
18
 
19
- # def generate_conditions(opts) #:nodoc:
19
+ def generate_conditions(opts) #:nodoc:
20
+ return false # should be implemented
20
21
  # if opts.empty?
21
22
  # Wice.log "empty parameters for the grid custom filter"
22
23
  # return false
@@ -48,9 +49,8 @@ module Wice
48
49
  # [" #{@field.alias_or_table_name(table_alias)}.#{@field.name} = ?", opts]
49
50
  # end
50
51
  # end
51
- # end
52
-
53
- # end
52
+ end
53
+ end
54
54
 
55
55
  class FilterConditionsGeneratorBoolean < FilterConditionsGenerator #:nodoc:
56
56
  @@handled_type[Boolean] = self
data/lib/mongoid_field.rb CHANGED
@@ -10,15 +10,30 @@ module Wice
10
10
  # Preprocess incoming parameters for datetime, if what's coming in is
11
11
  # a datetime (with custom_filter it can be anything else, and not
12
12
  # the datetime hash {"fr" => ..., "to" => ...})
13
- if (self.type == Time) && request_params.is_a?(Hash)
14
- ["fr", "to"].each do |sym|
15
- if request_params[sym]
16
- if request_params[sym].is_a?(String)
17
- request_params[sym] = Time.parse(Wice::Defaults::DATETIME_PARSER.call(request_params[sym]).to_s)
18
- elsif request_params[sym].is_a?(Hash)
19
- request_params[sym] = Time.parse(::Wice::GridTools.params_2_datetime(request_params[sym]).to_s)
13
+ if (self.type == Time)
14
+ if request_params.is_a?(Hash)
15
+ ["fr", "to"].each do |sym|
16
+ if request_params[sym]
17
+ if request_params[sym].is_a?(String)
18
+ request_params[sym] = Time.parse(Wice::Defaults::DATETIME_PARSER.call(request_params[sym]).to_s)
19
+ elsif request_params[sym].is_a?(Hash)
20
+ request_params[sym] = Time.parse(::Wice::GridTools.params_2_datetime(request_params[sym]).to_s)
21
+ end
20
22
  end
21
23
  end
24
+ elsif request_params.is_a?(Array) && request_params.size == 1
25
+ ago = request_params.first
26
+ today = Time.now.beginning_of_day
27
+ agos = {'1 day' => today - 24.hours,
28
+ '1 week' => today - 7.days,
29
+ '1 month' => today - 1.month,
30
+ 'ever' => Time.parse("2000-01-01")}
31
+ if agos.keys.include?(ago)
32
+ request_params = {}
33
+ #regular filtering viea 'fr', 'to' field
34
+ request_params[:fr] = agos[ago]
35
+ custom_filter_active = nil
36
+ end
22
37
  end
23
38
  end
24
39
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wice_grid_mongoid}
8
- s.version = "6.0.9"
8
+ s.version = "6.0.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Yuri Leikind", "Aleksandr Furmanov"]
12
- s.date = %q{2011-01-27}
12
+ s.date = %q{2011-01-28}
13
13
  s.description = %q{A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters }
14
14
  s.email = %q{aleksandr.furmanov@gmail.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wice_grid_mongoid
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
4
+ hash: 59
5
5
  prerelease: false
6
6
  segments:
7
7
  - 6
8
8
  - 0
9
- - 9
10
- version: 6.0.9
9
+ - 10
10
+ version: 6.0.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Yuri Leikind
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-01-27 00:00:00 -08:00
19
+ date: 2011-01-28 00:00:00 -08:00
20
20
  default_executable:
21
21
  dependencies: []
22
22