rails-add_ons 1.5.0 → 1.5.1
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.
- checksums.yaml +4 -4
- data/app/helpers/rails/add_ons/table_helper.rb +31 -2
- data/lib/rails/add_ons/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 375b145ef8a6874f2302313a0e856f2e68a4f0f8
|
|
4
|
+
data.tar.gz: a03c5fc82df7b8506ba297aac49c59175d947204
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7515c6f65b75695b5352e75fbbffed27e5ffb280cf265cf341622e693ae7ce191d90694821f1533b9c91ecfd59f900b09db81f9029225c5575dfa50bdec494bb
|
|
7
|
+
data.tar.gz: bb8692f3a2db53b8787b9b629ee0e10f27cee08fd2036e93f0a11bfb1f9abee721367e306919af999845a6c1f7ea23ef47f79b73831e3566a765d5e79d2162bd
|
|
@@ -15,6 +15,9 @@ module Rails
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
class SortLink
|
|
18
|
+
ARROW_UP = '▲'
|
|
19
|
+
ARROW_DOWN = '▼'
|
|
20
|
+
|
|
18
21
|
def initialize(view_context, column_name, title, options)
|
|
19
22
|
default_options = {}
|
|
20
23
|
|
|
@@ -29,14 +32,24 @@ module Rails
|
|
|
29
32
|
@title = title
|
|
30
33
|
|
|
31
34
|
if h.params[:sort_direction].present?
|
|
32
|
-
@sort_direction =
|
|
35
|
+
@sort_direction = sorted_ascending? ? :desc : :asc
|
|
33
36
|
else
|
|
34
37
|
@sort_direction = :asc
|
|
35
38
|
end
|
|
39
|
+
|
|
40
|
+
if sorted_by_this_column?
|
|
41
|
+
if sorted_ascending?
|
|
42
|
+
@title_with_arrow = add_arrow_up(@title)
|
|
43
|
+
else
|
|
44
|
+
@title_with_arrow = add_arrow_down(@title)
|
|
45
|
+
end
|
|
46
|
+
else
|
|
47
|
+
@title_with_arrow = @title
|
|
48
|
+
end
|
|
36
49
|
end
|
|
37
50
|
|
|
38
51
|
def perform
|
|
39
|
-
h.link_to(@
|
|
52
|
+
h.link_to(@title_with_arrow, h.url_for(sort_by: @column_name, sort_direction: @sort_direction))
|
|
40
53
|
end
|
|
41
54
|
|
|
42
55
|
private
|
|
@@ -44,6 +57,22 @@ module Rails
|
|
|
44
57
|
def h
|
|
45
58
|
@view_context
|
|
46
59
|
end
|
|
60
|
+
|
|
61
|
+
def sorted_by_this_column?
|
|
62
|
+
h.params[:sort_by] == @column_name.to_s
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def sorted_ascending?
|
|
66
|
+
h.params[:sort_direction].to_sym == :asc
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def add_arrow_up(title)
|
|
70
|
+
"#{title} #{ARROW_UP}".html_safe
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def add_arrow_down(title)
|
|
74
|
+
"#{title} #{ARROW_DOWN}".html_safe
|
|
75
|
+
end
|
|
47
76
|
end
|
|
48
77
|
end
|
|
49
78
|
end
|