effective_datatables 2.7.0 → 2.8.0
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 +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +6 -0
- data/app/assets/javascripts/effective_datatables/initialize.js.coffee +1 -2
- data/app/models/effective/array_datatable_tool.rb +3 -3
- data/app/models/effective/datatable.rb +10 -2
- data/app/models/effective/effective_datatable/options.rb +1 -1
- data/app/models/effective/effective_datatable/rendering.rb +25 -11
- data/lib/effective_datatables/version.rb +1 -1
- metadata +2 -3
- data/Rakefile +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 254850f988b403fcd7bab23babac6af5905a7ee4
|
4
|
+
data.tar.gz: c5722ac344bc0798bbe8ddab55582bd5b4c0fead
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47d8354626af6be0d1a8176e5609d4f9e7ee58e2a851845ff4d37260e86f4eb3ad344382ac64fd3e9a0755d8d663b178fb7f6c4355bb968229cb942853733aaa
|
7
|
+
data.tar.gz: ed8ab8398e717bea338457560fdbf2fb25f1e008069a73b34d9d20389587e1f5538c14b11028b02fa71780b5a7b3f073ec4a4c492e3f19b9199228e9cfc022cd
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -565,6 +565,12 @@ As well, you need to change the controller where you define the datatable to be
|
|
565
565
|
@datatable = Effective::Datatables::Posts.new(params[:scopes])
|
566
566
|
```
|
567
567
|
|
568
|
+
And to display the scopes anywhere in your view:
|
569
|
+
|
570
|
+
```ruby
|
571
|
+
= render_datatable_scopes(@datatable)
|
572
|
+
```
|
573
|
+
|
568
574
|
So initially, the `:start_date` will have the value of `Time.zone.now-3.months` and when submitted by the form, the value will be set there.
|
569
575
|
|
570
576
|
The form value will come back as a string, so you may need to `Time.zone.parse` that value.
|
@@ -200,8 +200,7 @@ destroyDataTables = ->
|
|
200
200
|
if $.fn.DataTable.fnIsDataTable(this)
|
201
201
|
$(this).DataTable().destroy()
|
202
202
|
|
203
|
-
$ -> initializeDataTables()
|
204
203
|
$(document).on 'page:change', -> initializeDataTables()
|
205
204
|
$(document).on 'turbolinks:load', -> initializeDataTables()
|
206
|
-
|
205
|
+
|
207
206
|
|
@@ -30,7 +30,7 @@ module Effective
|
|
30
30
|
if direction == :asc
|
31
31
|
collection.sort! do |x, y|
|
32
32
|
if (x[index] && y[index])
|
33
|
-
|
33
|
+
x[index] <=> y[index]
|
34
34
|
elsif x[index]
|
35
35
|
-1
|
36
36
|
elsif y[index]
|
@@ -42,7 +42,7 @@ module Effective
|
|
42
42
|
else
|
43
43
|
collection.sort! do |x, y|
|
44
44
|
if (x[index] && y[index])
|
45
|
-
|
45
|
+
y[index] <=> x[index]
|
46
46
|
elsif x[index]
|
47
47
|
1
|
48
48
|
elsif y[index]
|
@@ -70,7 +70,7 @@ module Effective
|
|
70
70
|
|
71
71
|
collection.select! do |row|
|
72
72
|
if table_column[:filter][:fuzzy]
|
73
|
-
|
73
|
+
row[index].to_s.downcase.include?(search_term)
|
74
74
|
else
|
75
75
|
row[index] == search_term
|
76
76
|
end
|
@@ -186,11 +186,19 @@ module Effective
|
|
186
186
|
# Check if collection has an order() clause and warn about it
|
187
187
|
# Usually that will make the table results look weird.
|
188
188
|
def active_record_collection?
|
189
|
-
@active_record_collection
|
189
|
+
if @active_record_collection == nil
|
190
|
+
@active_record_collection = (collection.ancestors.include?(ActiveRecord::Base) rescue false)
|
191
|
+
end
|
192
|
+
|
193
|
+
@active_record_collection
|
190
194
|
end
|
191
195
|
|
192
196
|
def array_collection?
|
193
|
-
|
197
|
+
if @array_collection == nil
|
198
|
+
@array_collection = (collection.kind_of?(Array) && collection.first.kind_of?(Array))
|
199
|
+
end
|
200
|
+
|
201
|
+
@array_collection
|
194
202
|
end
|
195
203
|
|
196
204
|
# Not every ActiveRecord query will work when calling the simple .count
|
@@ -134,7 +134,7 @@ module Effective
|
|
134
134
|
end
|
135
135
|
)
|
136
136
|
|
137
|
-
cols[name][:class] = "col-#{cols[name][:type]} col-#{name} #{cols[name][:class]}".strip
|
137
|
+
cols[name][:class] = "col-#{cols[name][:type]} col-#{name.parameterize} #{cols[name][:class]}".strip
|
138
138
|
|
139
139
|
# Formats
|
140
140
|
if name == 'id' || name.include?('year') || name.end_with?('_id')
|
@@ -19,28 +19,34 @@ module Effective
|
|
19
19
|
if table_tool.search_terms.present? && array_tool.search_terms.blank?
|
20
20
|
self.display_records = active_record_collection_size(col)
|
21
21
|
end
|
22
|
-
end
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
if array_tool.search_terms.present?
|
24
|
+
col = self.arrayize(col)
|
25
|
+
col = array_tool.search(col)
|
26
|
+
self.display_records = col.size
|
27
|
+
end
|
28
|
+
|
29
|
+
if array_tool.order_by_column.present?
|
30
|
+
col = self.arrayize(col)
|
31
|
+
col = array_tool.order(col)
|
32
|
+
end
|
28
33
|
end
|
29
34
|
|
30
|
-
if
|
31
|
-
col = self.arrayize(col)
|
35
|
+
if array_collection?
|
32
36
|
col = array_tool.order(col)
|
37
|
+
col = array_tool.search(col)
|
33
38
|
end
|
34
39
|
|
35
40
|
self.display_records ||= total_records
|
36
41
|
|
37
|
-
if
|
42
|
+
if array_collection?
|
38
43
|
col = array_tool.paginate(col)
|
39
44
|
else
|
40
45
|
col = table_tool.paginate(col)
|
41
|
-
col = self.arrayize(col)
|
42
46
|
end
|
43
47
|
|
48
|
+
col = self.arrayize(col)
|
49
|
+
|
44
50
|
self.format(col)
|
45
51
|
col = self.finalize(col)
|
46
52
|
end
|
@@ -85,7 +91,11 @@ module Effective
|
|
85
91
|
BLANK
|
86
92
|
elsif opts[:block]
|
87
93
|
begin
|
88
|
-
|
94
|
+
if active_record_collection?
|
95
|
+
view.instance_exec(obj, collection, self, &opts[:block])
|
96
|
+
else
|
97
|
+
view.instance_exec(obj, obj[opts[:array_index]], collection, self, &opts[:block])
|
98
|
+
end
|
89
99
|
rescue NoMethodError => e
|
90
100
|
if opts[:type] == :actions && e.message == 'super called outside of method'
|
91
101
|
rendered[name][index]
|
@@ -94,7 +104,11 @@ module Effective
|
|
94
104
|
end
|
95
105
|
end
|
96
106
|
elsif opts[:proc]
|
97
|
-
|
107
|
+
if active_record_collection?
|
108
|
+
view.instance_exec(obj, collection, self, &opts[:proc])
|
109
|
+
else
|
110
|
+
view.instance_exec(obj, obj[opts[:array_index]], collection, self, &opts[:proc])
|
111
|
+
end
|
98
112
|
elsif opts[:partial]
|
99
113
|
rendered[name][index]
|
100
114
|
elsif opts[:type] == :belongs_to
|
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: 2.
|
4
|
+
version: 2.8.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: 2017-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -105,7 +105,6 @@ extra_rdoc_files: []
|
|
105
105
|
files:
|
106
106
|
- MIT-LICENSE
|
107
107
|
- README.md
|
108
|
-
- Rakefile
|
109
108
|
- app/assets/images/dataTables/sort_asc.png
|
110
109
|
- app/assets/images/dataTables/sort_both.png
|
111
110
|
- app/assets/images/dataTables/sort_desc.png
|
data/Rakefile
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
begin
|
3
|
-
require 'bundler/setup'
|
4
|
-
rescue LoadError
|
5
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
-
end
|
7
|
-
|
8
|
-
# Our tasks
|
9
|
-
load 'lib/tasks/effective_datatables_tasks.rake'
|
10
|
-
|
11
|
-
# Testing tasks
|
12
|
-
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
13
|
-
load 'rails/tasks/engine.rake'
|
14
|
-
|
15
|
-
Bundler::GemHelper.install_tasks
|
16
|
-
|
17
|
-
require 'rspec/core'
|
18
|
-
require 'rspec/core/rake_task'
|
19
|
-
|
20
|
-
desc "Run all specs in spec directory (excluding plugin specs)"
|
21
|
-
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
22
|
-
|
23
|
-
task :default => :spec
|