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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e8241f1d82e0279d227acb1acd6c9fbd964f5614dda257456c99e0b55a1d863
4
- data.tar.gz: a7902556113b610300414fed6a2c77e44598a3ead8956703874e4928e80dd327
3
+ metadata.gz: 72ea11d1aa8fcb19809cda764f56ce8033cefc1391f174bbce11b77244bc9c0a
4
+ data.tar.gz: 3eb561003b0d682e34bbc885cf257079a4aa3084bf78d5038f3a3e64d7d9a2a5
5
5
  SHA512:
6
- metadata.gz: 90dcf2040ec6d5457b6409e95be6f5120f13777a4e6cbf86acab470951e9bc57a52862dd7dc413d25c9150e4743698396bc27f7bcb7d6c3e40a5402877cb6775
7
- data.tar.gz: 3edf5ade7c88ec8f75c610d28cc60d457c7888dce7bf4168db03b5f2d0c69843f8d608c3db39396e88bb6da0a3441c105731b9314ef260dd30e56ff873a59fb7
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
- if ($(this).hasClass('order-asc')) {
24
- var link = window.location.pathname + '?sort_by=' + $(this).data('order-term') + '&sort_order=desc' + window.location.hash
25
- } else {
26
- var link = window.location.pathname + '?sort_by=' + $(this).data('order-term') + '&sort_order=asc' + window.location.hash
27
- }
28
- $(this).wrapInner($('<a/>').attr('href', link));
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])),
@@ -1,3 +1,3 @@
1
1
  module AwesomeSort
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
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.2
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-06-12 00:00:00.000000000 Z
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
- rubyforge_project:
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