effective_datatables 2.4.0 → 2.4.1

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: 5356cff7e6d831538a222820ad35adde6b9c28a8
4
- data.tar.gz: 273bea0ced295a05ef825e2cfa009670c1a0f682
3
+ metadata.gz: 2f0b5d8833f49fa08b11c76ee4f49622ff13c72d
4
+ data.tar.gz: 3b64fb8a94657715b230c1b47976c0c180afaeb4
5
5
  SHA512:
6
- metadata.gz: 8c0af0da24feda9e04408d4150fd874818d7bf08ecb29f445797e4a06362cb4d9ec454f65163d77a551bfc5af2efb96e23ed0eebb99125a5224fc6883aaafd5d
7
- data.tar.gz: 3f6e5cd755c9d9c773ed9c32e9096fc2c5b496a7dfc5ff0c8aec14519e5b2719db57f09c332617566bc2b2f3f8a8968f6854326e073d75d5635a9e8fbea8e36a
6
+ metadata.gz: 91119ca0ee5f73dfa6bcefd728cf18c9a4e4f0f5ba7522f1b242c4d44f11290d1a25139d7300f59f82e3710a1f8a34284e3a7eeca47800a493d4e91be02a0dc1
7
+ data.tar.gz: 5caf11ca75774bb2133c8a67343a0b0aadb6f55e4b72b63136ecc459916d173bfe1105b5ae7e17a8b483d83582fd92a91bf8408da50cbc058fb8e2770119e2fa
@@ -68,10 +68,10 @@ module Effective
68
68
  collection.public_send(sql_op, "#{sql_column} = :term", term: term)
69
69
  elsif ['null', 'nil', nil].include?(term)
70
70
  collection.public_send(sql_op, "#{sql_column} = :term OR #{sql_column} IS NULL", term: '')
71
- elsif table_column[:filter][:fuzzy] != true
72
- collection.public_send(sql_op, "#{sql_column} = :term", term: term)
73
- else
71
+ elsif table_column[:filter][:fuzzy]
74
72
  collection.public_send(sql_op, "#{sql_column} #{ilike} :term", term: "%#{term}%")
73
+ else
74
+ collection.public_send(sql_op, "#{sql_column} = :term", term: term)
75
75
  end
76
76
  when :belongs_to_polymorphic
77
77
  # our key will be something like Post_15, or Event_1
@@ -66,15 +66,13 @@ module Effective
66
66
  end
67
67
 
68
68
  def search_column_with_defaults(collection, table_column, search_term, index)
69
- search_term = search_term.downcase
69
+ search_term = search_term.downcase if table_column[:filter][:fuzzy]
70
70
 
71
71
  collection.select! do |row|
72
- value = row[index].to_s.downcase
73
-
74
- if table_column[:filter][:fuzzy] != true
75
- value == search_term
72
+ if table_column[:filter][:fuzzy]
73
+ row[index].to_s.downcase.include?(search_term)
76
74
  else
77
- value.include?(search_term)
75
+ row[index] == search_term
78
76
  end
79
77
  end || collection
80
78
  end
@@ -164,6 +164,11 @@ module Effective
164
164
  filter[:as] ||= :select
165
165
  end
166
166
 
167
+ # Fuzzy by default throughout
168
+ unless filter.key?(:fuzzy)
169
+ filter[:fuzzy] = true
170
+ end
171
+
167
172
  # Check if this is an aggregate column
168
173
  if ['SUM(', 'COUNT(', 'MAX(', 'MIN(', 'AVG('].any? { |str| sql_column.include?(str) }
169
174
  filter[:sql_operation] = :having
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '2.4.0'.freeze
2
+ VERSION = '2.4.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_datatables
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect