effective_datatables 4.7.19 → 4.7.20

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: 618838ca90e9046e4cbd0bb0e7d7a5e73f00b07e58733a81ac07a0a7976524da
4
- data.tar.gz: 8e1c0545b02af85a0c4270f4ab70c1ac1e81b1d3b7ff9438f7562a42e71e661b
3
+ metadata.gz: 64b15bd9c60e95f6097c087680780efc353785339a872b303214ba5bfe7f0b4d
4
+ data.tar.gz: c60b68831df53a2b8e4d14684313f8c62b2a7dce346209358492d0276aa39804
5
5
  SHA512:
6
- metadata.gz: 9a33841f4c1923cfea7b9b28c767df80ca6454c5fe6174a7169ba902a3df3eb60c6437381a9b8b130ef6769f3276f4d35d83744eade5201ec164b819dd7f909e
7
- data.tar.gz: 40f39a4bdc1f0cb9b078be9332c60ece434b85cd31932604592f811c92b12cffd0944bfc1cb397bdc80ef41f1f307de929337e61438e4fe3e6c9a6e5ead4fc5e
6
+ metadata.gz: b816c9a553c6c984f579728363208abbd686adc4ac649dba3c8b2315d1ae0af2a361ce272266bceed88bc732e17bc092f7f1c26359eed861fa97c4b5a806eac0
7
+ data.tar.gz: 402548a22f0e10a00915eedf2c6f3e2d8847d6010b9a23b1cfa3633c2f297d25f8aa7e99c2ec229c910478da10f72f1b225c8ae93113cd669962a6139dcab4ed
data/README.md CHANGED
@@ -879,6 +879,10 @@ Create a [Google Chart](https://developers.google.com/chart/interactive/docs/qui
879
879
 
880
880
  No javascript required. Just use the `chart do ... end` block and return an Array of Arrays.
881
881
 
882
+ The first collection, `collection` is the raw results as returned from the `collection do` block.
883
+
884
+ The second collection, `searched_collection` is the results after the table's search columns have been applied, but irregardless of pagination.
885
+
882
886
  ```ruby
883
887
  charts do
884
888
  chart :breakfast, 'BarChart' do |collection|
@@ -894,6 +898,18 @@ charts do
894
898
  [date.strftime('%F'), posts.length]
895
899
  end
896
900
  end
901
+
902
+ chart :posts_per_user, 'ColumnChart' do |collection, searched_collection|
903
+ measured_posts = if search.present?
904
+ ["Posts with #{search.map { |k, v| k.to_s + ' ' + v.to_s }.join(',')}", searched_collection.length]
905
+ else
906
+ ['All Posts', collection.length]
907
+ end
908
+
909
+ [['Posts', 'Count'], measured_posts] +
910
+ searched_collection.group_by(&:user).map { |user, posts| [user.last_name, posts.length] }
911
+ end
912
+
897
913
  end
898
914
  ```
899
915
 
@@ -131,7 +131,7 @@ initializeDataTables = (target) ->
131
131
  if typeof(google) != 'undefined' && typeof(google.visualization) != 'undefined'
132
132
  $.each charts, (name, data) =>
133
133
  $(".effective-datatables-chart[data-name='#{name}']").each (_, obj) =>
134
- chart = new google.visualization[data['type']](obj)
134
+ chart = new google.visualization[data['as']](obj)
135
135
  chart.draw(google.visualization.arrayToDataTable(data['data']), data['options'])
136
136
 
137
137
  # Appends the search html, stored in the column definitions, into each column header
@@ -36,6 +36,9 @@ module Effective
36
36
  # Apply value ordering
37
37
  col = value_tool.order(col)
38
38
 
39
+ # Charts too
40
+ @charts_data = chart(collection, col) if _charts.present?
41
+
39
42
  # Apply pagination
40
43
  col = col.kind_of?(Array) ? value_tool.paginate(col) : column_tool.paginate(col)
41
44
 
@@ -48,9 +51,6 @@ module Effective
48
51
  # Compute aggregate data
49
52
  @aggregates_data = aggregate(col) if _aggregates.present?
50
53
 
51
- # Charts too
52
- @charts_data = chart(col) if _charts.present?
53
-
54
54
  # Format all results
55
55
  format(col)
56
56
 
@@ -161,11 +161,11 @@ module Effective
161
161
  end || BLANK
162
162
  end
163
163
 
164
- def chart(collection)
164
+ def chart(collection, searched_collection)
165
165
  _charts.inject({}) do |retval, (name, chart)|
166
166
  retval[name] = {
167
167
  as: chart[:as],
168
- data: dsl_tool.instance_exec(collection, &chart[:compute]),
168
+ data: dsl_tool.instance_exec(collection, searched_collection, &chart[:compute]),
169
169
  name: chart[:name],
170
170
  options: chart[:options]
171
171
  }
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '4.7.19'.freeze
2
+ VERSION = '4.7.20'.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.19
4
+ version: 4.7.20
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: 2020-03-03 00:00:00.000000000 Z
11
+ date: 2020-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails