effective_datatables 3.3.13 → 3.3.14

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: 9dffd38770a3af2941939b9e9270c9a0faa2b388
4
- data.tar.gz: 05984e20f1fd56aa5a694f249575471481ee3c2c
3
+ metadata.gz: ea8489f1a21f2dd9b48a0c3fdcceb3d9c3c1b705
4
+ data.tar.gz: 8c5c8d254c485bd5975aca3436bb82a5e0c51299
5
5
  SHA512:
6
- metadata.gz: c7025854c9eccd2dda33beb5386da2e1e0709e7e1e7d931f318143900eebc51de0fac7e0a73db6fb539ab7a07c0a7d8be751ae43e6c63e80d19694b78812615f
7
- data.tar.gz: 31212703a472da510fa3075b2b2ee06b9e8867cca1571fa561deabb32440d939e1017b4539020a83631c45b81659f694161cddf12e6b696b1fd3b8674a46346f
6
+ metadata.gz: 108b2f1856fee2aa9e153dd1baf76f0fa4a8a8b047ac8a9a36648fe7f657e33970d38d2afed2c3b4c0529e5938361a09b5efd020de0bcc026f68e16b3986d8f4
7
+ data.tar.gz: f54da3d46cf77a19b0626a8d51f12b33b95cb461d8642c72bea9286b40cfe4a7a5398582bbd24d7fc7eed54a55741f475f1306914266dd093df53626f7c46b8c
@@ -177,6 +177,7 @@ table.dataTable > tbody > tr.child {
177
177
  // Column specific adjustments
178
178
  table.dataTable {
179
179
  td.col-price { text-align: right; }
180
+ td.col-decimal { text-align: right; }
180
181
  td.col-right { text-align: right; }
181
182
 
182
183
  td.col-actions {
@@ -136,7 +136,7 @@ module Effective
136
136
  end
137
137
  when *macros, :resource
138
138
  Array(obj).any? do |resource|
139
- Array(terms).any? do |term|
139
+ Array(term).any? do |term|
140
140
  matched = false
141
141
 
142
142
  if term.kind_of?(Integer) && resource.respond_to?(:to_param)
@@ -112,6 +112,10 @@ module Effective
112
112
  elsif raw
113
113
  aggregate_column(values, opts, aggregate)
114
114
  else
115
+ if values.all? { |v| v.kind_of?(ActiveRecord::Base) && v.respond_to?(name) }
116
+ values = values.map { |v| (v[name] if opts[:sql_as_column]) || v.public_send(name) }
117
+ end
118
+
115
119
  format_column(aggregate_column(values, opts, aggregate), opts)
116
120
  end || BLANK
117
121
  end.compact
@@ -1,6 +1,7 @@
1
1
  module Effective
2
2
  module EffectiveDatatable
3
3
  module Resource
4
+ AGGREGATE_SQL_FUNCTIONS = ['ARRAY_AGG(', 'AVG(', 'COUNT(', 'MAX(', 'MIN(', 'STRING_AGG(', 'SUM(']
4
5
 
5
6
  def admin_namespace?
6
7
  controller_namespace == 'admin'
@@ -74,6 +75,10 @@ module Effective
74
75
  # Anything that doesn't belong to the model or the sql table, we assume is a SELECT SUM|AVG|RANK() as fancy
75
76
  opts[:sql_as_column] = true if (resource.table && resource.column(name).blank?)
76
77
  end
78
+
79
+ if opts[:sql_column].present? && AGGREGATE_SQL_FUNCTIONS.any? { |str| opts[:sql_column].to_s.start_with?(str) }
80
+ opts[:sql_as_column] = true
81
+ end
77
82
  end
78
83
  end
79
84
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '3.3.13'.freeze
2
+ VERSION = '3.3.14'.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: 3.3.13
4
+ version: 3.3.14
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: 2018-01-23 00:00:00.000000000 Z
11
+ date: 2018-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails