effective_datatables 4.7.9 → 4.7.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04dc4193bfa7df74ea293e09a5d58c2960353eef458b7b35592a8d28c5414f32
4
- data.tar.gz: fa69c2c429d134996db63c99ef21f726aeedd51c73b2d827ce0c90072b4817d2
3
+ metadata.gz: d7466c3941269d0062b5b2f920ae7371343f341bc8f09c8672d3a57217a80d57
4
+ data.tar.gz: 3338eb6cdc80824533d228d14aa9414ff19b3947b849ba466b348a5448ba6c18
5
5
  SHA512:
6
- metadata.gz: 387e3b27d26e4f6587543cde926a487450b4a339ec72c34f04d2e9fe310bf0443ff8c7d4471ac83e403bc1fb9e89e39ca787fa49ca914ae0d960d07b0e82a69d
7
- data.tar.gz: b9ef2b83820e368394d3a31e572cd4dd6faec3b883a2d9c5b37b469db31baee35eef705e950c9d82e46f403565c327bc4ffa5e602394013c3fd74c692660cdb0
6
+ metadata.gz: 5e4ef7ef9d01e2f192dfe051c09fbbe1f9fdc4fd2979ca3cfd2b86ab8bc6a5fb31708e8e1531c882db9fc3b08cdd60580440e25613f0bf6ebc41d98f29cfac29
7
+ data.tar.gz: e6a9170763f485ad3cddc04d5502b7fca657c28aa9cd04c509c91975e68b9139489f8b2e1bc0ac10ed707b621286330aab06f82c1fce1221d121b7b4241ae152
@@ -74,12 +74,12 @@ module Effective
74
74
  collection
75
75
  end
76
76
 
77
- def search_column(collection, value, column, index)
78
- Rails.logger.info "VALUE TOOL: search_column #{column.to_s} #{value} #{index}" if EffectiveDatatables.debug
77
+ def search_column(collection, original, column, index)
78
+ Rails.logger.info "VALUE TOOL: search_column #{column.to_s} #{original} #{index}" if EffectiveDatatables.debug
79
79
 
80
80
  fuzzy = column[:search][:fuzzy]
81
81
 
82
- term = Effective::Attribute.new(column[:as]).parse(value, name: column[:name])
82
+ term = Effective::Attribute.new(column[:as]).parse(original, name: column[:name])
83
83
  term_downcased = term.to_s.downcase
84
84
 
85
85
  # term == 'nil' rescue false is a Rails 4.1 fix, where you can't compare a TimeWithZone to 'nil'
@@ -89,7 +89,8 @@ module Effective
89
89
 
90
90
  # See effective_resources gem search() method # relation.rb
91
91
  collection.select! do |row|
92
- obj = obj_to_value(row[index], column, row)
92
+ obj = row[index]
93
+ value = obj_to_value(row[index], column, row)
93
94
 
94
95
  case column[:as]
95
96
  when :boolean
@@ -100,7 +101,7 @@ module Effective
100
101
  end
101
102
  when :datetime, :date
102
103
  end_at = (
103
- case (value.to_s.scan(/(\d+)/).flatten).length
104
+ case (original.to_s.scan(/(\d+)/).flatten).length
104
105
  when 1 ; term.end_of_year # Year
105
106
  when 2 ; term.end_of_month # Year-Month
106
107
  when 3 ; term.end_of_day # Year-Month-Day
@@ -110,35 +111,35 @@ module Effective
110
111
  else term
111
112
  end
112
113
  )
113
- obj >= term && obj <= end_at
114
+ value >= term && value <= end_at
114
115
  when :time
115
- (obj.hour == term.hour) && (term.min == 0 ? true : (obj.min == term.min))
116
+ (value.hour == term.hour) && (term.min == 0 ? true : (value.min == term.min))
116
117
  when :decimal, :currency
117
- if fuzzy && (term.round(0) == term) && value.to_s.include?('.') == false
118
+ if fuzzy && (term.round(0) == term) && original.to_s.include?('.') == false
118
119
  if term < 0
119
- obj <= term && obj > (term - 1.0)
120
+ value <= term && value > (term - 1.0)
120
121
  else
121
- obj >= term && obj < (term + 1.0)
122
+ value >= term && value < (term + 1.0)
122
123
  end
123
124
  else
124
- obj == term
125
+ value == term
125
126
  end
126
127
  when :duration
127
- if fuzzy && (term % 60 == 0) && value.to_s.include?('m') == false
128
+ if fuzzy && (term % 60 == 0) && original.to_s.include?('m') == false
128
129
  if term < 0
129
- obj <= term && obj > (term - 60)
130
+ value <= term && value > (term - 60)
130
131
  else
131
- obj >= term && obj < (term + 60)
132
+ value >= term && value < (term + 60)
132
133
  end
133
134
  else
134
- obj == term
135
+ value == term
135
136
  end
136
137
  when *datatable.association_macros, :resource
137
138
  Array(obj).any? do |resource|
138
139
  Array(term).any? do |term|
139
140
  matched = false
140
141
 
141
- if term.kind_of?(Integer) && resource.respond_to?(:to_param)
142
+ if term.kind_of?(Integer) && resource.respond_to?(:id) && resource.respond_to?(:to_param)
142
143
  matched = (resource.id == term || resource.to_param == term)
143
144
  end
144
145
 
@@ -147,9 +148,9 @@ module Effective
147
148
  end
148
149
  else # :string, :text, :email
149
150
  if fuzzy
150
- obj.to_s.downcase.include?(term_downcased)
151
+ value.to_s.downcase.include?(term_downcased)
151
152
  else
152
- obj == term || (obj.to_s == term.to_s)
153
+ value == term || (value.to_s == term.to_s)
153
154
  end
154
155
  end
155
156
  end || collection
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '4.7.9'.freeze
2
+ VERSION = '4.7.10'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_datatables
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.7.9
4
+ version: 4.7.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-08 00:00:00.000000000 Z
11
+ date: 2019-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails