sortable-table 0.1.0 → 0.1.1

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: a955921e2db9b9ed641b8747366ba2e28f0a3fca
4
- data.tar.gz: 68cc86e153706bf32411c61536197b5d6fcd913e
3
+ metadata.gz: aba999a67bdf3d1a0066095391f9821525141a32
4
+ data.tar.gz: 9a05d9b5ce69b6e7233412fd2db0849643240ec2
5
5
  SHA512:
6
- metadata.gz: a7fbebbb2210f86fc87eaa3a5fb55240a3b0f6be5293f33e06fa98f2f754a5f29ff471f59b3fc92280af68e9daa84f1bb960e63d5fba98d094cee517de6b1cfc
7
- data.tar.gz: 30a48be0ec2089ccbbadf651f61184152fddd46d6ff6c8054e4a30cf734b0e6caaff4a8eed752f6358d2bc7f633472c148871b77ac17761f7b01dc45e8f74b6f
6
+ metadata.gz: d50db3465e7de283f2b2c3ef256bb2f50a50282cdd2165e6675bcb6529d063cccad4c745f0dcff829be81956d78d3f9d524e54650f9372d99acb37c93e607642
7
+ data.tar.gz: 1784df03d14167d2b4f30133727679b96aa87b852813554afa73db1a96dcc8c03ac6b6c83109737453b3b22f0f65f0a3d60a23b731eb18e1e15f41cb56ed8f6a
@@ -1,16 +1,22 @@
1
1
  module SortableTable
2
2
  module ActionViewExtension
3
3
  def sort_by(column, options = {})
4
- current_column = options[:current_column] || SortableTable::SortColumn.new(nil, nil)
5
- title = options[:title] || column.titleize
6
- prefix = options[:prefix]
4
+ current_column = options.delete(:current_column) || SortableTable::SortColumn.new(nil, nil)
5
+ title = options.delete(:title) || column.titleize
6
+ prefix = options.delete(:prefix)
7
7
  is_current_column = column == current_column.column
8
- css_class = is_current_column ? "current #{current_column.direction}" : nil
8
+ options_class = options.delete(:class)
9
+ css_class = is_current_column ? "current #{current_column.direction} #{options_class}" : options_class
9
10
  direction = is_current_column && current_column.direction == 'asc' ? 'desc' : 'asc'
10
- link_to title, params.merge("#{prefix}sort" => column,
11
+ sort_params = { "#{prefix}sort" => column,
11
12
  "#{prefix}direction" => direction,
12
- "#{prefix}page" => nil),
13
- class: css_class
13
+ "#{prefix}page" => nil }
14
+ if options.has_key?(:route_method)
15
+ goto = options.delete(:route_method).call sort_params
16
+ else
17
+ goto = params.merge( sort_params )
18
+ end
19
+ link_to title, goto, options.merge( {class: css_class } )
14
20
  end
15
21
  end
16
- end
22
+ end
@@ -12,7 +12,7 @@ module SortableTable
12
12
  end
13
13
 
14
14
  def sort_column(column, direction)
15
- column_definition = column_definitions[column] || column_definitions[default_column]
15
+ column_definition = column_definitions[column] || (column && column_definitions[column.to_sym]) || column_definitions[default_column]
16
16
  column_definition.create_sort_column(direction || default_direction.to_s)
17
17
  end
18
18
  end
@@ -1,3 +1,3 @@
1
1
  module SortableTable
2
- VERSION = '0.1.0'
3
- end
2
+ VERSION = '0.1.1'
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sortable-table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Mitchell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-11 00:00:00.000000000 Z
11
+ date: 2016-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  version: '0'
159
159
  requirements: []
160
160
  rubyforge_project:
161
- rubygems_version: 2.0.14
161
+ rubygems_version: 2.0.15
162
162
  signing_key:
163
163
  specification_version: 4
164
164
  summary: Sort HTML table columns
@@ -171,4 +171,3 @@ test_files:
171
171
  - spec/models/sort_column_spec.rb
172
172
  - spec/models/sort_table_spec.rb
173
173
  - spec/spec_helper.rb
174
- has_rdoc: