incline 0.2.22 → 0.2.23
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/incline/data_tables_request.rb +22 -12
- data/lib/incline/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e361fba9f1b1198c39aac4dc2a24d7f61dee689
|
4
|
+
data.tar.gz: 88d60394ae9ff47ae5517aba022e1e0890f57fcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55f9e505070563fcb301328bfe2acb09490cdce9e726287ba1aa60a91072f89cc5ce09d526020500b586eb01dc79004a445e731408b9bda4812d564d352f1d81
|
7
|
+
data.tar.gz: e9e9006297346b190372be28398058cc9f5c5d08a62f53ad471d56946dbe9de1229b8950cc4d99ad29dae854c15f197d9c9a99233be8e38fd266471c378f16bd
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
incline (0.2.
|
4
|
+
incline (0.2.23)
|
5
5
|
ansi (~> 1.5.0)
|
6
6
|
bcrypt
|
7
7
|
bootstrap-sass
|
@@ -58,7 +58,7 @@ GEM
|
|
58
58
|
tzinfo (~> 1.1)
|
59
59
|
ansi (1.5.0)
|
60
60
|
arel (6.0.4)
|
61
|
-
autoprefixer-rails (7.1.
|
61
|
+
autoprefixer-rails (7.1.6)
|
62
62
|
execjs
|
63
63
|
bcrypt (3.1.11)
|
64
64
|
bootstrap-sass (3.3.7)
|
@@ -209,13 +209,19 @@ module Incline
|
|
209
209
|
|
210
210
|
dataset = load_records(relation, false)
|
211
211
|
return -1 if dataset.blank?
|
212
|
+
|
213
|
+
first_item = dataset.first
|
214
|
+
klass = first_item.class
|
215
|
+
|
216
|
+
id_field = klass.respond_to?('primary_key') ? klass.primary_key : nil
|
217
|
+
id_field ||= first_item.respond_to?('id') ? 'id' : nil
|
212
218
|
|
213
|
-
return -1 unless
|
219
|
+
return -1 unless id_field
|
214
220
|
if locate_id.is_a?(::Numeric)
|
215
|
-
dataset.index{|item| item.
|
221
|
+
dataset.index{|item| item.send(id_field) == locate_id} || -1
|
216
222
|
else
|
217
223
|
loc_id = locate_id.to_s.downcase
|
218
|
-
dataset.index{|item| item.
|
224
|
+
dataset.index{|item| item.send(id_field).to_s.downcase == loc_id} || -1
|
219
225
|
end
|
220
226
|
|
221
227
|
end
|
@@ -240,15 +246,19 @@ module Incline
|
|
240
246
|
# store the unfiltered count.
|
241
247
|
@config[:records_total] = relation.count
|
242
248
|
|
243
|
-
# If
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
249
|
+
# If we have search parameters and any of the search parameters is a regular expression or
|
250
|
+
# one or more columns being searched is not a database column, then filtering must be done
|
251
|
+
# locally.
|
252
|
+
filter_local =
|
253
|
+
!(search.blank? && columns.reject{|c| c[:search].blank? }.blank?) &&
|
254
|
+
(
|
255
|
+
# main search is a regex.
|
256
|
+
search.is_a?(::Regexp) ||
|
257
|
+
# one or more column searches is a regex.
|
258
|
+
columns.select{|c| c[:search].is_a?(::Regexp)}.any? ||
|
259
|
+
# one or more searchable columns is not in the database model
|
260
|
+
columns.reject {|c| !c[:searchable] || relation.model.column_names.include?(c[:name].to_s) }.any?
|
261
|
+
)
|
252
262
|
|
253
263
|
Incline::Log::debug "Filtering will be done #{filter_local ? 'application' : 'database'}-side."
|
254
264
|
|
data/lib/incline/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: incline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Beau Barker
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|