effective_datatables 2.2.10 → 2.2.11
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 925dbdcde129594000b35c33bdcca9d40a2270a2
|
4
|
+
data.tar.gz: 45aaec09d5196309e7975c51de52ad97f2d52690
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cd98bc405d0be8aa0da7c8fccbc0657334bdb619ffef1f4f114051ec1ab2ab8d5ace4806da40ce2178855118e351fba9b03d357599e4a04cd080f82b24ee049
|
7
|
+
data.tar.gz: d743c635c18acb6b64a051e944fcc787e57f753f6b3a0767da299711262542dcca7e5d146f02885e9e1bc91d28c0c2950d5bb0e34c7bde8639d36dd29ceeec07
|
@@ -72,19 +72,33 @@ module Effective
|
|
72
72
|
collection
|
73
73
|
end
|
74
74
|
when :has_many
|
75
|
-
inverse_ids = term.split(',').map { |term| (term = term.to_i) == 0 ? nil : term }.compact
|
76
|
-
return collection unless inverse_ids.present?
|
77
|
-
|
78
75
|
reflection = collection.klass.reflect_on_association(table_column[:name].to_sym)
|
79
76
|
raise "unable to find #{collection.klass.name} :has_many :#{table_column[:name]} association" unless reflection
|
80
77
|
|
81
|
-
obj = reflection.build_association({})
|
78
|
+
obj = reflection.build_association({})
|
82
79
|
klass = obj.class
|
83
80
|
|
84
81
|
inverse = reflection.inverse_of || klass.reflect_on_association(collection.table_name) || obj.class.reflect_on_association(collection.table_name.singularize)
|
85
82
|
raise "unable to find #{klass.name} has_many :#{collection.table_name} or belongs_to :#{collection.table_name.singularize} associations" unless inverse
|
86
83
|
|
87
|
-
ids =
|
84
|
+
ids = if [:select, :grouped_select].include?(table_column[:filter][:type])
|
85
|
+
# Treat the search term as one or more IDs
|
86
|
+
inverse_ids = term.split(',').map { |term| (term = term.to_i) == 0 ? nil : term }.compact
|
87
|
+
return collection unless inverse_ids.present?
|
88
|
+
|
89
|
+
klass.where(id: inverse_ids).joins(inverse.name).pluck(inverse.foreign_key)
|
90
|
+
else
|
91
|
+
# Treat the search term as a string.
|
92
|
+
klass_columns = if (table_column[:column] == klass.table_name) # No custom column has been defined
|
93
|
+
klass.columns.map { |col| col.name if col.text? }.compact # Search all database text? columns
|
94
|
+
else
|
95
|
+
[table_column[:column].gsub("#{klass.table_name}.", '')] # table_column :order_items, column: 'order_items.title'
|
96
|
+
end
|
97
|
+
|
98
|
+
conditions = klass_columns.map { |col_name| "#{klass.table_name}.#{col_name} #{ilike} :term" }
|
99
|
+
|
100
|
+
klass.where(conditions.join(' OR '), term: "%#{term}%", num: term.to_i).joins(inverse.name).pluck(inverse.foreign_key)
|
101
|
+
end
|
88
102
|
|
89
103
|
collection.public_send(sql_op, id: ids)
|
90
104
|
when :obfuscated_id
|
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: 2.2.
|
4
|
+
version: 2.2.11
|
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: 2016-01-
|
11
|
+
date: 2016-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|