paginated_table 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  module PaginatedTable
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -60572,3 +60572,308 @@ Processing by DataController#index as HTML
60572
60572
  Rendered data/_data.html.erb (6.9ms)
60573
60573
  Rendered data/index.html.erb within layouts/application (7.2ms)
60574
60574
  Completed 200 OK in 8ms (Views: 8.0ms)
60575
+
60576
+
60577
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:44 -0400 2012
60578
+ Processing by DataController#index as HTML
60579
+ Rendered data/_data.html.erb (16.0ms)
60580
+ Rendered data/index.html.erb within layouts/application (19.1ms)
60581
+ Completed 200 OK in 79ms (Views: 78.7ms)
60582
+
60583
+
60584
+ Started GET "/assets/application.css" for 127.0.0.1 at Thu May 03 14:03:44 -0400 2012
60585
+ Served asset /application.css - 200 OK (3ms)
60586
+
60587
+
60588
+ Started GET "/assets/application.js" for 127.0.0.1 at Thu May 03 14:03:44 -0400 2012
60589
+ Compiled application.js (8ms) (pid 68058)
60590
+ Served asset /application.js - 200 OK (20ms)
60591
+
60592
+
60593
+ Started GET "/data?page=4&per_page=10&sort_column=id&sort_direction=asc" for 127.0.0.1 at Thu May 03 14:03:44 -0400 2012
60594
+ Processing by DataController#index as JS
60595
+ Parameters: {"per_page"=>"10", "sort_direction"=>"asc", "sort_column"=>"id", "page"=>"4"}
60596
+ Rendered data/_data.html.erb (7.5ms)
60597
+ Completed 200 OK in 10ms (Views: 10.1ms)
60598
+
60599
+
60600
+ Started GET "/data?page=3&per_page=10&sort_column=id&sort_direction=asc" for 127.0.0.1 at Thu May 03 14:03:44 -0400 2012
60601
+ Processing by DataController#index as JS
60602
+ Parameters: {"per_page"=>"10", "sort_direction"=>"asc", "sort_column"=>"id", "page"=>"3"}
60603
+ Rendered data/_data.html.erb (7.2ms)
60604
+ Completed 200 OK in 8ms (Views: 7.6ms)
60605
+
60606
+
60607
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:45 -0400 2012
60608
+ Processing by DataController#index as HTML
60609
+ Rendered data/_data.html.erb (44.3ms)
60610
+ Rendered data/index.html.erb within layouts/application (44.6ms)
60611
+ Completed 200 OK in 46ms (Views: 45.7ms)
60612
+
60613
+
60614
+ Started GET "/data?page=2&per_page=10&sort_column=id&sort_direction=asc" for 127.0.0.1 at Thu May 03 14:03:45 -0400 2012
60615
+ Processing by DataController#index as JS
60616
+ Parameters: {"per_page"=>"10", "sort_direction"=>"asc", "sort_column"=>"id", "page"=>"2"}
60617
+ Rendered data/_data.html.erb (6.6ms)
60618
+ Completed 200 OK in 7ms (Views: 7.0ms)
60619
+
60620
+
60621
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:45 -0400 2012
60622
+ Processing by DataController#index as HTML
60623
+ Rendered data/_data.html.erb (6.8ms)
60624
+ Rendered data/index.html.erb within layouts/application (7.0ms)
60625
+ Completed 200 OK in 8ms (Views: 8.1ms)
60626
+
60627
+
60628
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:45 -0400 2012
60629
+ Processing by DataController#index as HTML
60630
+ Rendered data/_data.html.erb (6.1ms)
60631
+ Rendered data/index.html.erb within layouts/application (6.3ms)
60632
+ Completed 200 OK in 8ms (Views: 7.4ms)
60633
+
60634
+
60635
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:45 -0400 2012
60636
+ Processing by DataController#index as HTML
60637
+ Rendered data/_data.html.erb (6.1ms)
60638
+ Rendered data/index.html.erb within layouts/application (6.3ms)
60639
+ Completed 200 OK in 8ms (Views: 7.4ms)
60640
+
60641
+
60642
+ Started GET "/data?per_page=10&page=2&sort_column=id&sort_direction=asc" for 127.0.0.1 at Thu May 03 14:03:45 -0400 2012
60643
+ Processing by DataController#index as HTML
60644
+ Parameters: {"per_page"=>"10", "sort_direction"=>"asc", "sort_column"=>"id", "page"=>"2"}
60645
+ Rendered data/_data.html.erb (7.6ms)
60646
+ Rendered data/index.html.erb within layouts/application (7.9ms)
60647
+ Completed 200 OK in 9ms (Views: 8.8ms)
60648
+
60649
+
60650
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:45 -0400 2012
60651
+ Processing by DataController#index as HTML
60652
+ Rendered data/_data.html.erb (6.8ms)
60653
+ Rendered data/index.html.erb within layouts/application (7.0ms)
60654
+ Completed 200 OK in 8ms (Views: 8.1ms)
60655
+
60656
+
60657
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:45 -0400 2012
60658
+ Processing by DataController#index as HTML
60659
+ Rendered data/_data.html.erb (6.9ms)
60660
+ Rendered data/index.html.erb within layouts/application (7.2ms)
60661
+ Completed 200 OK in 9ms (Views: 8.4ms)
60662
+
60663
+
60664
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:45 -0400 2012
60665
+ Processing by DataController#index as HTML
60666
+ Rendered data/_data.html.erb (6.1ms)
60667
+ Rendered data/index.html.erb within layouts/application (6.3ms)
60668
+ Completed 200 OK in 8ms (Views: 7.3ms)
60669
+
60670
+
60671
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:45 -0400 2012
60672
+ Processing by DataController#index as HTML
60673
+ Rendered data/_data.html.erb (6.3ms)
60674
+ Rendered data/index.html.erb within layouts/application (6.5ms)
60675
+ Completed 200 OK in 8ms (Views: 7.5ms)
60676
+
60677
+
60678
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:45 -0400 2012
60679
+ Processing by DataController#index as HTML
60680
+ Rendered data/_data.html.erb (7.0ms)
60681
+ Rendered data/index.html.erb within layouts/application (7.2ms)
60682
+ Completed 200 OK in 8ms (Views: 8.3ms)
60683
+
60684
+
60685
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:45 -0400 2012
60686
+ Processing by DataController#index as HTML
60687
+ Rendered data/_data.html.erb (6.2ms)
60688
+ Rendered data/index.html.erb within layouts/application (6.4ms)
60689
+ Completed 200 OK in 8ms (Views: 7.4ms)
60690
+
60691
+
60692
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:45 -0400 2012
60693
+ Processing by DataController#index as HTML
60694
+ Rendered data/_data.html.erb (50.2ms)
60695
+ Rendered data/index.html.erb within layouts/application (50.5ms)
60696
+ Completed 200 OK in 52ms (Views: 51.6ms)
60697
+
60698
+
60699
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:45 -0400 2012
60700
+ Processing by DataController#index as HTML
60701
+ Rendered data/_data.html.erb (6.5ms)
60702
+ Rendered data/index.html.erb within layouts/application (6.8ms)
60703
+ Completed 200 OK in 8ms (Views: 7.8ms)
60704
+
60705
+
60706
+ Started GET "/data?page=2&per_page=10&sort_column=id&sort_direction=asc" for 127.0.0.1 at Thu May 03 14:03:45 -0400 2012
60707
+ Processing by DataController#index as JS
60708
+ Parameters: {"per_page"=>"10", "sort_direction"=>"asc", "sort_column"=>"id", "page"=>"2"}
60709
+ Rendered data/_data.html.erb (6.6ms)
60710
+ Completed 200 OK in 7ms (Views: 7.0ms)
60711
+
60712
+
60713
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:47 -0400 2012
60714
+ Processing by DataController#index as HTML
60715
+ Rendered data/_data.html.erb (7.5ms)
60716
+ Rendered data/index.html.erb within layouts/application (7.7ms)
60717
+ Completed 200 OK in 9ms (Views: 8.8ms)
60718
+
60719
+
60720
+ Started GET "/data?per_page=10&page=1&sort_column=name&sort_direction=asc" for 127.0.0.1 at Thu May 03 14:03:47 -0400 2012
60721
+ Processing by DataController#index as HTML
60722
+ Parameters: {"per_page"=>"10", "sort_direction"=>"asc", "sort_column"=>"name", "page"=>"1"}
60723
+ Rendered data/_data.html.erb (6.9ms)
60724
+ Rendered data/index.html.erb within layouts/application (7.3ms)
60725
+ Completed 200 OK in 9ms (Views: 8.3ms)
60726
+
60727
+
60728
+ Started GET "/data?per_page=10&page=1&sort_column=name&sort_direction=desc" for 127.0.0.1 at Thu May 03 14:03:47 -0400 2012
60729
+ Processing by DataController#index as HTML
60730
+ Parameters: {"per_page"=>"10", "sort_direction"=>"desc", "sort_column"=>"name", "page"=>"1"}
60731
+ Rendered data/_data.html.erb (50.1ms)
60732
+ Rendered data/index.html.erb within layouts/application (50.3ms)
60733
+ Completed 200 OK in 52ms (Views: 51.4ms)
60734
+
60735
+
60736
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:47 -0400 2012
60737
+ Processing by DataController#index as HTML
60738
+ Rendered data/_data.html.erb (6.1ms)
60739
+ Rendered data/index.html.erb within layouts/application (6.3ms)
60740
+ Completed 200 OK in 8ms (Views: 7.4ms)
60741
+
60742
+
60743
+ Started GET "/data?per_page=10&page=1&sort_column=name&sort_direction=asc" for 127.0.0.1 at Thu May 03 14:03:47 -0400 2012
60744
+ Processing by DataController#index as HTML
60745
+ Parameters: {"per_page"=>"10", "sort_direction"=>"asc", "sort_column"=>"name", "page"=>"1"}
60746
+ Rendered data/_data.html.erb (5.9ms)
60747
+ Rendered data/index.html.erb within layouts/application (6.2ms)
60748
+ Completed 200 OK in 8ms (Views: 7.2ms)
60749
+
60750
+
60751
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:47 -0400 2012
60752
+ Processing by DataController#index as HTML
60753
+ Rendered data/_data.html.erb (6.8ms)
60754
+ Rendered data/index.html.erb within layouts/application (7.0ms)
60755
+ Completed 200 OK in 8ms (Views: 8.0ms)
60756
+
60757
+
60758
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:47 -0400 2012
60759
+ Processing by DataController#index as HTML
60760
+ Rendered data/_data.html.erb (7.9ms)
60761
+ Rendered data/index.html.erb within layouts/application (8.2ms)
60762
+ Completed 200 OK in 9ms (Views: 9.2ms)
60763
+
60764
+
60765
+ Started GET "/data?page=1&per_page=10&sort_column=name&sort_direction=asc" for 127.0.0.1 at Thu May 03 14:03:47 -0400 2012
60766
+ Processing by DataController#index as JS
60767
+ Parameters: {"per_page"=>"10", "sort_direction"=>"asc", "sort_column"=>"name", "page"=>"1"}
60768
+ Rendered data/_data.html.erb (6.2ms)
60769
+ Completed 200 OK in 7ms (Views: 6.6ms)
60770
+
60771
+
60772
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:47 -0400 2012
60773
+ Processing by DataController#index as HTML
60774
+ Rendered data/_data.html.erb (6.5ms)
60775
+ Rendered data/index.html.erb within layouts/application (6.8ms)
60776
+ Completed 200 OK in 8ms (Views: 7.8ms)
60777
+
60778
+
60779
+ Started GET "/data?page=1&per_page=10&sort_column=name&sort_direction=asc" for 127.0.0.1 at Thu May 03 14:03:47 -0400 2012
60780
+ Processing by DataController#index as JS
60781
+ Parameters: {"per_page"=>"10", "sort_direction"=>"asc", "sort_column"=>"name", "page"=>"1"}
60782
+ Rendered data/_data.html.erb (6.2ms)
60783
+ Completed 200 OK in 7ms (Views: 6.7ms)
60784
+
60785
+
60786
+ Started GET "/data?page=2&per_page=10&sort_column=name&sort_direction=asc" for 127.0.0.1 at Thu May 03 14:03:47 -0400 2012
60787
+ Processing by DataController#index as JS
60788
+ Parameters: {"per_page"=>"10", "sort_direction"=>"asc", "sort_column"=>"name", "page"=>"2"}
60789
+ Rendered data/_data.html.erb (7.1ms)
60790
+ Completed 200 OK in 8ms (Views: 7.6ms)
60791
+
60792
+
60793
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:48 -0400 2012
60794
+ Processing by DataController#index as HTML
60795
+ Rendered data/_data.html.erb (6.9ms)
60796
+ Rendered data/index.html.erb within layouts/application (7.1ms)
60797
+ Completed 200 OK in 8ms (Views: 8.2ms)
60798
+
60799
+
60800
+ Started GET "/data?page=1&per_page=10&sort_column=name&sort_direction=asc" for 127.0.0.1 at Thu May 03 14:03:48 -0400 2012
60801
+ Processing by DataController#index as JS
60802
+ Parameters: {"per_page"=>"10", "sort_direction"=>"asc", "sort_column"=>"name", "page"=>"1"}
60803
+ Rendered data/_data.html.erb (6.7ms)
60804
+ Completed 200 OK in 7ms (Views: 7.1ms)
60805
+
60806
+
60807
+ Started GET "/data?page=1&per_page=10&sort_column=name&sort_direction=desc" for 127.0.0.1 at Thu May 03 14:03:48 -0400 2012
60808
+ Processing by DataController#index as JS
60809
+ Parameters: {"per_page"=>"10", "sort_direction"=>"desc", "sort_column"=>"name", "page"=>"1"}
60810
+ Rendered data/_data.html.erb (50.3ms)
60811
+ Completed 200 OK in 51ms (Views: 51.0ms)
60812
+
60813
+
60814
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:48 -0400 2012
60815
+ Processing by DataController#index as HTML
60816
+ Rendered data/_data.html.erb (6.1ms)
60817
+ Rendered data/index.html.erb within layouts/application (6.4ms)
60818
+ Completed 200 OK in 8ms (Views: 7.5ms)
60819
+
60820
+
60821
+ Started GET "/data?per_page=10&page=1&sort_column=name&sort_direction=asc" for 127.0.0.1 at Thu May 03 14:03:48 -0400 2012
60822
+ Processing by DataController#index as HTML
60823
+ Parameters: {"per_page"=>"10", "sort_direction"=>"asc", "sort_column"=>"name", "page"=>"1"}
60824
+ Rendered data/_data.html.erb (6.0ms)
60825
+ Rendered data/index.html.erb within layouts/application (6.3ms)
60826
+ Completed 200 OK in 8ms (Views: 7.4ms)
60827
+
60828
+
60829
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:48 -0400 2012
60830
+ Processing by DataController#index as HTML
60831
+ Rendered data/_data.html.erb (7.4ms)
60832
+ Rendered data/index.html.erb within layouts/application (7.7ms)
60833
+ Completed 200 OK in 9ms (Views: 8.7ms)
60834
+
60835
+
60836
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:48 -0400 2012
60837
+ Processing by DataController#index as HTML
60838
+ Rendered data/_data.html.erb (6.0ms)
60839
+ Rendered data/index.html.erb within layouts/application (6.3ms)
60840
+ Completed 200 OK in 8ms (Views: 7.3ms)
60841
+
60842
+
60843
+ Started GET "/data?per_page=10&page=1&sort_column=name&sort_direction=asc" for 127.0.0.1 at Thu May 03 14:03:48 -0400 2012
60844
+ Processing by DataController#index as HTML
60845
+ Parameters: {"per_page"=>"10", "sort_direction"=>"asc", "sort_column"=>"name", "page"=>"1"}
60846
+ Rendered data/_data.html.erb (49.9ms)
60847
+ Rendered data/index.html.erb within layouts/application (50.2ms)
60848
+ Completed 200 OK in 52ms (Views: 51.3ms)
60849
+
60850
+
60851
+ Started GET "/data?per_page=10&page=1&sort_column=name&sort_direction=desc" for 127.0.0.1 at Thu May 03 14:03:48 -0400 2012
60852
+ Processing by DataController#index as HTML
60853
+ Parameters: {"per_page"=>"10", "sort_direction"=>"desc", "sort_column"=>"name", "page"=>"1"}
60854
+ Rendered data/_data.html.erb (6.1ms)
60855
+ Rendered data/index.html.erb within layouts/application (6.3ms)
60856
+ Completed 200 OK in 8ms (Views: 7.3ms)
60857
+
60858
+
60859
+ Started GET "/data" for 127.0.0.1 at Thu May 03 14:03:48 -0400 2012
60860
+ Processing by DataController#index as HTML
60861
+ Rendered data/_data.html.erb (6.4ms)
60862
+ Rendered data/index.html.erb within layouts/application (6.7ms)
60863
+ Completed 200 OK in 8ms (Views: 7.7ms)
60864
+
60865
+
60866
+ Started GET "/data?per_page=10&page=1&sort_column=name&sort_direction=asc" for 127.0.0.1 at Thu May 03 14:03:48 -0400 2012
60867
+ Processing by DataController#index as HTML
60868
+ Parameters: {"per_page"=>"10", "sort_direction"=>"asc", "sort_column"=>"name", "page"=>"1"}
60869
+ Rendered data/_data.html.erb (6.8ms)
60870
+ Rendered data/index.html.erb within layouts/application (7.0ms)
60871
+ Completed 200 OK in 8ms (Views: 8.0ms)
60872
+
60873
+
60874
+ Started GET "/data?per_page=10&page=2&sort_column=name&sort_direction=asc" for 127.0.0.1 at Thu May 03 14:03:48 -0400 2012
60875
+ Processing by DataController#index as HTML
60876
+ Parameters: {"per_page"=>"10", "sort_direction"=>"asc", "sort_column"=>"name", "page"=>"2"}
60877
+ Rendered data/_data.html.erb (7.2ms)
60878
+ Rendered data/index.html.erb within layouts/application (7.4ms)
60879
+ Completed 200 OK in 9ms (Views: 8.5ms)
@@ -0,0 +1,7 @@
1
+ (function($) {
2
+ $(document).ready(function() {
3
+ $("div.paginated_table a[data-remote='true']").live('ajax:success', function(event, data, status, xhr) {
4
+ $(this).parents('div.paginated_table').replaceWith(xhr.responseText);
5
+ });
6
+ });
7
+ })(jQuery);
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paginated_table
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Donald Ball
@@ -51,12 +51,13 @@ dependencies:
51
51
  version_requirements: &id003 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
- - - ">="
54
+ - - ~>
55
55
  - !ruby/object:Gem::Version
56
56
  hash: 3
57
57
  segments:
58
+ - 2
58
59
  - 0
59
- version: "0"
60
+ version: "2.0"
60
61
  prerelease: false
61
62
  type: :runtime
62
63
  name: jquery-rails
@@ -127,6 +128,7 @@ extensions: []
127
128
  extra_rdoc_files: []
128
129
 
129
130
  files:
131
+ - lib/paginated_table.rb
130
132
  - lib/paginated_table/config.rb
131
133
  - lib/paginated_table/controller_helpers.rb
132
134
  - lib/paginated_table/engine.rb
@@ -134,11 +136,7 @@ files:
134
136
  - lib/paginated_table/railtie.rb
135
137
  - lib/paginated_table/version.rb
136
138
  - lib/paginated_table/view_helpers.rb
137
- - lib/paginated_table.rb
138
- - lib/tasks/paginated_table_tasks.rake
139
- - MIT-LICENSE
140
- - Rakefile
141
- - README.md
139
+ - vendor/assets/javascripts/paginated_table.js
142
140
  - test/dummy/app/assets/javascripts/application.js
143
141
  - test/dummy/app/assets/stylesheets/application.css
144
142
  - test/dummy/app/controllers/application_controller.rb
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright 2012 YOURNAME
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md DELETED
@@ -1,158 +0,0 @@
1
- # PaginatedTable
2
-
3
- [![Build Status](https://secure.travis-ci.org/dball/paginated_table.png)](http://travis-ci.org/dball/paginated_table)
4
-
5
- PaginatedTable is a Rails plugin that makes rendering paginated, sorted
6
- HTML tables dead simple.
7
-
8
- ## Requirements
9
-
10
- * rails 3.2 (3.1 may work)
11
- * will_paginate 3.0
12
- * jquery-rails
13
-
14
- ## Installation
15
-
16
- Add `paginated_table` to your `Gemfile` and `bundle install`.
17
-
18
- Add the `paginated_table` javascript to your application's javascript
19
- requires after `jquery` and `jquery_ujs`:
20
-
21
- //= require jquery
22
- //= require jquery_ujs
23
- //= require paginated_table
24
-
25
- ## Usage
26
-
27
- PaginatedTable mixes helper methods into ActionController::Base and
28
- ActionView::Base, conveniently named `paginated_table`.
29
-
30
- ### Controller
31
-
32
- The `paginated_table` helper is an instance method you can call in an
33
- action that paginates a table:
34
-
35
- class ProductsController < ApplicationController
36
- def index
37
- paginated_table :products => Product.all
38
- end
39
- end
40
-
41
- This will sort the collection using Arel's order method, paginate
42
- the given collection using will_paginate, store the
43
- page in an instance variable with the name of the hash key, e.g.
44
- `@products`, and if the request is AJAX, renders a partial response.
45
-
46
- ### View
47
-
48
- The `paginated_table` helper is an instance method you can call in a
49
- view that renders a paginated table. To work with the AJAX pagination,
50
- the call must appear in a partial with the same name as the table's
51
- instance variable, e.g. `products.html.erb`. Thus, we might have:
52
-
53
- In `index.html.erb`:
54
-
55
- <h1>Products</h1>
56
-
57
- <%= render :partial => 'products' %>
58
-
59
- and in `products.html.erb`:
60
-
61
- <%= paginated_table(@products) do |table|
62
- table.column :name, :sortable => false
63
- table.column :price do |price|
64
- format_currency(price)
65
- end
66
- table.column :qty, :title => 'Quantity'
67
- end %>
68
-
69
- The `div.paginated_table` element on the page will be updated for successful
70
- AJAX responses.
71
-
72
- The table DSL provides a column method by which you describe the table.
73
- The column calls correspond to columns in the rendered table. Columns
74
- with no block send their name to the records to get their cell values, while
75
- columns with blocks yield to them the records to get their cell values.
76
- Columns are sortable by default, but may be rendered unsortable with the
77
- :sortable option set to false.
78
-
79
- The table gets a header row with titleized column names, and a
80
- wrapping header and footer with pagination info and links. The
81
- pagination links are decorated to be AJAX requests by jquery-rails, the
82
- results of which overwrite the paginated_table div. The column names
83
- corresponding to sortable columns are linked to sort the table
84
- ascending, then descending, restarting at the first page of the
85
- collection.
86
-
87
- ### Output
88
-
89
- <div class="paginated_table">
90
- <div class="header">
91
- <div class="info">
92
- ... will_paginate info ...
93
- </div>
94
- <div class="links">
95
- <div class="pagination">
96
- ... will_paginate links ...
97
- </div>
98
- </div>
99
- </div>
100
- <table class="paginated">
101
- <thead>
102
- <tr>
103
- <th class="sortable sorted_asc">...</th>
104
- <th class="sortable">...</th>
105
- </tr>
106
- </thead>
107
- <tbody>
108
- <tr>
109
- <td>...</td>
110
- <td>...</td>
111
- </tr>
112
- </tbody>
113
- </table>
114
- <div class="footer">
115
- <div class="info">
116
- ... will_paginate info ...
117
- </div>
118
- <div class="links">
119
- <div class="pagination">
120
- ... will_paginate links ...
121
- </div>
122
- </div>
123
- </div>
124
- </div>
125
-
126
- ### Global Configuration
127
-
128
- In an initializer, e.g. `config/initializers/paginated_table.rb`:
129
-
130
- PaginatedTable.configure do |config|
131
- config.rows_per_page = 20
132
- end
133
-
134
- ## TODO
135
-
136
- * AJAX links should be optional
137
-
138
- * AJAX busy indicator
139
-
140
- * AJAX error indicator
141
-
142
- * Partial should infer ivar by template name?
143
-
144
- * Escaped HTML leaks in the will_paginate links
145
-
146
- * Explicitly enable the :rows option
147
- * It really belongs in the view helper, but it's simpler to implement
148
- in the controller helper
149
-
150
- * Global configuration
151
- * AJAX links
152
-
153
- * :per_page request param should be allowed to be ignored or restricted
154
- to a configurable maximum
155
-
156
- * scope th header elements to column
157
-
158
- * allow column cells to render as th elements
data/Rakefile DELETED
@@ -1,38 +0,0 @@
1
- #!/usr/bin/env rake
2
- begin
3
- require 'bundler/setup'
4
- rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
- end
7
- begin
8
- require 'rdoc/task'
9
- rescue LoadError
10
- require 'rdoc/rdoc'
11
- require 'rake/rdoctask'
12
- RDoc::Task = Rake::RDocTask
13
- end
14
-
15
- RDoc::Task.new(:rdoc) do |rdoc|
16
- rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = 'PaginatedTable'
18
- rdoc.options << '--line-numbers'
19
- rdoc.rdoc_files.include('README.rdoc')
20
- rdoc.rdoc_files.include('lib/**/*.rb')
21
- end
22
-
23
-
24
-
25
-
26
- Bundler::GemHelper.install_tasks
27
-
28
- require 'rake/testtask'
29
-
30
- Rake::TestTask.new(:test) do |t|
31
- t.libs << 'lib'
32
- t.libs << 'test'
33
- t.pattern = 'test/**/*_test.rb'
34
- t.verbose = false
35
- end
36
-
37
-
38
- task :default => :test
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :paginated_table do
3
- # # Task goes here
4
- # end