effective_datatables 1.8.1 → 1.8.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1e69441faaaf97e4d7233349e3251117d31557d
|
4
|
+
data.tar.gz: e3fbf33bb81f9f037ba8bb8dfbf618f97a0b96c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0719337d5baaa89aecd3abf33c4f5f85f8e31d07abf1b15b486ff10d560efedeafd191464fd06949035a611b165659b9c8216bc7c160e57ae04b7dc0c6502a82
|
7
|
+
data.tar.gz: 2e2e94e71e14e63c0fa12ca3c10858e2c8d2b9d907ef5ee506fed6fd8c71b4218f3287ff519e0de8db37884d33d9c8a1574b61df1fba60e79dd94b70aa9ca17d
|
data/README.md
CHANGED
@@ -351,6 +351,22 @@ The request object is available to the table_column, so you could just as easily
|
|
351
351
|
request.referer.include?('/admin/')
|
352
352
|
```
|
353
353
|
|
354
|
+
### Header Rendering
|
355
|
+
|
356
|
+
You can override the default rendering and define a partial to use for the header `<th>`:
|
357
|
+
|
358
|
+
```ruby
|
359
|
+
table_column :special, :header_partial => '/posts/special_header'
|
360
|
+
```
|
361
|
+
|
362
|
+
The following locals will be available in the header partial:
|
363
|
+
|
364
|
+
```ruby
|
365
|
+
form # The SimpleForm FormBuilder instance
|
366
|
+
name # The name of your column
|
367
|
+
column # the table_column options
|
368
|
+
filterable # whether the dataTable is filterable
|
369
|
+
```
|
354
370
|
|
355
371
|
## table_columns
|
356
372
|
|
@@ -48,13 +48,15 @@ initializeDataTables = ->
|
|
48
48
|
# For every existing Input, Set up the search events
|
49
49
|
(search_inputs = datatable.find('thead').first().find('input,select')).each (index, input) ->
|
50
50
|
$input = $(input)
|
51
|
-
$input.on 'click', (event) -> false # Dont order columns when you click inside the input
|
52
|
-
$input.on 'mousedown', (event) -> event.stopPropagation() # Dont order columns when you click inside the input
|
53
51
|
|
54
|
-
if $input.
|
55
|
-
$input.on '
|
56
|
-
|
57
|
-
|
52
|
+
if $input.data('column-name')
|
53
|
+
$input.on 'click', (event) -> false # Dont order columns when you click inside the input
|
54
|
+
$input.on 'mousedown', (event) -> event.stopPropagation() # Dont order columns when you click inside the input
|
55
|
+
|
56
|
+
if $input.is('select')
|
57
|
+
$input.on 'change', (event) -> dataTableSearch(event)
|
58
|
+
else if $input.is('input')
|
59
|
+
$input.keyup($.debounce(300, dataTableSearch))
|
58
60
|
|
59
61
|
# Let's actually initialize the table now
|
60
62
|
table = datatable.dataTable(init_options)
|
@@ -62,7 +64,7 @@ initializeDataTables = ->
|
|
62
64
|
# Assign PreSearch columns
|
63
65
|
search_inputs.each (index, input) =>
|
64
66
|
$input = $(input)
|
65
|
-
if $input.data('column-index') && $input.val()
|
67
|
+
if $input.data('column-index') && $input.data('column-name') && $input.val()
|
66
68
|
table.fnSettings().aoPreSearchCols[$input.data('column-index')].sSearch = $input.val()
|
67
69
|
|
68
70
|
# FixedColumns doesn't work well yet.
|
@@ -1,26 +1,27 @@
|
|
1
1
|
module EffectiveDatatablesHelper
|
2
2
|
def render_datatable(datatable, opts = {}, &block)
|
3
3
|
datatable.view = self
|
4
|
-
locals = {:
|
4
|
+
locals = {style: :full, filterable: true, sortable: true, table_class: 'table-bordered table-striped'}.merge(opts)
|
5
5
|
|
6
|
-
render :
|
6
|
+
render partial: 'effective/datatables/datatable', locals: locals.merge(datatable: datatable)
|
7
7
|
end
|
8
8
|
|
9
9
|
def render_simple_datatable(datatable, opts = {})
|
10
10
|
datatable.view = self
|
11
11
|
datatable.per_page = :all
|
12
|
-
locals = {:
|
12
|
+
locals = {style: :simple, filterable: false, sortable: false, table_class: 'table-bordered table-striped sorting-hidden'}.merge(opts)
|
13
13
|
|
14
|
-
render :
|
14
|
+
render partial: 'effective/datatables/datatable', locals: locals.merge(datatable: datatable)
|
15
15
|
end
|
16
16
|
|
17
17
|
def render_datatable_header_cell(form, name, opts, filterable = true)
|
18
|
+
return render(partial: opts[:header_partial], locals: {form: form, name: (opts[:label] || name), column: opts, filterable: filterable}) if opts[:header_partial].present?
|
18
19
|
return content_tag(:p, opts[:label] || name) if filterable == false
|
19
20
|
|
20
21
|
case opts[:filter][:type]
|
21
22
|
when :string, :text, :number
|
22
|
-
form.input name, :
|
23
|
-
:
|
23
|
+
form.input name, label: false, required: false, as: :string, placeholder: (opts[:label] || name),
|
24
|
+
input_html: { name: nil, autocomplete: 'off', data: {'column-name' => opts[:name], 'column-index' => opts[:index]} }
|
24
25
|
when :select, :boolean
|
25
26
|
if opts[:filter][:values].respond_to?(:call)
|
26
27
|
opts[:filter][:values] = opts[:filter][:values].call()
|
@@ -30,8 +31,8 @@ module EffectiveDatatablesHelper
|
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
|
-
form.input name, :
|
34
|
-
:
|
34
|
+
form.input name, label: false, required: false, as: :select, collection: opts[:filter][:values], include_blank: (opts[:label] || name.titleize),
|
35
|
+
input_html: { name: nil, autocomplete: 'off', data: {'column-name' => opts[:name], 'column-index' => opts[:index]} }
|
35
36
|
else
|
36
37
|
content_tag(:p, opts[:label] || name)
|
37
38
|
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: 1.8.
|
4
|
+
version: 1.8.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-06-
|
11
|
+
date: 2015-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|