mongoid-data_table 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mongoid-data_table (1.0.3)
4
+ mongoid-data_table (1.0.5)
5
5
  kaminari (~> 0.12.4)
6
6
  rails (>= 3.0.0)
7
7
 
@@ -9,12 +9,12 @@ GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
11
  abstract (1.0.0)
12
- actionmailer (3.0.7)
13
- actionpack (= 3.0.7)
14
- mail (~> 2.2.15)
15
- actionpack (3.0.7)
16
- activemodel (= 3.0.7)
17
- activesupport (= 3.0.7)
12
+ actionmailer (3.0.8)
13
+ actionpack (= 3.0.8)
14
+ mail (~> 2.2.19)
15
+ actionpack (3.0.8)
16
+ activemodel (= 3.0.8)
17
+ activesupport (= 3.0.8)
18
18
  builder (~> 2.1.2)
19
19
  erubis (~> 2.6.6)
20
20
  i18n (~> 0.5.0)
@@ -22,19 +22,19 @@ GEM
22
22
  rack-mount (~> 0.6.14)
23
23
  rack-test (~> 0.5.7)
24
24
  tzinfo (~> 0.3.23)
25
- activemodel (3.0.7)
26
- activesupport (= 3.0.7)
25
+ activemodel (3.0.8)
26
+ activesupport (= 3.0.8)
27
27
  builder (~> 2.1.2)
28
28
  i18n (~> 0.5.0)
29
- activerecord (3.0.7)
30
- activemodel (= 3.0.7)
31
- activesupport (= 3.0.7)
32
- arel (~> 2.0.2)
29
+ activerecord (3.0.8)
30
+ activemodel (= 3.0.8)
31
+ activesupport (= 3.0.8)
32
+ arel (~> 2.0.10)
33
33
  tzinfo (~> 0.3.23)
34
- activeresource (3.0.7)
35
- activemodel (= 3.0.7)
36
- activesupport (= 3.0.7)
37
- activesupport (3.0.7)
34
+ activeresource (3.0.8)
35
+ activemodel (= 3.0.8)
36
+ activesupport (= 3.0.8)
37
+ activesupport (3.0.8)
38
38
  arel (2.0.10)
39
39
  bson (1.3.1)
40
40
  bson_ext (1.3.1)
@@ -64,25 +64,25 @@ GEM
64
64
  rack (>= 1.0.0)
65
65
  rack-test (0.5.7)
66
66
  rack (>= 1.0)
67
- rails (3.0.7)
68
- actionmailer (= 3.0.7)
69
- actionpack (= 3.0.7)
70
- activerecord (= 3.0.7)
71
- activeresource (= 3.0.7)
72
- activesupport (= 3.0.7)
67
+ rails (3.0.8)
68
+ actionmailer (= 3.0.8)
69
+ actionpack (= 3.0.8)
70
+ activerecord (= 3.0.8)
71
+ activeresource (= 3.0.8)
72
+ activesupport (= 3.0.8)
73
73
  bundler (~> 1.0)
74
- railties (= 3.0.7)
75
- railties (3.0.7)
76
- actionpack (= 3.0.7)
77
- activesupport (= 3.0.7)
74
+ railties (= 3.0.8)
75
+ railties (3.0.8)
76
+ actionpack (= 3.0.8)
77
+ activesupport (= 3.0.8)
78
78
  rake (>= 0.8.7)
79
79
  thor (~> 0.14.4)
80
- rake (0.9.0)
80
+ rake (0.9.2)
81
81
  rspec (2.6.0)
82
82
  rspec-core (~> 2.6.0)
83
83
  rspec-expectations (~> 2.6.0)
84
84
  rspec-mocks (~> 2.6.0)
85
- rspec-core (2.6.1)
85
+ rspec-core (2.6.4)
86
86
  rspec-expectations (2.6.0)
87
87
  diff-lcs (~> 1.1.2)
88
88
  rspec-mocks (2.6.0)
data/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # Mongoid: Data Table
2
+
3
+ Makes it easy to ship data to a jQuery DataTable from Mongoid.
4
+
5
+ ## Quick example:
6
+
7
+ ### Javascript
8
+
9
+ ```javascript
10
+ $(".providers-data-table").dataTable({
11
+ "bJQueryUI" : true,
12
+ "bProcessing" : true,
13
+ "bAutoWidth" : false,
14
+ "sPaginationType" : "full_numbers",
15
+ "aoColumns" : [{"sType" : "html"}, null, null, null, null],
16
+ "aaSorting" : [[0, 'asc'], [1, 'asc']],
17
+ "bServerSide" : true,
18
+ "sAjaxSource" : "/providers.json"
19
+ }).fnSetFilteringDelay();
20
+ ```
21
+
22
+ **Note:** the fnSetFilteringDelay() call isn't required but highly recommended: http://datatables.net/plug-ins/api#fnSetFilteringDelay
23
+
24
+ ### Model
25
+
26
+ ```ruby
27
+ class Provider
28
+
29
+ include Mongoid::Documenta
30
+ include Mongoid::DataTable
31
+
32
+ ## fields ##
33
+ field :name
34
+ field :fein
35
+ field :country
36
+ field :state
37
+
38
+ ## associations ##
39
+ referenced_in :category
40
+
41
+ ## data_table ##
42
+ data_table_options.merge!({
43
+ :fields => %w(name fein category country state),
44
+ :searchable => %w(name fein),
45
+ :dataset => lambda do |provider|
46
+ {
47
+ 0 => "<%= link_to(provider.name, provider) %>",
48
+ 1 => provider.fein,
49
+ 2 => provider.category.name,
50
+ 3 => provider.country,
51
+ 4 => provider.state,
52
+ :DT_RowId => provider._id
53
+ }
54
+ end
55
+ })
56
+
57
+ end
58
+ ```
59
+
60
+ ### Controller (InheritedResources::Base)
61
+
62
+ **Recommended:** https://github.com/josevalim/inherited_resources
63
+
64
+ ```ruby
65
+ class PrividersController < InheritedResources::Base
66
+
67
+ respond_to :json, :only => :index
68
+
69
+ protected
70
+
71
+ def collection
72
+ @providers ||= end_of_association_chain.to_data_table(self)
73
+ end
74
+
75
+ end
76
+ ```
77
+
78
+ ### Controller (ActionController::Base)
79
+
80
+ ```ruby
81
+ class ProvidersController < ApplicationController
82
+
83
+ def index
84
+ respond_to do |format|
85
+ format.html
86
+ format.json do
87
+ render :json => Provider.to_data_table(self)
88
+ end
89
+ end
90
+ end
91
+
92
+ end
93
+ ```
94
+
95
+ ### View (HAML)
96
+
97
+ ```haml
98
+ %table.providers-data-table
99
+ %thead
100
+ %tr
101
+ %th Name
102
+ %th FEIN
103
+ %th Category
104
+ %th County
105
+ %th State
106
+
107
+ %tbody
108
+ ```
109
+
110
+ Patches welcome, enjoy!
111
+
112
+ ## Copyright
113
+
114
+ Copyright &copy; 2010-2011 Jason Dew, Andrew Bennett. See LICENSE for details.
@@ -15,6 +15,8 @@ module Mongoid
15
15
  @unscoped = options[:unscoped] || klass.unscoped
16
16
  @fields = options[:fields] || klass.data_table_fields
17
17
  @aliases = options[:aliases] || @fields
18
+
19
+ params[:iDisplayLength] = conditions.count if params[:iDisplayLength] == -1
18
20
  end
19
21
 
20
22
  def collection(force = false)
@@ -33,7 +35,7 @@ module Mongoid
33
35
  end
34
36
 
35
37
  def per_page
36
- (params[:iDisplayLength] || klass.per_page rescue 10).to_i
38
+ (params[:iDisplayLength] || options[:per_page] || klass.per_page rescue 10).to_i
37
39
  end
38
40
 
39
41
  def conditions
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module DataTable
3
- VERSION = "1.0.4"
3
+ VERSION = "1.0.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mongoid-data_table
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.4
5
+ version: 1.0.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jason Dew
@@ -11,11 +11,10 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-05-23 00:00:00 Z
14
+ date: 2011-06-08 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
18
- prerelease: false
19
18
  requirement: &id001 !ruby/object:Gem::Requirement
20
19
  none: false
21
20
  requirements:
@@ -23,10 +22,10 @@ dependencies:
23
22
  - !ruby/object:Gem::Version
24
23
  version: 3.0.0
25
24
  type: :runtime
25
+ prerelease: false
26
26
  version_requirements: *id001
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: kaminari
29
- prerelease: false
30
29
  requirement: &id002 !ruby/object:Gem::Requirement
31
30
  none: false
32
31
  requirements:
@@ -34,10 +33,10 @@ dependencies:
34
33
  - !ruby/object:Gem::Version
35
34
  version: 0.12.4
36
35
  type: :runtime
36
+ prerelease: false
37
37
  version_requirements: *id002
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: bson_ext
40
- prerelease: false
41
40
  requirement: &id003 !ruby/object:Gem::Requirement
42
41
  none: false
43
42
  requirements:
@@ -45,10 +44,10 @@ dependencies:
45
44
  - !ruby/object:Gem::Version
46
45
  version: 1.3.1
47
46
  type: :development
47
+ prerelease: false
48
48
  version_requirements: *id003
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: mongoid
51
- prerelease: false
52
51
  requirement: &id004 !ruby/object:Gem::Requirement
53
52
  none: false
54
53
  requirements:
@@ -56,10 +55,10 @@ dependencies:
56
55
  - !ruby/object:Gem::Version
57
56
  version: 2.0.2
58
57
  type: :development
58
+ prerelease: false
59
59
  version_requirements: *id004
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: mocha
62
- prerelease: false
63
62
  requirement: &id005 !ruby/object:Gem::Requirement
64
63
  none: false
65
64
  requirements:
@@ -67,10 +66,10 @@ dependencies:
67
66
  - !ruby/object:Gem::Version
68
67
  version: 0.9.12
69
68
  type: :development
69
+ prerelease: false
70
70
  version_requirements: *id005
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: rspec
73
- prerelease: false
74
73
  requirement: &id006 !ruby/object:Gem::Requirement
75
74
  none: false
76
75
  requirements:
@@ -78,10 +77,10 @@ dependencies:
78
77
  - !ruby/object:Gem::Version
79
78
  version: 2.6.0
80
79
  type: :development
80
+ prerelease: false
81
81
  version_requirements: *id006
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: shoulda
84
- prerelease: false
85
84
  requirement: &id007 !ruby/object:Gem::Requirement
86
85
  none: false
87
86
  requirements:
@@ -89,10 +88,10 @@ dependencies:
89
88
  - !ruby/object:Gem::Version
90
89
  version: 2.11.3
91
90
  type: :development
91
+ prerelease: false
92
92
  version_requirements: *id007
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: watchr
95
- prerelease: false
96
95
  requirement: &id008 !ruby/object:Gem::Requirement
97
96
  none: false
98
97
  requirements:
@@ -100,6 +99,7 @@ dependencies:
100
99
  - !ruby/object:Gem::Version
101
100
  version: "0.7"
102
101
  type: :development
102
+ prerelease: false
103
103
  version_requirements: *id008
104
104
  description: Simple data preparation from Mongoid to the jQuery DataTables plugin
105
105
  email:
@@ -118,7 +118,7 @@ files:
118
118
  - Gemfile
119
119
  - Gemfile.lock
120
120
  - LICENSE
121
- - README.rdoc
121
+ - README.md
122
122
  - Rakefile
123
123
  - lib/mongoid-data_table.rb
124
124
  - lib/mongoid/data_table.rb
@@ -146,17 +146,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
146
  requirements:
147
147
  - - ">="
148
148
  - !ruby/object:Gem::Version
149
+ hash: 2570707088203796240
150
+ segments:
151
+ - 0
149
152
  version: "0"
150
153
  required_rubygems_version: !ruby/object:Gem::Requirement
151
154
  none: false
152
155
  requirements:
153
156
  - - ">="
154
157
  - !ruby/object:Gem::Version
158
+ hash: 2570707088203796240
159
+ segments:
160
+ - 0
155
161
  version: "0"
156
162
  requirements: []
157
163
 
158
164
  rubyforge_project:
159
- rubygems_version: 1.8.3
165
+ rubygems_version: 1.8.5
160
166
  signing_key:
161
167
  specification_version: 3
162
168
  summary: Simple data preparation from Mongoid to the jQuery DataTables plugin
data/README.rdoc DELETED
@@ -1,105 +0,0 @@
1
- = Mongoid: Data Table
2
-
3
- Makes it easy to ship data to a jQuery DataTable from Mongoid.
4
-
5
- == Quick example:
6
-
7
- === Javascript
8
-
9
- $(".providers-data-table").dataTable({
10
- "bJQueryUI" : true,
11
- "bProcessing" : true,
12
- "bAutoWidth" : false,
13
- "sPaginationType" : "full_numbers",
14
- "aoColumns" : [{"sType" : "html"}, null, null, null, null],
15
- "aaSorting" : [[0, 'asc'], [1, 'asc']],
16
- "bServerSide" : true,
17
- "sAjaxSource" : "/providers.json"
18
- }).fnSetFilteringDelay();
19
-
20
- *Note:* the fnSetFilteringDelay() call isn't required but highly recommended: http://datatables.net/plug-ins/api#fnSetFilteringDelay
21
-
22
- === Model
23
-
24
- class Provider
25
-
26
- include Mongoid::Documenta
27
- include Mongoid::DataTable
28
-
29
- ## fields ##
30
- field :name
31
- field :fein
32
- field :country
33
- field :state
34
-
35
- ## associations ##
36
- referenced_in :category
37
-
38
- ## data_table ##
39
- data_table_options.merge!({
40
- :fields => %w(name fein category country state),
41
- :searchable => %w(name fein),
42
- :dataset => lambda do |provider|
43
- {
44
- 0 => "<%= link_to(provider.name, provider) %>",
45
- 1 => provider.fein,
46
- 2 => provider.category.name,
47
- 3 => provider.country,
48
- 4 => provider.state,
49
- :DT_RowId => provider._id
50
- }
51
- end
52
- })
53
-
54
- end
55
-
56
- === Controller (InheritedResources::Base)
57
-
58
- *Recommended:* https://github.com/josevalim/inherited_resources
59
-
60
- class PrividersController < InheritedResources::Base
61
-
62
- respond_to :json, :only => :index
63
-
64
- protected
65
-
66
- def collection
67
- @providers ||= end_of_association_chain.to_data_table(self)
68
- end
69
-
70
- end
71
-
72
- === Controller (ActionController::Base)
73
-
74
- class ProvidersController < ApplicationController
75
-
76
- def index
77
- respond_to do |format|
78
- format.html
79
- format.json do
80
- render :json => Provider.to_data_table(self)
81
- end
82
- end
83
- end
84
-
85
- end
86
-
87
-
88
- === View (HAML)
89
-
90
- %table.providers-data-table
91
- %thead
92
- %tr
93
- %th Name
94
- %th FEIN
95
- %th Category
96
- %th County
97
- %th State
98
-
99
- %tbody
100
-
101
- Patches welcome, enjoy!
102
-
103
- == Copyright
104
-
105
- Copyright (c) 2010-2011 Jason Dew, Andrew Bennett. See LICENSE for details.