effective_datatables 3.2.1 → 3.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/effective/datatables_controller.rb +1 -1
- data/app/helpers/effective_datatables_helper.rb +3 -2
- data/app/models/effective/datatable.rb +1 -1
- data/app/models/effective/effective_datatable/cookie.rb +13 -10
- data/app/models/effective/effective_datatable/params.rb +4 -1
- data/lib/effective_datatables/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8dcd63f38f80e7f59a6dbd33b2f7c2238e954ed
|
4
|
+
data.tar.gz: a932b089090e3a23c9a0a041a78d544925010a59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e2aa904aa6a0f8f348f85de650da46157e6bf0f8de3585abd83f623a4cd6868010f6408654843f7ff035ec371c5d0f0cf60b9958a45e9bd6bcd24338e450694
|
7
|
+
data.tar.gz: 92bcad95fb86bb381b52cd36c874ad462f7e1b97ee35f1e4fcaf3c12597c2602c182c393264f0e7930272e3cbda5f01ef4421c78b5bc890d1f72be98998abe68
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# These are expected to be called by a developer. They are part of the datatables DSL.
|
2
2
|
module EffectiveDatatablesHelper
|
3
3
|
|
4
|
-
def render_datatable(datatable, input_js: {}, charts: true, filters: true, simple: false)
|
4
|
+
def render_datatable(datatable, input_js: {}, charts: true, filters: true, simple: false, buttons: true)
|
5
5
|
raise 'expected datatable to be present' unless datatable
|
6
6
|
|
7
7
|
datatable.view ||= self
|
@@ -14,6 +14,7 @@ module EffectiveDatatablesHelper
|
|
14
14
|
|
15
15
|
charts = charts && datatable._charts.present?
|
16
16
|
filters = filters && (datatable._scopes.present? || datatable._filters.present?)
|
17
|
+
input_js[:buttons] = false unless buttons
|
17
18
|
|
18
19
|
effective_datatable_params = {
|
19
20
|
id: datatable.to_param,
|
@@ -22,7 +23,7 @@ module EffectiveDatatablesHelper
|
|
22
23
|
'effective-form-inputs' => defined?(EffectiveFormInputs),
|
23
24
|
'bulk-actions' => datatable_bulk_actions(datatable),
|
24
25
|
'columns' => datatable_columns(datatable),
|
25
|
-
'cookie' => datatable.
|
26
|
+
'cookie' => datatable.cookie_key,
|
26
27
|
'display-length' => datatable.display_length,
|
27
28
|
'display-order' => [datatable.order_index, datatable.order_direction].to_json().html_safe,
|
28
29
|
'display-records' => datatable.to_json[:recordsFiltered],
|
@@ -7,14 +7,17 @@ module Effective
|
|
7
7
|
@cookie
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
@
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
def cookie_key
|
11
|
+
@cookie_key ||= (datatables_ajax_request? ? view.params[:cookie] : cookie_param)
|
12
|
+
end
|
13
|
+
|
14
|
+
# All possible dt cookie keys. Used to make sure the datatable has a cookie set for this session.
|
15
|
+
def cookie_keys
|
16
|
+
@cookie_keys ||= Array(@dt_cookie).compact.map(&:first)
|
17
|
+
end
|
18
|
+
|
19
|
+
def cookie_param
|
20
|
+
[self.class, attributes].hash.to_s.last(12)
|
18
21
|
end
|
19
22
|
|
20
23
|
private
|
@@ -28,7 +31,7 @@ module Effective
|
|
28
31
|
raise 'invalid datatables cookie' unless @dt_cookie.kind_of?(Array)
|
29
32
|
|
30
33
|
# Assign individual cookie
|
31
|
-
index = @dt_cookie.rindex { |
|
34
|
+
index = @dt_cookie.rindex { |key, _| key == cookie_key }
|
32
35
|
@cookie = @dt_cookie.delete_at(index) if index
|
33
36
|
end
|
34
37
|
|
@@ -40,7 +43,7 @@ module Effective
|
|
40
43
|
|
41
44
|
def save_cookie!
|
42
45
|
@dt_cookie ||= []
|
43
|
-
@dt_cookie << [
|
46
|
+
@dt_cookie << [cookie_key, cookie_payload]
|
44
47
|
|
45
48
|
while @dt_cookie.to_s.size > MAX_COOKIE_SIZE
|
46
49
|
@dt_cookie.shift((@dt_cookie.length / 3) + 1)
|
@@ -5,7 +5,10 @@ module Effective
|
|
5
5
|
private
|
6
6
|
|
7
7
|
def datatables_ajax_request?
|
8
|
-
|
8
|
+
return @_datatables_ajax_request unless @_datatables_ajax_request.nil?
|
9
|
+
|
10
|
+
@_datatables_ajax_request =
|
11
|
+
(view && view.params[:draw] && view.params[:columns] && cookie_keys.include?(view.params[:cookie])) == true
|
9
12
|
end
|
10
13
|
|
11
14
|
def params
|
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.2.
|
4
|
+
version: 3.2.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: 2017-09-
|
11
|
+
date: 2017-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|