effective_datatables 3.0.9 → 3.0.10

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: 58e4a1ee916c1766e2d3d2be61ffe2607d92c0d4
4
- data.tar.gz: b796116f649e7ca0711d7436f50b587d12c47576
3
+ metadata.gz: 16759c0e5f1a13f16ea9ebd7b227826a059d6d41
4
+ data.tar.gz: 566fb03358fb13f1f16fe43fd17b317fb2f960e1
5
5
  SHA512:
6
- metadata.gz: 1bcd2435e64b3576f7568f126791a77e6c5da1de4a26244b8f290ce4f9d03f43037d23075b7f932e21a3c288a8049c4a0fd9b3b4ec314f1c0498f37edd7f4734
7
- data.tar.gz: 5286e5530da18eaea928e8fae7311be484778b6be2694e1d0855c69c61cda7ba74efaa4b62e3fd79e8c7f44d2dbdf50d1b5bd6278ba202052403b3526dc6b518
6
+ metadata.gz: 03025955a600bc23c5a208a28f94ce65efb65a84cc68e9fedc9083c96c230e6f08ee42d20c2daa32c0d0b23bd922f24e2817b2ab9b4ac3badeec1996e28395ee
7
+ data.tar.gz: ff418748517d4133b1d6a0ccf595332d883ea439f43ef880d1d6bb877b8537bf821d40c3ebde5a231fa1799a15683406150d4e80f00f392b9c89e8f7df1fc412
data/README.md CHANGED
@@ -41,6 +41,7 @@ A lot has changed. See below for full details.
41
41
  # Getting Started
42
42
 
43
43
  ```ruby
44
+ gem 'haml-rails' # or try using gem 'hamlit-rails'
44
45
  gem 'effective_datatables'
45
46
  ```
46
47
 
@@ -313,6 +314,8 @@ As well, a datatable can be initialized with `attributes`.
313
314
 
314
315
  When initialized with a Hash, that hash is available throughout the entire datatable as `attributes`.
315
316
 
317
+ You can call the attributes from within the datatable as `attributes` or within a partial/view as `@datatable.attributes`.
318
+
316
319
  These attributes are serialized and stored in an encrypted cookie. Objects won't work. Keep it simple.
317
320
 
318
321
  Attributes cannot be changed by search, filter, or state in any way. They're guaranteed to be the same as when first initialized.
@@ -3,7 +3,7 @@ initializeDataTables = ->
3
3
  return if $.fn.DataTable.fnIsDataTable(this)
4
4
 
5
5
  datatable = $(this)
6
- simple = (datatable.data('simple') == true)
6
+ simple = ('' + datatable.data('simple') == 'true')
7
7
  input_js_options = datatable.data('input-js-options') || {}
8
8
  buttons_export_columns = input_js_options['buttons_export_columns'] || ':not(.col-actions)'
9
9
 
@@ -17,7 +17,7 @@ module EffectiveDatatablesHelper
17
17
 
18
18
  effective_datatable_params = {
19
19
  id: datatable.to_param,
20
- class: datatable.table_html_class,
20
+ class: Array(datatable.table_html_class).join(' '),
21
21
  data: {
22
22
  'effective-form-inputs' => defined?(EffectiveFormInputs),
23
23
  'bulk-actions' => datatable_bulk_actions(datatable),
@@ -29,7 +29,7 @@ module EffectiveDatatablesHelper
29
29
  'display-start' => datatable.display_start,
30
30
  'input-js-options' => (input_js || {}).to_json.html_safe,
31
31
  'reset' => datatable_reset(datatable),
32
- 'simple' => datatable.simple?.to_s,
32
+ 'simple' => simple.to_s,
33
33
  'source' => effective_datatables.datatable_path(datatable, {format: 'json'}),
34
34
  'total-records' => datatable.to_json[:recordsTotal]
35
35
  }
@@ -127,7 +127,7 @@ module Effective
127
127
  end
128
128
 
129
129
  def table_html_class
130
- attributes[:class] || 'table table-bordered table-striped'
130
+ attributes[:class] || EffectiveDatatables.html_class
131
131
  end
132
132
 
133
133
  def to_param
@@ -83,6 +83,10 @@ module Effective
83
83
  opts[:search] = { as: opts[:search] }
84
84
  when Array, ActiveRecord::Relation
85
85
  opts[:search] = { collection: opts[:search] }
86
+ when Hash
87
+ # Nothing
88
+ else
89
+ raise "column #{name} unexpected search value"
86
90
  end
87
91
 
88
92
  search = opts[:search]
@@ -93,6 +97,8 @@ module Effective
93
97
  search[:collection] = search[:collection].map { |obj| [obj.to_s, obj.to_param] }
94
98
  elsif search[:collection].kind_of?(Array)
95
99
  search[:collection].each { |obj| obj[1] = 'nil' if obj[1] == nil }
100
+ elsif search[:collection].kind_of?(Hash)
101
+ search[:collection].each { |k, v| search[:collection][k] = 'nil' if v == nil }
96
102
  end
97
103
 
98
104
  search[:value] ||= search.delete(:selected) if search.key?(:selected)
@@ -150,7 +150,8 @@ module Effective
150
150
 
151
151
  if state[:search].blank? && !datatables_ajax_request?
152
152
  columns.each do |name, opts|
153
- state[:search][name] = opts[:search][:value] if (opts[:search] || {}).key?(:value)
153
+ next unless opts[:search].kind_of?(Hash) && opts[:search].key?(:value)
154
+ state[:search][name] = opts[:search][:value]
154
155
  end
155
156
  end
156
157
 
@@ -24,6 +24,9 @@ EffectiveDatatables.setup do |config|
24
24
  # Valid options are: 5, 10, 25, 50, 100, 250, 1000, :all
25
25
  config.default_length = 25
26
26
 
27
+ # Default class used on the <table> tag
28
+ config.html_class = 'table table-bordered table-striped'
29
+
27
30
  # When using the actions_column DSL method, apply the following behavior
28
31
  # Valid values for each action are:
29
32
  # true - display this action if authorized?(:show, Post)
@@ -7,6 +7,8 @@ module EffectiveDatatables
7
7
  mattr_accessor :authorization_method
8
8
 
9
9
  mattr_accessor :default_length
10
+ mattr_accessor :html_class
11
+
10
12
  mattr_accessor :actions_column # A Hash
11
13
  mattr_accessor :debug
12
14
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '3.0.9'.freeze
2
+ VERSION = '3.0.10'.freeze
3
3
  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: 3.0.9
4
+ version: 3.0.10
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: 2017-06-08 00:00:00.000000000 Z
11
+ date: 2017-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails