sortablecolumns 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ === 0.1.4 / 2008-06-04
2
+ * Table heading (TH) urls now remove any parameter named "page". This is to support paginated tables
3
+ since, if a user is on a page other than 1, clicking on a column heading should sort all data and
4
+ revert back to page 1.
5
+ * Changed self.#{sorter_name}_col_text to return non-breaking space when nil or empty string.
6
+ (this is to force TD elements to be displayed when empty)
7
+
1
8
  === 0.1.3 / 2008-05-05
2
9
  * Minor test updates, doc updates
3
10
 
@@ -1,5 +1,5 @@
1
1
  module Sortablecolumns #:nodoc:
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
4
4
  Dir[File.join(File.dirname(__FILE__), "sortablecolumns/**/*.rb")].sort.each { |lib| require lib }
5
5
  ActiveRecord::Base.send(:include, ActiveRecord::Acts::Sortablecolumns)
@@ -160,6 +160,7 @@ module Sortablecolumns
160
160
  _params = params.dup
161
161
  _params[:order_by] = order_by
162
162
  _params[:dir] = dir
163
+ _params.delete(:page)
163
164
  url_for(_params)
164
165
  end
165
166
 
@@ -51,7 +51,13 @@ module ActiveRecord #:nodoc:
51
51
  end
52
52
 
53
53
  def self.#{sorter_name}_col_text(obj, col)
54
- return obj.send(col) if self.#{sorter_name}_in_resultset?(col)
54
+ if self.#{sorter_name}_in_resultset?(col)
55
+ ret = obj.send(col)
56
+ if ret == '' or ret.nil?
57
+ ret = " " #so empty TD cells still get displayed
58
+ end
59
+ return ret
60
+ end
55
61
  return self.#{sorter_name}_print_text(col)
56
62
  end
57
63
 
@@ -367,6 +367,7 @@ class SortablecolumnsHelperTest < Test::Unit::TestCase
367
367
 
368
368
  def test_print_col_person_lastname
369
369
  assert_equal '<td>Jones</td>', @view.print_col(@person, 'mysorter', 'lastname')
370
+ #while we're here, make sure we can use symbols or strings
370
371
  assert_equal '<td>Jones</td>', @view.print_col(@person, :mysorter, :lastname)
371
372
  end
372
373
 
@@ -464,9 +465,26 @@ class SortablecolumnsHelperTest < Test::Unit::TestCase
464
465
  @view.params[:dir] = 'desc'
465
466
  new_order = 'windshield_strength'
466
467
  new_dir = 'asc'
467
- _params = @view.params
468
468
  expected = "http://test.host/cars/wheels?bar=123&dir=asc&foo=blah&order_by=windshield_strength"
469
- #assert_equal expected, @view.get_url(new_order, new_dir, _params)
469
+ assert_equal expected, @view.get_url(new_order, new_dir)
470
+ end
471
+
472
+ def test_get_url_with_page
473
+ # If pagination is being used and a page param is in the url, it should be removed.
474
+ # That is, we don't want to sort the current page of results, we want to start
475
+ # back at the beginning (page 1) and sort that. Maybe make this customizable in
476
+ # the future.
477
+
478
+ @view.params[:controller] = 'cars'
479
+ @view.params[:action] = 'wheels'
480
+ @view.params[:foo] = 'blah'
481
+ @view.params[:bar] = '123'
482
+ @view.params[:order_by] = 'wheel_type'
483
+ @view.params[:dir] = 'desc'
484
+ @view.params[:page] = '2'
485
+ new_order = 'windshield_strength'
486
+ new_dir = 'asc'
487
+ expected = "http://test.host/cars/wheels?bar=123&dir=asc&foo=blah&order_by=windshield_strength"
470
488
  assert_equal expected, @view.get_url(new_order, new_dir)
471
489
  end
472
490
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sortablecolumns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Donovan - http://www.bryandonovan.com
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-05 00:00:00 -07:00
12
+ date: 2008-06-04 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 1.5.1
22
+ version: 1.5.3
23
23
  version:
24
24
  description: Sortable HTML tables for Rails
25
25
  email: b.dondo+rubyforge@gmail.com