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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 533211d85df05ceea724f478a28537a9be1b1b4a18eb2e6fb3bec843236eaacb
4
- data.tar.gz: b521d06e9fb1cbb97d28eb693b6632d6891163b1eecf7c56472ede6989231f0c
3
+ metadata.gz: 7663f0cd98b88923ef51722002f27d145f7baba83ac670d177ba0dd62a2301dc
4
+ data.tar.gz: 6dd269bd1b8912817a03748734cdd503114c399eebe850eb1df2fc71949ea54d
5
5
  SHA512:
6
- metadata.gz: 709fd46784b74c1906c4dddb140c61453ddbf88057f3176ffb6872b26e2333977f48db5d28e2604bf8a96ba826749962e3d7ec4c6f0060fd927a7a8f23adedc4
7
- data.tar.gz: '08d88ac7aa0ad5f93ca003c044aa6cdd8ae6f42ff10755aacad27a327b0334411f7c0e652b3fe58299666d34bc4d6ca04bf2eefa689653eea12336fcf8b9b5b4'
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, :all
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. Valid lengths are `5`, `10`, `25`, `50`, `100`, `250`, `500`, `:all`
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 :all
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: [[5, 10, 25, 50, 100, 250, 500], ['5', '10', '25', '50', '100', '250', '500']]
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
- # Default number of entries shown per page
25
- # Valid options are: 5, 10, 25, 50, 100, 250, 500, :all
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
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '4.29.0'.freeze
2
+ VERSION = '4.30.0'.freeze
3
3
  end
@@ -9,6 +9,8 @@ module EffectiveDatatables
9
9
  mattr_accessor :authorization_method
10
10
 
11
11
  mattr_accessor :default_length
12
+ mattr_accessor :length_menu
13
+
12
14
  mattr_accessor :html_class
13
15
  mattr_accessor :save_state
14
16
 
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.29.0
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-06-12 00:00:00.000000000 Z
11
+ date: 2024-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails