awesome_sort 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -0
- data/app/assets/javascripts/awesome_sort.js +22 -6
- data/app/helpers/awesome_sort/awesome_sort_helper.rb +1 -1
- data/lib/awesome_sort/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72ea11d1aa8fcb19809cda764f56ce8033cefc1391f174bbce11b77244bc9c0a
|
4
|
+
data.tar.gz: 3eb561003b0d682e34bbc885cf257079a4aa3084bf78d5038f3a3e64d7d9a2a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09206b0dd24ce6fcd458ff00e3bd2211c7aad4616538cf48e497b253c09ba8dedcadeab779a567ae820f1d44a00c077663985936d54a54a5fc058b4db5be43ff'
|
7
|
+
data.tar.gz: 91ef44bbcd125ea418abee918863f1d9903925fde9ca4c846cea0b498246bfb46b1286fe0a92a0c9b54db967d7d7746f03f0acd04cba71fdb87449c235db1a9c
|
data/README.md
CHANGED
@@ -40,6 +40,21 @@ AwesomeSort.configure do |config|
|
|
40
40
|
end
|
41
41
|
```
|
42
42
|
|
43
|
+
In the view, when creating columns for the table, use the following syntax:
|
44
|
+
```ruby
|
45
|
+
<%= column_sort(
|
46
|
+
column_name: "title",
|
47
|
+
width: "10%",
|
48
|
+
link_name: "Title",
|
49
|
+
controller_name: "contact_index",
|
50
|
+
extra: { search: @search }) %>
|
51
|
+
```
|
52
|
+
where: <br />
|
53
|
+
"column_name" will be the name of your db column <br />
|
54
|
+
"width" will be your column width <br />
|
55
|
+
"link_name" will be the name of the column displayed as a link <br />
|
56
|
+
"controller_name" will be the controller name for logic <br />
|
57
|
+
"extra" pass in there extra parameters <br />
|
43
58
|
|
44
59
|
## Development
|
45
60
|
|
@@ -20,11 +20,27 @@ function orderable() {
|
|
20
20
|
}
|
21
21
|
|
22
22
|
$(".orderable").each(function() {
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
var url = new URL(window.location)
|
24
|
+
url.searchParams.append('sort_by', $(this).data('order-term'))
|
25
|
+
url.searchParams.append('sort_order', $(this).hasClass('order-asc') ? 'desc' : 'asc')
|
26
|
+
|
27
|
+
var element = $(this).has('> a').length ? $(this).children('a') : $(this).wrapInner($('<a/>'))
|
28
|
+
element.attr('href', url.toString());
|
29
29
|
});
|
30
30
|
};
|
31
|
+
|
32
|
+
function fireEvent(event) {
|
33
|
+
var e = new Event(event)
|
34
|
+
window.dispatchEvent(e)
|
35
|
+
}
|
36
|
+
|
37
|
+
// Have to manually fire event when history is updated (url changes)
|
38
|
+
var _pushState = history.pushState;
|
39
|
+
history.pushState = function() {
|
40
|
+
_pushState.apply(history, arguments);
|
41
|
+
fireEvent('pushState');
|
42
|
+
};
|
43
|
+
|
44
|
+
window.addEventListener('pushState', function() {
|
45
|
+
orderable()
|
46
|
+
})
|
@@ -19,7 +19,7 @@ module AwesomeSort
|
|
19
19
|
else
|
20
20
|
"asc"
|
21
21
|
end
|
22
|
-
content_tag(:th, width: args[:width], class: klass) do
|
22
|
+
content_tag(:th, width: args[:width], class: klass, data: { order_term: args[:column_name] }) do
|
23
23
|
link_to(
|
24
24
|
args[:link_name],
|
25
25
|
public_send(c_method, { sort_order: sort_order, sort_by: args[:column_name] }.merge(args[:extra])),
|
data/lib/awesome_sort/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awesome_sort
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Diaconu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -139,8 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
|
-
|
143
|
-
rubygems_version: 2.7.7
|
142
|
+
rubygems_version: 3.0.4
|
144
143
|
signing_key:
|
145
144
|
specification_version: 4
|
146
145
|
summary: Responsive sortable table
|