effective_datatables 3.2.4 → 3.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/effective_datatables/_filters.scss +0 -7
- data/app/models/effective/datatable_value_tool.rb +16 -4
- data/app/models/effective/effective_datatable/format.rb +1 -1
- data/app/models/effective/effective_datatable/resource.rb +5 -2
- data/app/views/effective/datatables/_filters.html.haml +9 -8
- data/app/views/effective/datatables/_resource_column.html.haml +1 -1
- data/lib/effective_datatables/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f740fcfa8103e4a41cd19d78627e660ed8261d7
|
4
|
+
data.tar.gz: 2a38dab4e9bfd6532d6455abdda04f50d928680b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28352978829362e667d377d03864e7cde3b9f4ce72230bd61d3c68aa97ba0f29f8ef49697171da41d84931fee1b4beea6229dd9f232e7276b49d82914f3579db
|
7
|
+
data.tar.gz: 255b54c6a2763303e7b9d423fa74cc846fe7fa771bd4292a4681e9b2bb90e70d4e1819bb937d88d0132cb92723f30791dcafab4dba6017bcb449e2e7f556aa03
|
@@ -85,12 +85,12 @@ module Effective
|
|
85
85
|
|
86
86
|
# term == 'nil' rescue false is a Rails 4.1 fix, where you can't compare a TimeWithZone to 'nil'
|
87
87
|
if (term == 'nil' rescue false)
|
88
|
-
return collection.select! { |row| obj_to_value(row[index], column) == nil } || collection
|
88
|
+
return collection.select! { |row| obj_to_value(row[index], column, row) == nil } || collection
|
89
89
|
end
|
90
90
|
|
91
91
|
# See effective_resources gem search() method # relation.rb
|
92
92
|
collection.select! do |row|
|
93
|
-
obj = obj_to_value(row[index], column)
|
93
|
+
obj = obj_to_value(row[index], column, row)
|
94
94
|
|
95
95
|
case column[:as]
|
96
96
|
when :boolean
|
@@ -165,8 +165,20 @@ module Effective
|
|
165
165
|
collection.size
|
166
166
|
end
|
167
167
|
|
168
|
-
def obj_to_value(obj, column)
|
169
|
-
|
168
|
+
def obj_to_value(obj, column, row = nil)
|
169
|
+
return obj if column[:compute]
|
170
|
+
|
171
|
+
# This matches format.rb. Probably should be refactored.
|
172
|
+
|
173
|
+
if column[:format]
|
174
|
+
datatable.dsl_tool.instance_exec(obj, row, &column[:format])
|
175
|
+
elsif column[:partial]
|
176
|
+
raise 'unsupported'
|
177
|
+
elsif obj.respond_to?(column[:name])
|
178
|
+
obj.send(column[:name])
|
179
|
+
else
|
180
|
+
obj
|
181
|
+
end
|
170
182
|
end
|
171
183
|
|
172
184
|
end
|
@@ -19,6 +19,7 @@ module Effective
|
|
19
19
|
if active_record_collection?
|
20
20
|
columns.each do |name, opts|
|
21
21
|
|
22
|
+
# col 'comments.title'
|
22
23
|
if name.kind_of?(String) && name.include?('.')
|
23
24
|
raise "invalid datatables column '#{name}'. the joined syntax only supports one dot." if name.scan(/\./).count > 1
|
24
25
|
|
@@ -28,8 +29,10 @@ module Effective
|
|
28
29
|
raise "invalid datatables column '#{name}'. unable to find '#{name.split('.').first}' association on '#{resource}'."
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
joins_values = (collection.joins_values + collection.left_outer_joins_values)
|
33
|
+
|
34
|
+
unless joins_values.include?(associated.to_sym)
|
35
|
+
raise "your datatables collection must .joins(:#{associated}) or .left_outer_joins(:#{associated}) to work with the joined syntax"
|
33
36
|
end
|
34
37
|
|
35
38
|
opts[:resource] = Effective::Resource.new(resource.associated(associated), namespace: controller_namespace)
|
@@ -1,8 +1,8 @@
|
|
1
|
-
.
|
2
|
-
.
|
3
|
-
= simple_form_for :filters, url: (datatable._form[:url] || '#'), method: datatable._form[:verb], html: { class: 'form-inline' } do |form|
|
1
|
+
.effective-datatable-filters{'aria-controls': datatable.to_param}
|
2
|
+
= simple_form_for :filters, url: (datatable._form[:url] || '#'), method: datatable._form[:verb], html: { class: 'form-inline' } do |form|
|
4
3
|
|
5
|
-
|
4
|
+
- if datatable._scopes.present?
|
5
|
+
.btn-toolbar
|
6
6
|
= form.input :scope, label: false, required: false, checked: datatable.state[:scope],
|
7
7
|
as: (defined?(EffectiveFormInputs) ? :effective_radio_buttons : :radio_buttons),
|
8
8
|
collection: datatable._scopes.map { |name, opts| [opts[:label], name] },
|
@@ -15,7 +15,8 @@
|
|
15
15
|
multiple: opts[:input_html].delete(:multiple),
|
16
16
|
input_html: (({name: ''} unless datatable._filters_form_required?) || {}).merge(opts[:input_html])
|
17
17
|
|
18
|
-
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
.btn-group
|
19
|
+
- if datatable._filters_form_required?
|
20
|
+
= form.button :submit, 'Apply', 'data-disable-with': 'Applying...'
|
21
|
+
- else
|
22
|
+
= link_to 'Apply', '#', class: 'btn btn-primary btn-effective-datatable-filters', 'data-apply-datatable-filters': 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: 3.2.
|
4
|
+
version: 3.2.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: 2017-
|
11
|
+
date: 2017-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|