effective_datatables 4.13.4 → 4.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/effective/datatable_column_tool.rb +2 -2
- data/app/models/effective/effective_datatable/csv.rb +1 -1
- data/app/models/effective/effective_datatable/format.rb +6 -5
- data/app/models/effective/effective_datatable/resource.rb +8 -4
- data/lib/effective_datatables/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc47f42fc35402807796c781d25c4a2c04209c298524ff5097eccd4132e0831d
|
4
|
+
data.tar.gz: 5237226dfc47dd03a9132f06a44bd664ce55c24016ea037c948ba781d05f4843
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fca83c18fac2f69f8934f2835ff1e26f7c90ee71cac121ce61652a6a17dfe064e57c3f22e8e2335a0b6ca866b0e531886d396babb72dccbb3ba24166859a13b3
|
7
|
+
data.tar.gz: 3bddcb7006524041110b313c5f5ce577c757c790abafac7e9324dbda6126c2a4a3472ee0ce28e63b81112562430adf7ecd93be994ac108f8e9730ec53fc3d496
|
@@ -75,10 +75,10 @@ module Effective
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def search_column(collection, value, column, sql_column)
|
78
|
-
Rails.logger.info "COLUMN TOOL: search_column #{column.to_s}
|
78
|
+
Rails.logger.info "COLUMN TOOL: search_column #{column.to_s} value=#{value} operation=#{column[:search][:operation]} column=#{sql_column}" if EffectiveDatatables.debug
|
79
79
|
|
80
80
|
Effective::Resource.new(collection)
|
81
|
-
.search(column[:name], value, as: column[:as],
|
81
|
+
.search(column[:name], value, as: column[:as], operation: column[:search][:operation], column: sql_column)
|
82
82
|
end
|
83
83
|
|
84
84
|
def paginate(collection)
|
@@ -22,7 +22,7 @@ module Effective
|
|
22
22
|
CSV.generate do |csv|
|
23
23
|
csv << csv_header()
|
24
24
|
|
25
|
-
collection.
|
25
|
+
collection.find_in_batches do |resources|
|
26
26
|
resources = arrayize(resources, csv: true)
|
27
27
|
format(resources, csv: true)
|
28
28
|
finalize(resources)
|
@@ -68,7 +68,7 @@ module Effective
|
|
68
68
|
elsif opts[:format] && rendered.key?(name)
|
69
69
|
dsl_tool.instance_exec(value, row, rendered[name][row_index], &opts[:format])
|
70
70
|
elsif opts[:format]
|
71
|
-
dsl_tool.instance_exec(value, row, &opts[:format])
|
71
|
+
dsl_tool.instance_exec(value, row, &opts[:format]).to_s
|
72
72
|
elsif opts[:partial]
|
73
73
|
rendered[name][row_index]
|
74
74
|
else
|
@@ -88,6 +88,7 @@ module Effective
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
+
# Must return a string
|
91
92
|
def format_column(value, column, csv: false)
|
92
93
|
return if value.nil? || (column[:resource] && value.blank?)
|
93
94
|
|
@@ -114,24 +115,24 @@ module Effective
|
|
114
115
|
value.respond_to?(:strftime) ? value.strftime(EffectiveDatatables.format_date) : BLANK
|
115
116
|
when :datetime
|
116
117
|
if csv
|
117
|
-
value
|
118
|
+
value.to_s
|
118
119
|
else
|
119
120
|
value.respond_to?(:strftime) ? value.strftime(EffectiveDatatables.format_datetime) : BLANK
|
120
121
|
end
|
121
122
|
when :decimal
|
122
|
-
value
|
123
|
+
value.to_s
|
123
124
|
when :duration
|
124
125
|
view.number_to_duration(value)
|
125
126
|
when :effective_addresses
|
126
127
|
csv ? value.to_html.gsub('<br>', "\n") : value.to_html
|
127
128
|
when :effective_obfuscation
|
128
|
-
value
|
129
|
+
value.to_s
|
129
130
|
when :effective_roles
|
130
131
|
value.join(', ')
|
131
132
|
when :email
|
132
133
|
csv ? value : view.mail_to(value)
|
133
134
|
when :integer
|
134
|
-
value
|
135
|
+
value.to_s
|
135
136
|
when :percent
|
136
137
|
case value
|
137
138
|
when Integer ; view.number_to_percentage(value / 1000.0, precision: 3).gsub('.000%', '%')
|
@@ -158,7 +158,6 @@ module Effective
|
|
158
158
|
|
159
159
|
def load_resource_search!
|
160
160
|
columns.each do |name, opts|
|
161
|
-
|
162
161
|
case opts[:search]
|
163
162
|
when false
|
164
163
|
opts[:search] = { as: :null }; next
|
@@ -176,13 +175,12 @@ module Effective
|
|
176
175
|
|
177
176
|
# Parameterize collection
|
178
177
|
if search[:collection].kind_of?(ActiveRecord::Relation)
|
179
|
-
search[:collection] = search[:collection].map { |obj| [obj.to_s, obj.
|
178
|
+
search[:collection] = search[:collection].map { |obj| [obj.to_s, obj.id] }
|
180
179
|
elsif search[:collection].kind_of?(Array) && search[:collection].first.kind_of?(ActiveRecord::Base)
|
181
|
-
search[:collection] = search[:collection].map { |obj| [obj.to_s, obj.
|
180
|
+
search[:collection] = search[:collection].map { |obj| [obj.to_s, obj.id] }
|
182
181
|
end
|
183
182
|
|
184
183
|
search[:as] ||= :select if search.key?(:collection)
|
185
|
-
search[:fuzzy] ||= true unless search.key?(:fuzzy)
|
186
184
|
search[:value] ||= search.delete(:selected) if search.key?(:selected)
|
187
185
|
|
188
186
|
# Merge with defaults
|
@@ -195,6 +193,12 @@ module Effective
|
|
195
193
|
search.reverse_merge!(search_resource.search_form_field(name, opts[:as]))
|
196
194
|
end
|
197
195
|
|
196
|
+
# Assign default search operation
|
197
|
+
search[:operation] ||= search.delete(:op)
|
198
|
+
search[:operation] ||= :eq if search[:as] == :select
|
199
|
+
search[:operation] ||= :matches if search[:fuzzy]
|
200
|
+
search[:operation] ||= search_resource.sql_operation(name, as: opts[:as])
|
201
|
+
|
198
202
|
# Assign default include_null
|
199
203
|
if search[:as] == :select && !search.key?(:include_null)
|
200
204
|
search[:include_null] = true
|
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.
|
4
|
+
version: 4.14.0
|
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:
|
11
|
+
date: 2023-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|