effective_datatables 2.2.1 → 2.2.2
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/app/assets/javascripts/effective_datatables/initialize.js.coffee.erb +9 -7
- data/app/assets/stylesheets/effective_datatables/_overrides.scss.erb +15 -14
- data/app/helpers/effective_datatables_helper.rb +13 -16
- data/app/models/effective/datatable.rb +15 -1
- data/app/models/effective/effective_datatable/ajax.rb +2 -0
- data/app/views/effective/datatables/_datatable.html.haml +6 -9
- data/lib/effective_datatables/version.rb +1 -1
- metadata +27 -28
- data/app/assets/images/effective_datatables/copy_csv_xls_pdf.swf +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23149a11f5d924187b057923850c1883278bed56
|
4
|
+
data.tar.gz: af8cebc2b8ed50a9c1ab9bf3ea9d76a6572ef3bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9f8b343da4185651b0e55e4d2b72ded088cb360962d31e71da5886000c26403046c69c2c0c4445c71900adf42cf00c879393823fe66b0592cbaa63286c656d5
|
7
|
+
data.tar.gz: b564536eb290f27fdf2721dd37902dcfa441a7224eab2703edc27d24037dbe1f1674597df8fe3baa2af808d755d0c0b9424b93b36e6817e4c16d65143c80aa44
|
@@ -1,8 +1,10 @@
|
|
1
1
|
initializeDataTables = ->
|
2
|
-
$('table
|
2
|
+
$('table.effective-datatable').each ->
|
3
3
|
return if $.fn.DataTable.fnIsDataTable(this)
|
4
4
|
|
5
5
|
datatable = $(this)
|
6
|
+
simple = (datatable.data('simple') == true)
|
7
|
+
input_js_options = datatable.data('input-js-options') || {}
|
6
8
|
|
7
9
|
init_options =
|
8
10
|
ajax: { url: datatable.data('source'), type: 'POST' }
|
@@ -45,7 +47,7 @@ initializeDataTables = ->
|
|
45
47
|
columns: ':visible:not(.col-actions)'
|
46
48
|
},
|
47
49
|
]
|
48
|
-
colReorder:
|
50
|
+
colReorder: !simple
|
49
51
|
columns: datatable.data('columns')
|
50
52
|
deferLoading: [datatable.data('display-records'), datatable.data('total-records')]
|
51
53
|
deferRender: true
|
@@ -79,10 +81,6 @@ initializeDataTables = ->
|
|
79
81
|
|
80
82
|
$th.addClass('initialized')
|
81
83
|
|
82
|
-
if datatable.data('effective-datatables-table') == 'simple'
|
83
|
-
init_options['lengthMenu'] = [-1] # Show all results
|
84
|
-
init_options['dom'] = "<'row'r>t" # Just show the table
|
85
|
-
|
86
84
|
# Sets up the proper events for each input
|
87
85
|
initializeFilterEvents = (th) ->
|
88
86
|
th.find('input,select').each (_, input) ->
|
@@ -101,8 +99,12 @@ initializeDataTables = ->
|
|
101
99
|
table = obj.closest('table.dataTable')
|
102
100
|
table.DataTable().column("#{obj.data('column-name')}:name").search(obj.val()).draw()
|
103
101
|
|
102
|
+
if simple
|
103
|
+
init_options['dom'] = "<'row'<'col-sm-12'tr>>" # Just show the table
|
104
|
+
datatable.addClass('sort-hidden')
|
105
|
+
|
104
106
|
# Let's actually initialize the table now
|
105
|
-
table = datatable.dataTable(init_options)
|
107
|
+
table = datatable.dataTable(jQuery.extend(init_options, input_js_options))
|
106
108
|
|
107
109
|
# Apply EffectiveFormInputs to the Show x per page dropdown
|
108
110
|
if datatable.data('effective-form-inputs')
|
@@ -1,3 +1,4 @@
|
|
1
|
+
// Use asset_data_uri to prevent 3 additional GET requests for icons
|
1
2
|
table.dataTable thead .sorting {
|
2
3
|
background-image: url(<%= asset_data_uri('dataTables/sort_both.png') %>);
|
3
4
|
background-position: 100% 70%;
|
@@ -13,14 +14,16 @@ table.dataTable thead .sorting_desc {
|
|
13
14
|
background-position: 100% 70%;
|
14
15
|
}
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
}
|
19
|
-
table.dataTable thead .
|
20
|
-
|
21
|
-
|
22
|
-
table.dataTable thead .
|
23
|
-
|
17
|
+
// Override bootstrap default glyphicons
|
18
|
+
table.dataTable thead .sorting:after { content: ''; }
|
19
|
+
table.dataTable thead .sorting_asc:after { content: ''; }
|
20
|
+
table.dataTable thead .sorting_desc:after { content: ''; }
|
21
|
+
|
22
|
+
// Table header
|
23
|
+
table.dataTable thead > tr > th.sorting_asc,
|
24
|
+
table.dataTable thead > tr > th.sorting_desc,
|
25
|
+
table.dataTable thead > tr > th.sorting {
|
26
|
+
padding-right: 18px;
|
24
27
|
}
|
25
28
|
|
26
29
|
table.dataTable thead th {
|
@@ -32,12 +35,10 @@ table.dataTable thead th {
|
|
32
35
|
.form-group { margin-bottom: 0px; font-weight: normal; }
|
33
36
|
}
|
34
37
|
|
35
|
-
|
36
|
-
table.dataTable thead
|
37
|
-
table.dataTable thead
|
38
|
-
|
39
|
-
white-space: nowrap;
|
40
|
-
}
|
38
|
+
// Sorting disabled
|
39
|
+
table.dataTable.sort-hidden thead .sorting { background-image: none; }
|
40
|
+
table.dataTable.sort-hidden thead .sorting_asc { background-image: none; }
|
41
|
+
table.dataTable.sort-hidden thead .sorting_desc { background-image: none; }
|
41
42
|
|
42
43
|
// Filter bar
|
43
44
|
table.dataTable .form-group { width: 100%; margin-left: 0px; margin-right: 0px; }
|
@@ -1,17 +1,15 @@
|
|
1
1
|
module EffectiveDatatablesHelper
|
2
|
-
def render_datatable(datatable,
|
2
|
+
def render_datatable(datatable, input_js_options = nil)
|
3
3
|
datatable.view = self
|
4
|
-
|
5
|
-
|
6
|
-
render partial: 'effective/datatables/datatable', locals: locals.merge(datatable: datatable)
|
4
|
+
render partial: 'effective/datatables/datatable',
|
5
|
+
locals: { datatable: datatable, input_js_options: input_js_options.try(:to_json) }
|
7
6
|
end
|
8
7
|
|
9
|
-
def render_simple_datatable(datatable,
|
8
|
+
def render_simple_datatable(datatable, input_js_options = nil)
|
10
9
|
datatable.view = self
|
11
|
-
datatable.
|
12
|
-
|
13
|
-
|
14
|
-
render partial: 'effective/datatables/datatable', locals: locals.merge(datatable: datatable)
|
10
|
+
datatable.simple = true
|
11
|
+
render partial: 'effective/datatables/datatable',
|
12
|
+
locals: {datatable: datatable, input_js_options: input_js_options.try(:to_json) }
|
15
13
|
end
|
16
14
|
|
17
15
|
def datatable_default_order(datatable)
|
@@ -20,8 +18,8 @@ module EffectiveDatatablesHelper
|
|
20
18
|
|
21
19
|
# https://datatables.net/reference/option/columns
|
22
20
|
def datatable_columns(datatable)
|
23
|
-
|
24
|
-
simple_form_for(datatable, url: '#', html: {id: "#{datatable.to_param}-form"}) { |f|
|
21
|
+
form = nil
|
22
|
+
simple_form_for(datatable, url: '#', html: {id: "#{datatable.to_param}-form"}) { |f| form = f }
|
25
23
|
|
26
24
|
datatable.table_columns.map do |name, options|
|
27
25
|
{
|
@@ -30,17 +28,16 @@ module EffectiveDatatablesHelper
|
|
30
28
|
className: options[:class],
|
31
29
|
width: options[:width],
|
32
30
|
responsivePriority: (options[:responsivePriority] || 10000), # 10,000 is datatables default
|
33
|
-
sortable: options[:sortable],
|
31
|
+
sortable: (options[:sortable] && !datatable.simple?),
|
34
32
|
visible: (options[:visible].respond_to?(:call) ? datatable.instance_exec(&options[:visible]) : options[:visible]),
|
35
|
-
filterHtml: datatable_header_filter(
|
33
|
+
filterHtml: (datatable_header_filter(form, name, options) unless datatable.simple?),
|
36
34
|
filterSelectedValue: options[:filter][:selected]
|
37
35
|
}
|
38
36
|
end.to_json()
|
39
37
|
end
|
40
38
|
|
41
|
-
def datatable_header_filter(form, name, opts
|
42
|
-
return render(partial: opts[:header_partial], locals: {form: form, name: (opts[:label] || name), column: opts
|
43
|
-
return content_tag(:p, opts[:label] || name) if filterable == false
|
39
|
+
def datatable_header_filter(form, name, opts)
|
40
|
+
return render(partial: opts[:header_partial], locals: {form: form, name: (opts[:label] || name), column: opts}) if opts[:header_partial].present?
|
44
41
|
|
45
42
|
case opts[:filter][:type]
|
46
43
|
when :string, :text, :number
|
@@ -1,6 +1,9 @@
|
|
1
1
|
module Effective
|
2
2
|
class Datatable
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :display_records, :view, :attributes
|
4
|
+
|
5
|
+
# These two options control the render behaviour of a datatable
|
6
|
+
attr_accessor :table_html_class, :simple
|
4
7
|
|
5
8
|
delegate :render, :controller, :link_to, :mail_to, :number_to_currency, :to => :@view
|
6
9
|
|
@@ -121,6 +124,17 @@ module Effective
|
|
121
124
|
@order_direction = nil
|
122
125
|
end
|
123
126
|
|
127
|
+
def table_html_class
|
128
|
+
@table_html_class.presence || 'table table-bordered table-striped'
|
129
|
+
end
|
130
|
+
|
131
|
+
# When simple only a table will be rendered with
|
132
|
+
# no sorting, no filtering, no export buttons, no pagination, no per page, no colReorder
|
133
|
+
# default sorting only, default visibility only, all records returned, and responsive enabled
|
134
|
+
def simple?
|
135
|
+
@simple == true
|
136
|
+
end
|
137
|
+
|
124
138
|
protected
|
125
139
|
|
126
140
|
def params
|
@@ -1,16 +1,13 @@
|
|
1
1
|
:ruby
|
2
2
|
effective_datatable_params = {
|
3
|
-
:
|
4
|
-
:
|
5
|
-
:
|
6
|
-
:cellspacing => 0,
|
7
|
-
:border => 0,
|
8
|
-
:width => '100%',
|
9
|
-
:data => {
|
10
|
-
'effective-datatables-table' => style,
|
3
|
+
id: "#{datatable.to_param}-table",
|
4
|
+
class: "#{datatable.table_html_class}",
|
5
|
+
data: {
|
11
6
|
'effective-form-inputs' => defined?(EffectiveFormInputs),
|
12
7
|
'columns' => datatable_columns(datatable),
|
13
|
-
'
|
8
|
+
'input-js-options' => local_assigns[:input_js_options],
|
9
|
+
'simple' => datatable.simple?.to_s,
|
10
|
+
'source' => effective_datatables.datatable_path(datatable, {format: 'json'}.merge(attributes: datatable.attributes)).chomp('?'),
|
14
11
|
'default-order' => datatable_default_order(datatable),
|
15
12
|
'display-entries' => datatable.display_entries,
|
16
13
|
'display-records' => (datatable.to_json[:recordsFiltered] || 0),
|
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_datatables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
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: 2015-12-
|
11
|
+
date: 2015-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: coffee-rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: kaminari
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: sass-rails
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: haml-rails
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: simple_form
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
description: Uniquely powerful server-side searching, sorting and filtering of any
|
@@ -103,10 +103,12 @@ executables: []
|
|
103
103
|
extensions: []
|
104
104
|
extra_rdoc_files: []
|
105
105
|
files:
|
106
|
+
- MIT-LICENSE
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
106
109
|
- app/assets/images/dataTables/sort_asc.png
|
107
110
|
- app/assets/images/dataTables/sort_both.png
|
108
111
|
- app/assets/images/dataTables/sort_desc.png
|
109
|
-
- app/assets/images/effective_datatables/copy_csv_xls_pdf.swf
|
110
112
|
- app/assets/javascripts/dataTables/buttons/buttons.bootstrap.js
|
111
113
|
- app/assets/javascripts/dataTables/buttons/buttons.colVis.js
|
112
114
|
- app/assets/javascripts/dataTables/buttons/buttons.html5.js
|
@@ -117,8 +119,8 @@ files:
|
|
117
119
|
- app/assets/javascripts/dataTables/jquery.dataTables.min.js
|
118
120
|
- app/assets/javascripts/dataTables/responsive/dataTables.responsive.min.js
|
119
121
|
- app/assets/javascripts/dataTables/responsive/responsive.bootstrap.min.js
|
120
|
-
- app/assets/javascripts/effective_datatables/initialize.js.coffee.erb
|
121
122
|
- app/assets/javascripts/effective_datatables.js
|
123
|
+
- app/assets/javascripts/effective_datatables/initialize.js.coffee.erb
|
122
124
|
- app/assets/javascripts/vendor/jquery.debounce.min.js
|
123
125
|
- app/assets/javascripts/vendor/jszip.min.js
|
124
126
|
- app/assets/stylesheets/dataTables/buttons/buttons.bootstrap.min.css
|
@@ -129,8 +131,8 @@ files:
|
|
129
131
|
- app/assets/stylesheets/dataTables/jquery.dataTables.min.css
|
130
132
|
- app/assets/stylesheets/dataTables/responsive/responsive.bootstrap.min.css
|
131
133
|
- app/assets/stylesheets/dataTables/responsive/responsive.dataTables.min.css
|
132
|
-
- app/assets/stylesheets/effective_datatables/_overrides.scss.erb
|
133
134
|
- app/assets/stylesheets/effective_datatables.scss
|
135
|
+
- app/assets/stylesheets/effective_datatables/_overrides.scss.erb
|
134
136
|
- app/controllers/effective/datatables_controller.rb
|
135
137
|
- app/helpers/effective_datatables_helper.rb
|
136
138
|
- app/models/effective/access_denied.rb
|
@@ -145,21 +147,21 @@ files:
|
|
145
147
|
- app/views/effective/datatables/_datatable.html.haml
|
146
148
|
- app/views/effective/datatables/_spacer_template.html
|
147
149
|
- config/routes.rb
|
150
|
+
- lib/effective_datatables.rb
|
148
151
|
- lib/effective_datatables/engine.rb
|
149
152
|
- lib/effective_datatables/version.rb
|
150
|
-
- lib/effective_datatables.rb
|
151
153
|
- lib/generators/effective_datatables/install_generator.rb
|
152
|
-
- lib/generators/templates/effective_datatables.rb
|
153
154
|
- lib/generators/templates/README
|
155
|
+
- lib/generators/templates/effective_datatables.rb
|
154
156
|
- lib/tasks/effective_datatables_tasks.rake
|
155
|
-
-
|
156
|
-
- Rakefile
|
157
|
-
- README.md
|
157
|
+
- spec/dummy/README.rdoc
|
158
|
+
- spec/dummy/Rakefile
|
158
159
|
- spec/dummy/app/assets/javascripts/application.js
|
159
160
|
- spec/dummy/app/assets/stylesheets/application.css
|
160
161
|
- spec/dummy/app/controllers/application_controller.rb
|
161
162
|
- spec/dummy/app/helpers/application_helper.rb
|
162
163
|
- spec/dummy/app/views/layouts/application.html.erb
|
164
|
+
- spec/dummy/config.ru
|
163
165
|
- spec/dummy/config/application.rb
|
164
166
|
- spec/dummy/config/boot.rb
|
165
167
|
- spec/dummy/config/database.yml
|
@@ -175,7 +177,6 @@ files:
|
|
175
177
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
176
178
|
- spec/dummy/config/locales/en.yml
|
177
179
|
- spec/dummy/config/routes.rb
|
178
|
-
- spec/dummy/config.ru
|
179
180
|
- spec/dummy/db/development.sqlite3
|
180
181
|
- spec/dummy/db/schema.rb
|
181
182
|
- spec/dummy/db/test.sqlite3
|
@@ -185,8 +186,6 @@ files:
|
|
185
186
|
- spec/dummy/public/422.html
|
186
187
|
- spec/dummy/public/500.html
|
187
188
|
- spec/dummy/public/favicon.ico
|
188
|
-
- spec/dummy/Rakefile
|
189
|
-
- spec/dummy/README.rdoc
|
190
189
|
- spec/dummy/script/rails
|
191
190
|
- spec/effective_datatables_spec.rb
|
192
191
|
- spec/spec_helper.rb
|
@@ -201,17 +200,17 @@ require_paths:
|
|
201
200
|
- lib
|
202
201
|
required_ruby_version: !ruby/object:Gem::Requirement
|
203
202
|
requirements:
|
204
|
-
- -
|
203
|
+
- - ">="
|
205
204
|
- !ruby/object:Gem::Version
|
206
205
|
version: '0'
|
207
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
208
207
|
requirements:
|
209
|
-
- -
|
208
|
+
- - ">="
|
210
209
|
- !ruby/object:Gem::Version
|
211
210
|
version: '0'
|
212
211
|
requirements: []
|
213
212
|
rubyforge_project:
|
214
|
-
rubygems_version: 2.0
|
213
|
+
rubygems_version: 2.5.0
|
215
214
|
signing_key:
|
216
215
|
specification_version: 4
|
217
216
|
summary: Uniquely powerful server-side searching, sorting and filtering of any ActiveRecord
|
Binary file
|