handles_sortable_columns 0.1.1 → 0.1.2
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.
data/VERSION.yml
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{handles_sortable_columns}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Alex Fortuna"]
|
12
|
-
s.date = %q{2010-08
|
12
|
+
s.date = %q{2010-09-08}
|
13
13
|
s.description = %q{Sortable Table Columns}
|
14
14
|
s.email = %q{alex.r@askit.org}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.homepage = %q{http://github.com/dadooda/handles_sortable_columns}
|
30
30
|
s.rdoc_options = ["--charset=UTF-8"]
|
31
31
|
s.require_paths = ["lib"]
|
32
|
-
s.rubygems_version = %q{1.3.
|
32
|
+
s.rubygems_version = %q{1.3.7}
|
33
33
|
s.summary = %q{Sortable Table Columns}
|
34
34
|
s.test_files = [
|
35
35
|
"spec/handles_sortable_columns_spec.rb"
|
@@ -39,7 +39,7 @@ Gem::Specification.new do |s|
|
|
39
39
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
40
40
|
s.specification_version = 3
|
41
41
|
|
42
|
-
if Gem::Version.new(Gem::
|
42
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
43
43
|
else
|
44
44
|
end
|
45
45
|
else
|
@@ -203,6 +203,7 @@ module Handles #:nodoc:
|
|
203
203
|
# * <tt>:column</tt> -- Column name. E.g. <tt>"created_at"</tt>.
|
204
204
|
# * <tt>:direction</tt> -- Sort direction on first click. <tt>:asc</tt> or <tt>:desc</tt>. Default is <tt>:asc</tt>.
|
205
205
|
# * <tt>:class</tt> -- CSS class for link (regardless of sorted state).
|
206
|
+
# * <tt>:style</tt> -- CSS style for link (regardless of sorted state).
|
206
207
|
#
|
207
208
|
# Examples:
|
208
209
|
#
|
@@ -223,6 +224,7 @@ module Handles #:nodoc:
|
|
223
224
|
o[k = :column] = options.delete(k) || controller.class.sortable_column_name_from_title(title)
|
224
225
|
o[k = :direction] = options.delete(k).to_s.downcase =~ /\Adesc\z/ ? :desc : :asc
|
225
226
|
o[k = :class] = options.delete(k) || controller.class.sortable_columns_config[k]
|
227
|
+
o[k = :style] = options.delete(k)
|
226
228
|
#HELP /sortable_column
|
227
229
|
|
228
230
|
raise "Unknown option(s): #{options.inspect}" if not options.empty?
|
@@ -235,26 +237,33 @@ module Handles #:nodoc:
|
|
235
237
|
css_class << s
|
236
238
|
end
|
237
239
|
|
240
|
+
# If already sorted and indicator class defined, append it.
|
241
|
+
if pp[:column] == o[:column].to_s and (s = conf[:indicator_class][pp[:direction]]).present?
|
242
|
+
css_class << s
|
243
|
+
end
|
244
|
+
|
238
245
|
# Build link itself.
|
239
246
|
pcs = []
|
240
247
|
|
248
|
+
html_options = {}
|
249
|
+
html_options[:class] = css_class.join(" ") if css_class.present?
|
250
|
+
html_options[:style] = o[:style] if o[:style].present?
|
251
|
+
|
241
252
|
# Already sorted?
|
242
253
|
if pp[:column] == o[:column].to_s
|
243
|
-
|
244
|
-
css_class << s
|
245
|
-
end
|
246
|
-
|
247
|
-
pcs << link_to(title, params.merge({conf[:sort_param] => [("-" if pp[:direction] == :asc), o[:column]].join, conf[:page_param] => 1}), {:class => css_class.present?? css_class.join(" ") : nil}) # Opposite sort order when clicked.
|
254
|
+
pcs << link_to(title, params.merge({conf[:sort_param] => [("-" if pp[:direction] == :asc), o[:column]].join, conf[:page_param] => 1}), html_options) # Opposite sort order when clicked.
|
248
255
|
|
256
|
+
# Append indicator, if configured.
|
249
257
|
if (s = conf[:indicator_text][pp[:direction]]).present?
|
250
258
|
pcs << s
|
251
259
|
end
|
252
260
|
else
|
253
261
|
# Not sorted.
|
254
|
-
pcs << link_to(title, params.merge({conf[:sort_param] => [("-" if o[:direction] != :asc), o[:column]].join, conf[:page_param] => 1}),
|
262
|
+
pcs << link_to(title, params.merge({conf[:sort_param] => [("-" if o[:direction] != :asc), o[:column]].join, conf[:page_param] => 1}), html_options)
|
255
263
|
end
|
256
264
|
|
257
|
-
|
265
|
+
# For Rails 3 provide #html_safe.
|
266
|
+
(v = pcs.join).respond_to?(:html_safe) ? v.html_safe : v
|
258
267
|
end
|
259
268
|
end # HelperMethods
|
260
269
|
end # SortableColumns
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# Rails gem init.
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
|
3
|
+
# NOTE: Rails 3 seems to require exact order.
|
4
|
+
require File.join(File.dirname(__FILE__), "handles/sortable_columns")
|
5
|
+
require File.join(File.dirname(__FILE__), "action_controller/base/handles_sortable_columns")
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: handles_sortable_columns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 31
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Alex Fortuna
|
@@ -9,7 +15,7 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-08
|
18
|
+
date: 2010-09-08 00:00:00 +04:00
|
13
19
|
default_executable:
|
14
20
|
dependencies: []
|
15
21
|
|
@@ -31,6 +37,7 @@ files:
|
|
31
37
|
- lib/action_controller/base/handles_sortable_columns.rb
|
32
38
|
- lib/handles/sortable_columns.rb
|
33
39
|
- lib/handles_sortable_columns.rb
|
40
|
+
- spec/handles_sortable_columns_spec.rb
|
34
41
|
has_rdoc: true
|
35
42
|
homepage: http://github.com/dadooda/handles_sortable_columns
|
36
43
|
licenses: []
|
@@ -41,21 +48,27 @@ rdoc_options:
|
|
41
48
|
require_paths:
|
42
49
|
- lib
|
43
50
|
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
44
52
|
requirements:
|
45
53
|
- - ">="
|
46
54
|
- !ruby/object:Gem::Version
|
55
|
+
hash: 3
|
56
|
+
segments:
|
57
|
+
- 0
|
47
58
|
version: "0"
|
48
|
-
version:
|
49
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
50
61
|
requirements:
|
51
62
|
- - ">="
|
52
63
|
- !ruby/object:Gem::Version
|
64
|
+
hash: 3
|
65
|
+
segments:
|
66
|
+
- 0
|
53
67
|
version: "0"
|
54
|
-
version:
|
55
68
|
requirements: []
|
56
69
|
|
57
70
|
rubyforge_project:
|
58
|
-
rubygems_version: 1.3.
|
71
|
+
rubygems_version: 1.3.7
|
59
72
|
signing_key:
|
60
73
|
specification_version: 3
|
61
74
|
summary: Sortable Table Columns
|