effective_datatables 4.29.0 → 4.30.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -3
- data/app/assets/javascripts/effective_datatables/initialize.js.coffee +1 -1
- data/app/helpers/effective_datatables_helper.rb +1 -0
- data/app/helpers/effective_datatables_private_helper.rb +12 -0
- data/app/models/effective/datatable.rb +5 -0
- data/config/effective_datatables.rb +4 -2
- data/lib/effective_datatables/version.rb +1 -1
- data/lib/effective_datatables.rb +2 -0
- 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: 7663f0cd98b88923ef51722002f27d145f7baba83ac670d177ba0dd62a2301dc
|
4
|
+
data.tar.gz: 6dd269bd1b8912817a03748734cdd503114c399eebe850eb1df2fc71949ea54d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c3f9d268f19b45c7163a425d8720c353d60c03631c0b430e84caa514a7b5705e9caba70ac69df0406f7259502faf953351661fad958c068bc7cd67d51b6e9a9
|
7
|
+
data.tar.gz: 7a87a66cca6ad5bf2c675ebfece0e3085e27a01f65810a80e9f185821fc36262cba335ff3c85c7c75c047d6c58c9de183866064f6f96911ddd3ed63058fca06a
|
data/README.md
CHANGED
@@ -43,6 +43,7 @@ Please check out [Effective Datatables 3.x](https://github.com/code-and-effect/e
|
|
43
43
|
* [bulk_actions_col](#bulk_actions_col)
|
44
44
|
* [actions_col](#actions_col)
|
45
45
|
* [length](#length)
|
46
|
+
* [length_menu](#length_menu)
|
46
47
|
* [order](#order)
|
47
48
|
* [reorder](#reorder)
|
48
49
|
* [aggregate](#aggregate)
|
@@ -228,7 +229,7 @@ class PostsDatatable < Effective::Datatable
|
|
228
229
|
# The user's selected filters, search, sort, length, column visibility and pagination settings are saved between visits
|
229
230
|
# on a per-table basis and can be Reset with a button
|
230
231
|
datatable do
|
231
|
-
length 25 # 5, 10, 25, 50, 100, 500
|
232
|
+
length 25 # 5, 10, 25, 50, 100, 500
|
232
233
|
order :updated_at, :desc
|
233
234
|
|
234
235
|
# Renders a column of checkboxes to select items for any bulk_actions
|
@@ -614,7 +615,7 @@ MyApp::UsersTable.new(namespace: :my_app)
|
|
614
615
|
|
615
616
|
## length
|
616
617
|
|
617
|
-
Sets the default number of rows per page.
|
618
|
+
Sets the default number of rows per page.
|
618
619
|
|
619
620
|
When not specified, effective_datatables uses the default as per the `config/initializers/effective_datatables.rb` or 25.
|
620
621
|
|
@@ -622,6 +623,18 @@ When not specified, effective_datatables uses the default as per the `config/ini
|
|
622
623
|
length 100
|
623
624
|
```
|
624
625
|
|
626
|
+
## length_menu
|
627
|
+
|
628
|
+
You can specify the length menu values in `config/initializers/effective_datatables.rb` or per datatable.
|
629
|
+
|
630
|
+
To override the default, add the method to your datatable
|
631
|
+
|
632
|
+
```
|
633
|
+
def length_menu
|
634
|
+
[5, 10, 25, 50]
|
635
|
+
end
|
636
|
+
```
|
637
|
+
|
625
638
|
## order
|
626
639
|
|
627
640
|
Sets the default order of table rows. The first argument is the column, the second the direction.
|
@@ -1332,7 +1345,7 @@ class TimeEntriesPerClientReport < Effective::Datatable
|
|
1332
1345
|
end
|
1333
1346
|
|
1334
1347
|
datatable do
|
1335
|
-
length
|
1348
|
+
length 50
|
1336
1349
|
|
1337
1350
|
col :client
|
1338
1351
|
|
@@ -53,7 +53,7 @@ initializeDataTables = (target) ->
|
|
53
53
|
displayStart: datatable.data('display-start')
|
54
54
|
iDisplayLength: datatable.data('display-length')
|
55
55
|
language: datatable.data('language')
|
56
|
-
lengthMenu:
|
56
|
+
lengthMenu: datatable.data('length-menu')
|
57
57
|
order: datatable.data('display-order')
|
58
58
|
processing: true
|
59
59
|
responsive: true
|
@@ -67,6 +67,7 @@ module EffectiveDatatablesHelper
|
|
67
67
|
'display-start' => datatable.display_start,
|
68
68
|
'inline' => inline.to_s,
|
69
69
|
'language' => EffectiveDatatables.language(I18n.locale),
|
70
|
+
'length-menu' => datatable_length_menu(datatable),
|
70
71
|
'options' => input_js.to_json,
|
71
72
|
'reorder' => datatable.reorder?.to_s,
|
72
73
|
'reorder-index' => (datatable.columns[:_reorder][:index] if datatable.reorder?).to_s,
|
@@ -29,6 +29,18 @@ module EffectiveDatatablesPrivateHelper
|
|
29
29
|
render('/effective/datatables/buttons', datatable: datatable, search: search).gsub("'", '"').html_safe
|
30
30
|
end
|
31
31
|
|
32
|
+
def datatable_length_menu(datatable)
|
33
|
+
length_menu = datatable.length_menu
|
34
|
+
|
35
|
+
if length_menu.present?
|
36
|
+
raise('expected datatable length_menu to be an Array of Integers') unless length_menu.kind_of?(Array) && length_menu.all? { |i| i.kind_of?(Integer) }
|
37
|
+
end
|
38
|
+
|
39
|
+
length_menu ||= [5, 10, 25, 50, 100, 250, 500]
|
40
|
+
|
41
|
+
[length_menu.map(&:to_i), length_menu.map(&:to_s)]
|
42
|
+
end
|
43
|
+
|
32
44
|
def datatable_new_resource_button(datatable, name, column)
|
33
45
|
return unless datatable.inline? && (column[:actions][:new] != false)
|
34
46
|
|
@@ -211,6 +211,11 @@ module Effective
|
|
211
211
|
Array(attributes[:class] || EffectiveDatatables.html_class).join(' ').presence
|
212
212
|
end
|
213
213
|
|
214
|
+
# An array of integers [5, 10, 25, 50, 100, 250, 500]
|
215
|
+
def length_menu
|
216
|
+
EffectiveDatatables.length_menu
|
217
|
+
end
|
218
|
+
|
214
219
|
def to_param
|
215
220
|
"#{self.class.name.underscore.parameterize}-#{[self.class, attributes].hash.abs.to_s.last(12)}"
|
216
221
|
end
|
@@ -21,8 +21,10 @@ EffectiveDatatables.setup do |config|
|
|
21
21
|
# end
|
22
22
|
config.authorization_method = Proc.new { |controller, action, resource| authorize!(action, resource) }
|
23
23
|
|
24
|
-
#
|
25
|
-
|
24
|
+
# Display x per page options
|
25
|
+
config.length_menu = [5, 10, 25, 50, 100, 250, 500]
|
26
|
+
|
27
|
+
# Default number of entries shown per page. Must be in the length_menu.
|
26
28
|
config.default_length = 25
|
27
29
|
|
28
30
|
# Default class used on the <table> tag
|
data/lib/effective_datatables.rb
CHANGED
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.30.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: 2024-
|
11
|
+
date: 2024-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|