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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aba999a67bdf3d1a0066095391f9821525141a32
|
4
|
+
data.tar.gz: 9a05d9b5ce69b6e7233412fd2db0849643240ec2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
5
|
-
title = options
|
6
|
-
prefix = options
|
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
|
-
|
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
|
-
|
11
|
+
sort_params = { "#{prefix}sort" => column,
|
11
12
|
"#{prefix}direction" => direction,
|
12
|
-
"#{prefix}page" => nil
|
13
|
-
|
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.
|
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.
|
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:
|
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.
|
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:
|