wice_grid_mongoid 6.2.1 → 6.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/filter_conditions_generators.rb +38 -37
- data/lib/mongoid_field.rb +22 -7
- data/wice_grid_mongoid.gemspec +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
6.2.
|
1
|
+
6.2.2
|
@@ -15,43 +15,44 @@ module Wice
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
|
27
|
-
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
|
36
|
-
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
|
54
|
-
|
18
|
+
class FilterConditionsGeneratorCustomFilter < FilterConditionsGenerator #:nodoc:
|
19
|
+
|
20
|
+
def generate_conditions(opts) #:nodoc:
|
21
|
+
return false # should be implemented
|
22
|
+
# if opts.empty?
|
23
|
+
# Wice.log "empty parameters for the grid custom filter"
|
24
|
+
# return false
|
25
|
+
# end
|
26
|
+
# opts = (opts.kind_of?(Array) && opts.size == 1) ? opts[0] : opts
|
27
|
+
|
28
|
+
# if opts.kind_of?(Array)
|
29
|
+
# opts_with_special_values, normal_opts = opts.partition{|v| ::Wice::GridTools.special_value(v)}
|
30
|
+
|
31
|
+
# conditions_ar = if normal_opts.size > 0
|
32
|
+
# [" #{@field.alias_or_table_name(table_alias)}.#{@field.name} IN ( " + (['?'] * normal_opts.size).join(', ') + ' )'] + normal_opts
|
33
|
+
# else
|
34
|
+
# []
|
35
|
+
# end
|
36
|
+
|
37
|
+
# if opts_with_special_values.size > 0
|
38
|
+
# special_conditions = opts_with_special_values.collect{|v| " #{@field.alias_or_table_name(table_alias)}.#{@field.name} is " + v}.join(' or ')
|
39
|
+
# if conditions_ar.size > 0
|
40
|
+
# conditions_ar[0] = " (#{conditions_ar[0]} or #{special_conditions} ) "
|
41
|
+
# else
|
42
|
+
# conditions_ar = " ( #{special_conditions} ) "
|
43
|
+
# end
|
44
|
+
# end
|
45
|
+
# conditions_ar
|
46
|
+
# else
|
47
|
+
# if ::Wice::GridTools.special_value(opts)
|
48
|
+
# " #{@field.alias_or_table_name(table_alias)}.#{@field.name} is " + opts
|
49
|
+
# else
|
50
|
+
# [" #{@field.alias_or_table_name(table_alias)}.#{@field.name} = ?", opts]
|
51
|
+
# end
|
52
|
+
# end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
55
56
|
|
56
57
|
class FilterConditionsGeneratorBoolean < FilterConditionsGenerator #:nodoc:
|
57
58
|
@@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)
|
14
|
-
|
15
|
-
|
16
|
-
if request_params[sym]
|
17
|
-
request_params[sym]
|
18
|
-
|
19
|
-
request_params[sym]
|
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
|
|
data/wice_grid_mongoid.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{wice_grid_mongoid}
|
8
|
-
s.version = "6.2.
|
8
|
+
s.version = "6.2.2"
|
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"]
|
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:
|
4
|
+
hash: 35
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 6
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 6.2.
|
9
|
+
- 2
|
10
|
+
version: 6.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Yuri Leikind
|