tablets 0.3.1 → 0.3.3

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: ada28ad84ab6080afca26791721a0cc50a38ddbd
4
- data.tar.gz: 545ad23ef11c304211f4095ca35956b9a38c3d44
3
+ metadata.gz: 68012b3107a6032fcedefead6cebe9842a432400
4
+ data.tar.gz: 282ee6b15713cffb360deccf1080f35e0fe4bad7
5
5
  SHA512:
6
- metadata.gz: fac271b7c4b42ef7f2e6098f5c5506da9e49ed275687480f1b7b692478ef28b2dc497b5b05db43096fb709a7267f4ee0a75cd80a81cd0a50e76d230d3bbcd189
7
- data.tar.gz: 0096c9645613c4eea418b968a7e6b960ee806d32cad89c61839e8a64a8ea217573da00823a7b02813e7929c85c435b6ba9c251b8b45afdafa6a634405993f07d
6
+ metadata.gz: aa226722b0c938c3167197b9636eeaa94562859a044cc008be3af059326e19203639a18206e85ce2ab6b8e38fcb9e689a626215222993781661825a756d6a799
7
+ data.tar.gz: d8df45c567abda884a7c319c0b64cc7ecd4e75e89ae2676f8e3fb4a59f6cfc77a2c738e579261fa064c98910613c4339401665df9cb3200d6371061ce44d4ecb
data/README.md CHANGED
@@ -74,8 +74,13 @@ Tablets.register :posts do
74
74
 
75
75
  # Data relation.
76
76
  relation do |params|
77
- # Note: User joined to enable ordering.
78
- User.joins(:users).where(user_id: params[:user_id])
77
+ # Note: users joined to enable ordering.
78
+ Post.joins(:users).where(user_id: params[:user_id])
79
+ end
80
+
81
+ # Additional data added to response.
82
+ payload do
83
+ { hash_with: 'data' }
79
84
  end
80
85
  end
81
86
  ```
@@ -133,8 +138,14 @@ Called after datatable initialization.
133
138
  Tablets.on('afterInit', function() {});
134
139
  ```
135
140
 
136
- Called before AJAX request.
141
+ Called before AJAX request is sent.
137
142
 
138
143
  ``` javascript
139
144
  Tablets.on('beforeRequest', function(params) {});
140
145
  ```
146
+
147
+ Called after AJAX response is received.
148
+
149
+ ``` javascript
150
+ Tablets.on('afterResponse', function(data) {});
151
+ ```
@@ -3,6 +3,7 @@ $.extend Tablets,
3
3
  beforeInit: []
4
4
  afterInit: []
5
5
  beforeRequest: []
6
+ afterResponse: []
6
7
 
7
8
  on: (event, callback) ->
8
9
  @callbacks[event].push callback
@@ -2,6 +2,7 @@ class Tablets.Tablet
2
2
  constructor: (@element, @options, @params) ->
3
3
  @initVars()
4
4
  @initTable()
5
+ @initHandlers()
5
6
 
6
7
  Tablets.set(@id, this)
7
8
 
@@ -32,6 +33,11 @@ class Tablets.Tablet
32
33
 
33
34
  @trigger('afterInit')
34
35
 
36
+ initHandlers: ->
37
+ @element.on 'xhr.dt', (_event, _table, data) =>
38
+ @trigger('afterResponse', data)
39
+
40
+
35
41
  reload: ->
36
42
  @element.dataTable().fnDraw(false)
37
43
 
data/lib/tablets/data.rb CHANGED
@@ -15,7 +15,8 @@ module Tablets
15
15
  draw: params[:draw].to_i,
16
16
  recordsTotal: query.total,
17
17
  recordsFiltered: query.filtered,
18
- data: data
18
+ data: data,
19
+ payload: tablet.payload
19
20
  }
20
21
  end
21
22
 
@@ -51,6 +51,11 @@ module Tablets
51
51
  end
52
52
  end
53
53
 
54
+ # Returns additional data returned to client.
55
+ def payload
56
+ call(:payload) { {} }
57
+ end
58
+
54
59
  # Checks if config has callback with specified name.
55
60
  def has?(name)
56
61
  @config.has?(name)
@@ -1,3 +1,3 @@
1
1
  module Tablets
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tablets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yevhen Shemet
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  version: '0'
158
158
  requirements: []
159
159
  rubyforge_project:
160
- rubygems_version: 2.4.5
160
+ rubygems_version: 2.4.7
161
161
  signing_key:
162
162
  specification_version: 4
163
163
  summary: Wrapper around jquery-datatables.