effective_datatables 4.7.4 → 4.7.5

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
  SHA256:
3
- metadata.gz: a60c15f1f3a43328d70962644780fb14cae4d00ad3477ae66d343927458ab659
4
- data.tar.gz: bcbce544e403042f50884b150c60eff9f259e10aaf303bc6c8397f066fadbfb1
3
+ metadata.gz: 48cac2f10a4ebc72966c0dfffbb2cfa813743d2bcc37ca2571e86252241d66ec
4
+ data.tar.gz: d7baf2ef61b1008ee0265c65bb3acb878c8da0d4031ea12cb4a27b000f54ef08
5
5
  SHA512:
6
- metadata.gz: cd33fcd4b81119097378e889a07db9e487bca7dcf602591b8754dc10b42607e957854e8890c51461899b88d50a02f009fb158315d2aa0cbeeff5a5f5cbfe5484
7
- data.tar.gz: e1e7394cf58aa0c2f9c09aaa8f5dd6f5031736cc7e921ea061af394686e93f8646298e516c522760d99856e18663723519aa6948b03422f114c282042ebc46fb
6
+ metadata.gz: 77eeca0bd8b7908e0fa6a893cb4cd96ab84c16bd235f520829c862104540861381af977ea017fd926608ea06620f43e935fd7af53a565321a7e00f52b66db54b
7
+ data.tar.gz: 42d1909524c35fc87fdd8495c5c28b84f93f8259b008a66d0a1037d1fc13f30e2efe86776f5fb5a35b2985b2bc32febdf14347e84abf9deed186810c19c16ea5
@@ -15,6 +15,8 @@ module Effective
15
15
 
16
16
  # The collection itself. Only evaluated once.
17
17
  attr_accessor :_collection
18
+ attr_accessor :_collection_apply_belongs_to
19
+ attr_accessor :_collection_apply_scope
18
20
 
19
21
  # The view
20
22
  attr_reader :view
@@ -14,7 +14,7 @@ module Effective
14
14
  @total_records = (active_record_collection? ? column_tool.size(col) : value_tool.size(col))
15
15
 
16
16
  # Apply scope
17
- col = column_tool.scope(col)
17
+ col = column_tool.scope(col) if @_collection_apply_scope
18
18
 
19
19
  # Apply column searching
20
20
  col = column_tool.search(col)
@@ -10,8 +10,13 @@ module Effective
10
10
  define_method('initialize_charts') { dsl_tool.instance_exec(&block) }
11
11
  end
12
12
 
13
- def collection(&block)
14
- define_method('initialize_collection') { self._collection = dsl_tool.instance_exec(&block) }
13
+ def collection(apply_belongs_to: true, apply_scope: true, &block)
14
+ define_method('initialize_collection') {
15
+ self._collection_apply_belongs_to = apply_belongs_to
16
+ self._collection_apply_scope = apply_scope
17
+
18
+ self._collection = dsl_tool.instance_exec(&block)
19
+ }
15
20
  end
16
21
 
17
22
  def datatable(&block)
@@ -180,12 +180,20 @@ module Effective
180
180
  next unless columns[associated]
181
181
 
182
182
  if columns[associated][:as] == :belongs_to
183
- @_collection = @_collection.where(attribute => value)
183
+ if @_collection_apply_belongs_to && !@_collection.where_values_hash.include?(attribute)
184
+ @_collection = @_collection.where(attribute => value)
185
+ end
186
+
184
187
  columns.delete(associated)
185
188
  elsif columns[associated][:as] == :belongs_to_polymorphic
186
189
  associated_type = attributes["#{associated}_type".to_sym] || raise("Expected #{associated}_type attribute to be present when #{associated}_id is present on a polymorphic belongs to")
187
190
 
188
- @_collection = @_collection.where(attribute => value).where("#{associated}_type" => associated_type)
191
+ if @_collection_apply_belongs_to
192
+ if !@_collection.where_values_hash.include?(attribute) && !@_collection.where_values_hash.include?("#{associated}_type")
193
+ @_collection = @_collection.where(attribute => value).where("#{associated}_type" => associated_type)
194
+ end
195
+ end
196
+
189
197
  columns.delete(associated)
190
198
  end
191
199
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '4.7.4'.freeze
2
+ VERSION = '4.7.5'.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.4
4
+ version: 4.7.5
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-06-14 00:00:00.000000000 Z
11
+ date: 2019-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails