effective_datatables 1.2.4 → 1.2.5

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: 53509b26f9e4b62d154006f3ae6ecd5ac0fe61a4
4
- data.tar.gz: 553b9c7616b6ee897aae9b65b7e2871a2cf2ef24
3
+ metadata.gz: 087d65c39d2b88c60fcc041b5f7a564bc61bded7
4
+ data.tar.gz: 611af4b47aaa06ccb61d59b5d8cd4bcb56363d91
5
5
  SHA512:
6
- metadata.gz: 5a219222e02cfe4dfb76c5ce8799ee8cd842ca80e46d41c24185e3b34c19ec03bf79b8fcbcbcd5c1dc469b896f7382ee2822e929101e7c421709083439e27ced
7
- data.tar.gz: eeb7adca4ac69be8345c504179bdff6c495d14a4fe4c2189674a9978415884a1689cf7c4a6269b9d236792a8dbd97bfd0171063c57b4823a31955dc963402571
6
+ metadata.gz: 6ddaca87e620c93d477081bd48fc4e6ba8029fef349ef3042d1b4b4dae736d6603822366d9d7f0741f0ecb5280e91833466ed2fd9a53b520d79b4e5de066d08c
7
+ data.tar.gz: e2217a2fd7c3b191bbf755a55f46b5ac85ac6ec44d67a6465302590710982660f3ab4f4a3d56661c4f47864c0d1023e49cd3073cce75c59795e345a9df26e840
data/README.md CHANGED
@@ -133,6 +133,7 @@ module Effective
133
133
  module Datatables
134
134
  class Posts < Effective::Datatable
135
135
  default_order :created_at, :desc
136
+ default_entries 25
136
137
 
137
138
  table_column :id, :visible => false
138
139
 
@@ -387,6 +388,17 @@ Sort the table by this field and direction on start up
387
388
  default_order :created_at, :asc|:desc
388
389
  ```
389
390
 
391
+ ## default_entries
392
+
393
+ The number of entries to show per page
394
+
395
+ ```ruby
396
+ default_entries :all
397
+ ```
398
+
399
+ Valid options are `10, 25, 50, 100, 250, 1000, :all`
400
+
401
+
390
402
  ## Additional Functionality
391
403
 
392
404
  There are a few other ways to customize the behaviour of effective_datatables
@@ -18,7 +18,7 @@ initializeDataTables = ->
18
18
  sAjaxSource: datatable.data('source')
19
19
  pagingType: 'simple_numbers'
20
20
  lengthMenu: [[10, 25, 50, 100, 250, 1000, -1], [10, 25, 50, 100, 250, 1000, 'All']]
21
- iDisplayLength: 25
21
+ iDisplayLength: datatable.data('default-entries')
22
22
  fnServerParams: (aoData, a, b) ->
23
23
  table = this.DataTable()
24
24
  table.columns().flatten().each (index) -> # Pass which columns are visible back to server
@@ -33,6 +33,7 @@ initializeDataTables = ->
33
33
  sSearch = undefined
34
34
  ((sSearch = data; break) if data.name == "sSearch_#{index}") for data in aoData
35
35
  sSearch.value = filter.selected if sSearch
36
+ datatable.fnSettings().aoPreSearchCols[index].sSearch = filter.selected
36
37
 
37
38
  aoColumnDefs: aoColumnDefs
38
39
  aoColumns: datatable.data('widths')
@@ -58,6 +58,12 @@ module EffectiveDatatablesHelper
58
58
  ].to_json()
59
59
  end
60
60
 
61
+ def datatable_default_entries(datatable)
62
+ default_entries = (datatable.default_entries.presence || EffectiveDatatables.default_entries)
63
+ default_entries = -1 if default_entries.to_s.downcase == 'all'
64
+ [10, 25, 50, 100, 250, 1000, -1].include?(default_entries) ? default_entries : 25
65
+ end
66
+
61
67
  def datatable_widths(datatable)
62
68
  datatable.table_columns.values.map { |options| {'sWidth' => options[:width]} if options[:width] }.to_json()
63
69
  end
@@ -41,6 +41,10 @@ module Effective
41
41
  @default_order = {name => direction}
42
42
  end
43
43
 
44
+ def default_entries(entries)
45
+ @default_entries = entries
46
+ end
47
+
44
48
  end
45
49
 
46
50
  def initialize(*args)
@@ -115,6 +119,10 @@ module Effective
115
119
  self.class.instance_variable_get(:@default_order)
116
120
  end
117
121
 
122
+ def default_entries
123
+ self.class.instance_variable_get(:@default_entries)
124
+ end
125
+
118
126
  def search_terms
119
127
  @search_terms ||= HashWithIndifferentAccess.new().tap do |terms|
120
128
  table_columns.keys.each_with_index do |col, x|
@@ -1,4 +1,4 @@
1
- %table.effective-datatable{:id => "#{datatable.to_param}-table", :class => ('table ' + table_class.to_s), :data => {'effective-datatables-table' => style, 'source' => effective_datatables.datatable_path(datatable, {:format => 'json'}.merge(:attributes => datatable.attributes)), 'filter' => datatable_filter(datatable, filterable), 'non-sortable' => datatable_non_sortable(datatable, sortable), 'non-visible' => datatable_non_visible(datatable), 'widths' => datatable_widths(datatable), 'default-order' => datatable_default_order(datatable), 'column-classes' => datatable_column_classes(datatable)}}
1
+ %table.effective-datatable{:id => "#{datatable.to_param}-table", :class => ('table ' + table_class.to_s), :data => {'effective-datatables-table' => style, 'source' => effective_datatables.datatable_path(datatable, {:format => 'json'}.merge(:attributes => datatable.attributes)), 'filter' => datatable_filter(datatable, filterable), 'non-sortable' => datatable_non_sortable(datatable, sortable), 'non-visible' => datatable_non_visible(datatable), 'widths' => datatable_widths(datatable), 'default-order' => datatable_default_order(datatable), 'default-entries' => datatable_default_entries(datatable), 'column-classes' => datatable_column_classes(datatable)}}
2
2
  %thead
3
3
  - max_depth = datatable.table_columns.map { |_, opts| opts[:th][:depth].to_i rescue 0 }.max
4
4
  - [*0..max_depth].each do |depth|
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '1.2.4'.freeze
2
+ VERSION = '1.2.5'.freeze
3
3
  end
@@ -8,6 +8,7 @@ module EffectiveDatatables
8
8
  mattr_accessor :authorization_method
9
9
  mattr_accessor :date_format
10
10
  mattr_accessor :datetime_format
11
+ mattr_accessor :default_entries
11
12
 
12
13
  def self.setup
13
14
  yield self
@@ -26,5 +26,7 @@ EffectiveDatatables.setup do |config|
26
26
  config.date_format = "%Y-%m-%d"
27
27
  config.datetime_format = "%Y-%m-%d %H:%M"
28
28
 
29
-
29
+ # Default number of entries shown per page
30
+ # Valid options are: 10, 25, 50, 100, 250, 1000, :all
31
+ config.default_entries = 25
30
32
  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.2.4
4
+ version: 1.2.5
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-03-06 00:00:00.000000000 Z
11
+ date: 2015-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails