incline 0.3.5 → 0.3.6
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 +25 -11
- data/lib/incline/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c22bc5c7a677ebd8b11734e83967760151242c3a
|
4
|
+
data.tar.gz: dfa99ed217bc6931202db255241e20c0246e0c85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8452a81918b8646b7a15c56655f2f40462e58821544be1d8a8e5c9a24c8e0e4a3840e4c5c1e53d47d9bb640fbd9bbb2e3c259b55ee2b57579e9cfa515d48819
|
7
|
+
data.tar.gz: c6bc08bb42fe75c4817c851cdf86f993568cfbba90f0e6ec83c239f5aedfdb8394d6e298bf66c7f12c6ff54d914f0d2b2c03341ca2405d493b55a1c8c09ea915
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
incline (0.3.
|
4
|
+
incline (0.3.6)
|
5
5
|
ansi (~> 1.5.0)
|
6
6
|
bcrypt
|
7
7
|
bootstrap-sass
|
@@ -83,7 +83,7 @@ GEM
|
|
83
83
|
execjs (2.7.0)
|
84
84
|
faker (1.7.3)
|
85
85
|
i18n (~> 0.5)
|
86
|
-
ffi (1.9.
|
86
|
+
ffi (1.9.23)
|
87
87
|
globalid (0.4.1)
|
88
88
|
activesupport (>= 4.2.0)
|
89
89
|
i18n (0.9.3)
|
@@ -209,10 +209,10 @@ module Incline
|
|
209
209
|
|
210
210
|
dataset = load_records(relation, false)
|
211
211
|
return -1 if dataset.blank?
|
212
|
-
|
212
|
+
|
213
213
|
first_item = dataset.first
|
214
214
|
klass = first_item.class
|
215
|
-
|
215
|
+
|
216
216
|
id_field = klass.respond_to?('primary_key') ? klass.primary_key : nil
|
217
217
|
id_field ||= first_item.respond_to?('id') ? 'id' : nil
|
218
218
|
|
@@ -223,7 +223,7 @@ module Incline
|
|
223
223
|
loc_id = locate_id.to_s.downcase
|
224
224
|
dataset.index{|item| item.send(id_field).to_s.downcase == loc_id} || -1
|
225
225
|
end
|
226
|
-
|
226
|
+
|
227
227
|
end
|
228
228
|
|
229
229
|
##
|
@@ -246,14 +246,14 @@ module Incline
|
|
246
246
|
# store the unfiltered count.
|
247
247
|
@config[:records_total] = relation.count
|
248
248
|
|
249
|
-
# If we have search parameters and any of the search parameters is a regular expression or
|
249
|
+
# If we have search parameters and any of the search parameters is a regular expression or
|
250
250
|
# one or more columns being searched is not a database column, then filtering must be done
|
251
251
|
# locally.
|
252
252
|
filter_local =
|
253
253
|
!(search.blank? && columns.reject{|c| c[:search].blank? }.blank?) &&
|
254
254
|
(
|
255
255
|
# main search is a regex.
|
256
|
-
|
256
|
+
search.is_a?(::Regexp) ||
|
257
257
|
# one or more column searches is a regex.
|
258
258
|
columns.select{|c| c[:search].is_a?(::Regexp)}.any? ||
|
259
259
|
# one or more searchable columns is not in the database model
|
@@ -308,10 +308,10 @@ module Incline
|
|
308
308
|
srch = col[:search]
|
309
309
|
relation =
|
310
310
|
if srch.is_a?(::Regexp)
|
311
|
-
relation.select { |item| item
|
311
|
+
relation.select { |item| get_value(item, name) =~ srch }
|
312
312
|
else
|
313
313
|
srch = srch.to_s.upcase
|
314
|
-
relation.select { |item| item
|
314
|
+
relation.select { |item| get_value(item, name).to_s.upcase.include?(srch) }
|
315
315
|
end
|
316
316
|
end
|
317
317
|
|
@@ -320,10 +320,10 @@ module Incline
|
|
320
320
|
cols = columns.select{|c| c[:searchable]}.map{|c| c[:name].to_s }.reject{|c| c.blank?}
|
321
321
|
relation =
|
322
322
|
if search.is_a?(::Regexp)
|
323
|
-
relation.select{|item| cols.find{|col|
|
323
|
+
relation.select{|item| cols.find{|col| get_value(item,col) =~ search} }
|
324
324
|
else
|
325
325
|
srch = search.to_s.upcase
|
326
|
-
relation.select{|item| cols.find{|col|
|
326
|
+
relation.select{|item| cols.find{|col| get_value(item,col).to_s.upcase.include?(srch) }}
|
327
327
|
end
|
328
328
|
end
|
329
329
|
|
@@ -360,13 +360,27 @@ module Incline
|
|
360
360
|
|
361
361
|
private
|
362
362
|
|
363
|
+
def get_value(item, name)
|
364
|
+
val = item
|
365
|
+
while item && name.to_s.strip != ''
|
366
|
+
top,_,name = name.to_s.partition('.')
|
367
|
+
begin
|
368
|
+
val = val.respond_to?(top) ? val.send(top) : nil
|
369
|
+
rescue =>e
|
370
|
+
::Incline::Log::warn e
|
371
|
+
val = nil
|
372
|
+
end
|
373
|
+
end
|
374
|
+
val
|
375
|
+
end
|
376
|
+
|
363
377
|
def local_sort(a, b, attribs, index = 0)
|
364
378
|
if index >= attribs.count
|
365
379
|
0
|
366
380
|
else
|
367
381
|
attr, dir = attribs[index]
|
368
|
-
val_a = a
|
369
|
-
val_b = b
|
382
|
+
val_a = get_value(a, attr)
|
383
|
+
val_b = get_value(b, attr)
|
370
384
|
if val_a == val_b
|
371
385
|
local_sort a, b, attribs, index + 1
|
372
386
|
else
|
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.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Beau Barker
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -610,7 +610,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
610
610
|
version: '0'
|
611
611
|
requirements: []
|
612
612
|
rubyforge_project:
|
613
|
-
rubygems_version: 2.6.
|
613
|
+
rubygems_version: 2.6.13
|
614
614
|
signing_key:
|
615
615
|
specification_version: 4
|
616
616
|
summary: A gem designed to get off to an even quicker start with Rails.
|