actionset 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/actionset.gemspec +10 -11
- data/lib/action_set.rb +0 -13
- data/lib/action_set/helpers/helper_methods.rb +2 -10
- data/lib/action_set/helpers/pagination/current_page_description_for_helper.rb +19 -0
- data/lib/action_set/helpers/pagination/current_page_for_helper.rb +9 -0
- data/lib/action_set/helpers/pagination/first_page_link_for_helper.rb +19 -0
- data/lib/action_set/helpers/pagination/last_page_link_for_helper.rb +24 -0
- data/lib/action_set/helpers/pagination/links_for_helper.rb +19 -69
- data/lib/action_set/helpers/pagination/next_page_link_for_helper.rb +24 -0
- data/lib/action_set/helpers/pagination/page_size_for_helper.rb +9 -0
- data/lib/action_set/helpers/pagination/path_for_helper.rb +9 -4
- data/lib/action_set/helpers/pagination/prev_page_link_for_helper.rb +23 -0
- data/lib/action_set/helpers/pagination/total_pages_for_helper.rb +15 -0
- data/lib/action_set/helpers/params/current_helper.rb +11 -0
- data/lib/action_set/helpers/params/form_for_object_helper.rb +16 -0
- data/lib/action_set/helpers/sort/current_direction_for_helper.rb +8 -8
- data/lib/action_set/helpers/sort/description_for_helper.rb +4 -0
- data/lib/action_set/helpers/sort/formatting_helper.rb +17 -0
- data/lib/action_set/helpers/sort/link_for_helper.rb +6 -0
- data/lib/action_set/helpers/sort/next_direction_for_helper.rb +9 -18
- data/lib/action_set/helpers/sort/path_for_helper.rb +11 -4
- data/lib/action_set/version.rb +1 -1
- metadata +53 -56
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f859bd2af027550824912a5fa2ea15856bf355b9
|
4
|
+
data.tar.gz: fb7d494de37f4eddc01697c032d20de7a6526870
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61ba01690350f529f1fb1ad0b7cc4084500b57878f055e3ac2d93f80ac7ca4d54df1b4a65a64136e851e5674a0198a8a7c602449a1774fbd319f400311c9a0c5
|
7
|
+
data.tar.gz: bb723d0784f6a44a6b5f01d05b4ed1ac5c50c3156d0983fafbb58ebcfd5fb0b3fc9238204c9e3d48ee3ae4a10ee8674d280eda6c1018b4e1d8270ee68e38e123
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
v 0.5.0
|
2
|
+
- Replace the use of `@filters` with the helper method `form_for_object_from_param(:filter)`
|
3
|
+
- Fix the pagination and sorting path helper methods to ensure they don't remove pre-existing params
|
4
|
+
- Rearrange the pagination helpers into a loose collection of micro-helpers
|
1
5
|
v 0.4.2
|
2
6
|
- Ensure that the sort_link_for helper method can work with symbol attributes
|
3
7
|
v 0.4.1
|
data/actionset.gemspec
CHANGED
@@ -27,15 +27,14 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_dependency 'railties'
|
28
28
|
|
29
29
|
spec.add_development_dependency 'rails', '~> 5.1.0'
|
30
|
-
spec.add_development_dependency 'bundler'
|
31
|
-
spec.add_development_dependency 'rake'
|
32
|
-
spec.add_development_dependency 'rspec'
|
33
|
-
spec.add_development_dependency '
|
34
|
-
spec.add_development_dependency '
|
35
|
-
spec.add_development_dependency '
|
36
|
-
spec.add_development_dependency '
|
37
|
-
spec.add_development_dependency '
|
38
|
-
spec.add_development_dependency '
|
39
|
-
spec.add_development_dependency 'simplecov'
|
40
|
-
spec.add_development_dependency 'simplecov-console', '~> 0.4.2'
|
30
|
+
spec.add_development_dependency 'bundler'
|
31
|
+
spec.add_development_dependency 'rake'
|
32
|
+
spec.add_development_dependency 'rspec'
|
33
|
+
spec.add_development_dependency 'database_cleaner'
|
34
|
+
spec.add_development_dependency 'capybara'
|
35
|
+
spec.add_development_dependency 'combustion'
|
36
|
+
spec.add_development_dependency 'factory_girl'
|
37
|
+
spec.add_development_dependency 'faker'
|
38
|
+
spec.add_development_dependency 'simplecov'
|
39
|
+
spec.add_development_dependency 'simplecov-console'
|
41
40
|
end
|
data/lib/action_set.rb
CHANGED
@@ -4,7 +4,6 @@ require 'rails/railtie'
|
|
4
4
|
require 'active_support/core_ext/object/blank'
|
5
5
|
require 'active_support/lazy_load_hooks'
|
6
6
|
require 'active_set'
|
7
|
-
require 'ostruct'
|
8
7
|
|
9
8
|
require 'action_set/version'
|
10
9
|
require_relative './action_set/instruction/value'
|
@@ -16,12 +15,6 @@ module ActionSet
|
|
16
15
|
::ActionView::Base.send :include, Helpers::HelperMethods
|
17
16
|
end
|
18
17
|
|
19
|
-
class Filter < OpenStruct
|
20
|
-
def model_name
|
21
|
-
OpenStruct.new(param_key: 'filter')
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
18
|
module ClassMethods
|
26
19
|
end
|
27
20
|
|
@@ -31,7 +24,6 @@ module ActionSet
|
|
31
24
|
end
|
32
25
|
|
33
26
|
def filter_set(set)
|
34
|
-
set_filters_ivar
|
35
27
|
active_set = ensure_active_set(set)
|
36
28
|
active_set = active_set.filter(filter_structure(set)) if filter_params.any?
|
37
29
|
active_set
|
@@ -56,11 +48,6 @@ module ActionSet
|
|
56
48
|
send_data(transformed_data, export_set_options(request.format))
|
57
49
|
end
|
58
50
|
|
59
|
-
def set_filters_ivar
|
60
|
-
@filters = JSON.parse(filter_params.to_json,
|
61
|
-
object_class: Filter)
|
62
|
-
end
|
63
|
-
|
64
51
|
private
|
65
52
|
|
66
53
|
def filter_structure(set)
|
@@ -1,24 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative './sort/current_direction_for_helper'
|
4
|
-
require_relative './sort/description_for_helper'
|
5
3
|
require_relative './sort/link_for_helper'
|
6
|
-
require_relative './sort/next_direction_for_helper'
|
7
|
-
require_relative './sort/path_for_helper'
|
8
4
|
require_relative './pagination/links_for_helper'
|
9
5
|
require_relative './pagination/path_for_helper'
|
6
|
+
require_relative './params/form_for_object_helper'
|
10
7
|
|
11
8
|
module ActionSet
|
12
9
|
module Helpers
|
13
10
|
module HelperMethods
|
14
|
-
include Sort::CurrentDirectionForHelper
|
15
|
-
include Sort::DescriptionForHelper
|
16
11
|
include Sort::LinkForHelper
|
17
|
-
include Sort::NextDirectionForHelper
|
18
|
-
include Sort::PathForHelper
|
19
|
-
|
20
|
-
include Pagination::PathForHelper
|
21
12
|
include Pagination::LinksForHelper
|
13
|
+
include Params::FormForObjectHelper
|
22
14
|
end
|
23
15
|
end
|
24
16
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './current_page_for_helper'
|
4
|
+
require_relative './total_pages_for_helper'
|
5
|
+
|
6
|
+
module Pagination
|
7
|
+
module CurrentPageDescriptionForHelper
|
8
|
+
include Pagination::CurrentPageForHelper
|
9
|
+
include Pagination::TotalPagesForHelper
|
10
|
+
|
11
|
+
def pagination_current_page_description_for(set)
|
12
|
+
description = "Page <strong>#{pagination_current_page_for(set)}</strong> of <strong>#{pagination_total_pages_for(set)}</strong>".html_safe
|
13
|
+
|
14
|
+
content_tag(:span,
|
15
|
+
description,
|
16
|
+
class: 'page-current')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './current_page_for_helper'
|
4
|
+
require_relative './path_for_helper'
|
5
|
+
|
6
|
+
module Pagination
|
7
|
+
module FirstPageLinkForHelper
|
8
|
+
include Pagination::CurrentPageForHelper
|
9
|
+
include Pagination::PathForHelper
|
10
|
+
|
11
|
+
def pagination_first_page_link_for(set)
|
12
|
+
if pagination_current_page_for(set) > 1
|
13
|
+
link_to('« First', pagination_path_for(1), class: 'page-link page-first')
|
14
|
+
else
|
15
|
+
content_tag(:span, '« First', class: 'page-link page-first disabled')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './current_page_for_helper'
|
4
|
+
require_relative './total_pages_for_helper'
|
5
|
+
require_relative './path_for_helper'
|
6
|
+
|
7
|
+
module Pagination
|
8
|
+
module LastPageLinkForHelper
|
9
|
+
include Pagination::CurrentPageForHelper
|
10
|
+
include Pagination::TotalPagesForHelper
|
11
|
+
include Pagination::PathForHelper
|
12
|
+
|
13
|
+
def pagination_last_page_link_for(set)
|
14
|
+
current_page = pagination_current_page_for(set)
|
15
|
+
total_pages = pagination_total_pages_for(set)
|
16
|
+
|
17
|
+
if current_page != total_pages && current_page <= total_pages
|
18
|
+
link_to('Last »', pagination_path_for(total_pages), class: 'page-link page-last')
|
19
|
+
else
|
20
|
+
content_tag(:span, 'Last »', class: 'page-link page-last disabled')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,79 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './first_page_link_for_helper'
|
4
|
+
require_relative './prev_page_link_for_helper'
|
5
|
+
require_relative './current_page_description_for_helper'
|
6
|
+
require_relative './next_page_link_for_helper'
|
7
|
+
require_relative './last_page_link_for_helper'
|
8
|
+
|
1
9
|
module Pagination
|
2
10
|
module LinksForHelper
|
11
|
+
include Pagination::FirstPageLinkForHelper
|
12
|
+
include Pagination::PrevPageLinkForHelper
|
13
|
+
include Pagination::CurrentPageDescriptionForHelper
|
14
|
+
include Pagination::NextPageLinkForHelper
|
15
|
+
include Pagination::LastPageLinkForHelper
|
16
|
+
|
3
17
|
def pagination_links_for(set)
|
4
18
|
content_tag(:nav, class: 'pagination', 'aria-label': 'Page navigation') do
|
5
19
|
safe_join([
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
20
|
+
pagination_first_page_link_for(set),
|
21
|
+
pagination_prev_page_link_for(set),
|
22
|
+
pagination_current_page_description_for(set),
|
23
|
+
pagination_next_page_link_for(set),
|
24
|
+
pagination_last_page_link_for(set)
|
11
25
|
])
|
12
26
|
end
|
13
27
|
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def description_of_current_page(set)
|
18
|
-
description = "Page <strong>#{current_page_for(set)}</strong> of <strong>#{total_pages_for(set)}</strong>".html_safe
|
19
|
-
|
20
|
-
content_tag(:span,
|
21
|
-
description,
|
22
|
-
class: 'page-current')
|
23
|
-
end
|
24
|
-
|
25
|
-
def link_to_first_page(set)
|
26
|
-
if current_page_for(set) > 1
|
27
|
-
link_to('« First', paginate_path_for(1), class: 'page-link page-first')
|
28
|
-
else
|
29
|
-
content_tag(:span, '« First', class: 'page-link page-first disabled')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def link_to_prev_page(set)
|
34
|
-
current_page = current_page_for(set)
|
35
|
-
|
36
|
-
if current_page > 1 && current_page <= total_pages_for(set)
|
37
|
-
link_to('‹ Prev', paginate_path_for(current_page - 1), rel: 'prev', class: 'page-link page-prev')
|
38
|
-
else
|
39
|
-
content_tag(:span, '‹ Prev', class: 'page-link page-prev disabled')
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def link_to_last_page(set)
|
44
|
-
current_page = current_page_for(set)
|
45
|
-
total_pages = total_pages_for(set)
|
46
|
-
|
47
|
-
if current_page != total_pages && current_page <= total_pages
|
48
|
-
link_to('Last »', paginate_path_for(total_pages), class: 'page-link page-last')
|
49
|
-
else
|
50
|
-
content_tag(:span, 'Last »', class: 'page-link page-last disabled')
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def link_to_next_page(set)
|
55
|
-
current_page = current_page_for(set)
|
56
|
-
total_pages = total_pages_for(set)
|
57
|
-
|
58
|
-
if current_page != total_pages && current_page <= total_pages
|
59
|
-
link_to('Next ›', paginate_path_for(current_page + 1), rel: 'next', class: 'page-link page-next')
|
60
|
-
else
|
61
|
-
content_tag(:span, 'Next ›', class: 'page-link page-next disabled')
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def total_pages_for(set)
|
66
|
-
total_set_size = set.set.count
|
67
|
-
|
68
|
-
(total_set_size.to_f / page_size_for(set)).ceil
|
69
|
-
end
|
70
|
-
|
71
|
-
def current_page_for(set)
|
72
|
-
set.instructions.dig(:paginate, :page)
|
73
|
-
end
|
74
|
-
|
75
|
-
def page_size_for(set)
|
76
|
-
set.instructions.dig(:paginate, :size)
|
77
|
-
end
|
78
28
|
end
|
79
29
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './current_page_for_helper'
|
4
|
+
require_relative './total_pages_for_helper'
|
5
|
+
require_relative './path_for_helper'
|
6
|
+
|
7
|
+
module Pagination
|
8
|
+
module NextPageLinkForHelper
|
9
|
+
include Pagination::CurrentPageForHelper
|
10
|
+
include Pagination::TotalPagesForHelper
|
11
|
+
include Pagination::PathForHelper
|
12
|
+
|
13
|
+
def pagination_next_page_link_for(set)
|
14
|
+
current_page = pagination_current_page_for(set)
|
15
|
+
total_pages = pagination_total_pages_for(set)
|
16
|
+
|
17
|
+
if current_page != total_pages && current_page <= total_pages
|
18
|
+
link_to('Next ›', pagination_path_for(current_page + 1), rel: 'next', class: 'page-link page-next')
|
19
|
+
else
|
20
|
+
content_tag(:span, 'Next ›', class: 'page-link page-next disabled')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,6 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../params/current_helper'
|
4
|
+
|
1
5
|
module Pagination
|
2
6
|
module PathForHelper
|
3
|
-
def
|
7
|
+
def pagination_path_for(page)
|
4
8
|
page ||= 1
|
5
9
|
url_for paginate_params_for(page)
|
6
10
|
end
|
@@ -8,9 +12,10 @@ module Pagination
|
|
8
12
|
private
|
9
13
|
|
10
14
|
def paginate_params_for(page)
|
11
|
-
current_params
|
12
|
-
|
13
|
-
|
15
|
+
current_params
|
16
|
+
.deep_merge(paginate: {
|
17
|
+
page: page
|
18
|
+
})
|
14
19
|
end
|
15
20
|
end
|
16
21
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './current_page_for_helper'
|
4
|
+
require_relative './total_pages_for_helper'
|
5
|
+
require_relative './path_for_helper'
|
6
|
+
|
7
|
+
module Pagination
|
8
|
+
module PrevPageLinkForHelper
|
9
|
+
include Pagination::CurrentPageForHelper
|
10
|
+
include Pagination::TotalPagesForHelper
|
11
|
+
include Pagination::PathForHelper
|
12
|
+
|
13
|
+
def pagination_prev_page_link_for(set)
|
14
|
+
current_page = pagination_current_page_for(set)
|
15
|
+
|
16
|
+
if current_page > 1 && current_page <= pagination_total_pages_for(set)
|
17
|
+
link_to('‹ Prev', pagination_path_for(current_page - 1), rel: 'prev', class: 'page-link page-prev')
|
18
|
+
else
|
19
|
+
content_tag(:span, '‹ Prev', class: 'page-link page-prev disabled')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './page_size_for_helper'
|
4
|
+
|
5
|
+
module Pagination
|
6
|
+
module TotalPagesForHelper
|
7
|
+
include Pagination::PageSizeForHelper
|
8
|
+
|
9
|
+
def pagination_total_pages_for(set)
|
10
|
+
total_set_size = set.set.count
|
11
|
+
|
12
|
+
(total_set_size.to_f / pagination_page_size_for(set)).ceil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
module Params
|
7
|
+
module FormForObjectHelper
|
8
|
+
def form_for_object_from_param(param)
|
9
|
+
form_for_params = params.fetch(param, {})
|
10
|
+
form_for_requirements = { model_name: { param_key: param } }
|
11
|
+
|
12
|
+
JSON.parse(form_for_params.merge(form_for_requirements).to_json,
|
13
|
+
object_class: OpenStruct)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../params/current_helper'
|
4
|
+
require_relative './formatting_helper'
|
5
|
+
|
3
6
|
module Sort
|
4
7
|
module CurrentDirectionForHelper
|
8
|
+
include Params::CurrentHelper
|
9
|
+
include Sort::FormattingHelper
|
10
|
+
|
5
11
|
def current_sort_direction_for(attribute, format: :short)
|
6
12
|
direction = current_params.dig(:sort, attribute).to_s.downcase
|
7
13
|
|
8
|
-
return
|
9
|
-
return
|
14
|
+
return ascending_str(format) if direction.presence_in %w[asc ascending]
|
15
|
+
return descending_str(format) if direction.presence_in %w[desc descending]
|
10
16
|
|
11
17
|
direction
|
12
18
|
end
|
13
|
-
|
14
|
-
def current_params
|
15
|
-
return params.to_unsafe_hash if params.respond_to? :to_unsafe_hash
|
16
|
-
|
17
|
-
params
|
18
|
-
end
|
19
19
|
end
|
20
20
|
end
|
@@ -1,7 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative './next_direction_for_helper'
|
4
|
+
|
3
5
|
module Sort
|
4
6
|
module DescriptionForHelper
|
7
|
+
include Sort::NextDirectionForHelper
|
8
|
+
|
5
9
|
def sort_description_for(attribute)
|
6
10
|
"sort by '#{attribute}' in #{next_sort_direction_for(attribute, format: :long)} order"
|
7
11
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sort
|
4
|
+
module FormattingHelper
|
5
|
+
def ascending_str(format)
|
6
|
+
return 'asc' if format.to_s == 'short'
|
7
|
+
|
8
|
+
'ascending'
|
9
|
+
end
|
10
|
+
|
11
|
+
def descending_str(format)
|
12
|
+
return 'desc' if format.to_s == 'short'
|
13
|
+
|
14
|
+
'descending'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,7 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative './path_for_helper'
|
4
|
+
require_relative './description_for_helper'
|
5
|
+
|
3
6
|
module Sort
|
4
7
|
module LinkForHelper
|
8
|
+
include Sort::PathForHelper
|
9
|
+
include Sort::DescriptionForHelper
|
10
|
+
|
5
11
|
def sort_link_for(attribute, name = nil)
|
6
12
|
link_to(name || attribute.to_s.titleize,
|
7
13
|
sort_path_for(attribute),
|
@@ -1,30 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative './current_direction_for_helper'
|
4
|
+
require_relative './formatting_helper'
|
4
5
|
|
5
6
|
module Sort
|
6
7
|
module NextDirectionForHelper
|
8
|
+
include Sort::CurrentDirectionForHelper
|
9
|
+
include Sort::FormattingHelper
|
10
|
+
|
7
11
|
def next_sort_direction_for(attribute, format: :short)
|
8
12
|
direction = current_sort_direction_for(attribute)
|
9
13
|
|
10
|
-
return
|
11
|
-
return
|
12
|
-
return
|
13
|
-
return _descending(format) if direction.presence_in %w[asc ascending]
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def _ascending(format)
|
19
|
-
return 'asc' if format.to_s == 'short'
|
20
|
-
|
21
|
-
'ascending'
|
22
|
-
end
|
23
|
-
|
24
|
-
def _descending(format)
|
25
|
-
return 'desc' if format.to_s == 'short'
|
14
|
+
return ascending_str(format) unless direction.presence_in %w[asc desc ascending descending]
|
15
|
+
return ascending_str(format) if direction.presence_in %w[desc descending]
|
16
|
+
return descending_str(format) if direction.presence_in %w[asc ascending]
|
26
17
|
|
27
|
-
|
18
|
+
ascending_str(format)
|
28
19
|
end
|
29
20
|
end
|
30
21
|
end
|
@@ -1,7 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../params/current_helper'
|
4
|
+
require_relative './next_direction_for_helper'
|
5
|
+
|
3
6
|
module Sort
|
4
7
|
module PathForHelper
|
8
|
+
include Params::CurrentHelper
|
9
|
+
include Sort::NextDirectionForHelper
|
10
|
+
|
5
11
|
def sort_path_for(attribute)
|
6
12
|
url_for sort_params_for(attribute)
|
7
13
|
end
|
@@ -9,10 +15,11 @@ module Sort
|
|
9
15
|
private
|
10
16
|
|
11
17
|
def sort_params_for(attribute)
|
12
|
-
current_params
|
13
|
-
|
14
|
-
|
15
|
-
|
18
|
+
current_params
|
19
|
+
.deep_merge(only_path: true,
|
20
|
+
sort: {
|
21
|
+
attribute => next_sort_direction_for(attribute)
|
22
|
+
})
|
16
23
|
end
|
17
24
|
end
|
18
25
|
end
|
data/lib/action_set/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionset
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Margheim
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeset
|
@@ -70,156 +70,142 @@ dependencies:
|
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '3.0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '3.0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rspec-rails
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
101
|
+
- - ">="
|
116
102
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
103
|
+
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
107
|
requirements:
|
122
|
-
- - "
|
108
|
+
- - ">="
|
123
109
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
110
|
+
version: '0'
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
112
|
name: database_cleaner
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
128
114
|
requirements:
|
129
|
-
- - "
|
115
|
+
- - ">="
|
130
116
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
117
|
+
version: '0'
|
132
118
|
type: :development
|
133
119
|
prerelease: false
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
135
121
|
requirements:
|
136
|
-
- - "
|
122
|
+
- - ">="
|
137
123
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
124
|
+
version: '0'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: capybara
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
142
128
|
requirements:
|
143
|
-
- - "
|
129
|
+
- - ">="
|
144
130
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
131
|
+
version: '0'
|
146
132
|
type: :development
|
147
133
|
prerelease: false
|
148
134
|
version_requirements: !ruby/object:Gem::Requirement
|
149
135
|
requirements:
|
150
|
-
- - "
|
136
|
+
- - ">="
|
151
137
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
138
|
+
version: '0'
|
153
139
|
- !ruby/object:Gem::Dependency
|
154
140
|
name: combustion
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
156
142
|
requirements:
|
157
|
-
- - "
|
143
|
+
- - ">="
|
158
144
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0
|
145
|
+
version: '0'
|
160
146
|
type: :development
|
161
147
|
prerelease: false
|
162
148
|
version_requirements: !ruby/object:Gem::Requirement
|
163
149
|
requirements:
|
164
|
-
- - "
|
150
|
+
- - ">="
|
165
151
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0
|
152
|
+
version: '0'
|
167
153
|
- !ruby/object:Gem::Dependency
|
168
154
|
name: factory_girl
|
169
155
|
requirement: !ruby/object:Gem::Requirement
|
170
156
|
requirements:
|
171
|
-
- - "
|
157
|
+
- - ">="
|
172
158
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
159
|
+
version: '0'
|
174
160
|
type: :development
|
175
161
|
prerelease: false
|
176
162
|
version_requirements: !ruby/object:Gem::Requirement
|
177
163
|
requirements:
|
178
|
-
- - "
|
164
|
+
- - ">="
|
179
165
|
- !ruby/object:Gem::Version
|
180
|
-
version:
|
166
|
+
version: '0'
|
181
167
|
- !ruby/object:Gem::Dependency
|
182
168
|
name: faker
|
183
169
|
requirement: !ruby/object:Gem::Requirement
|
184
170
|
requirements:
|
185
|
-
- - "
|
171
|
+
- - ">="
|
186
172
|
- !ruby/object:Gem::Version
|
187
|
-
version:
|
173
|
+
version: '0'
|
188
174
|
type: :development
|
189
175
|
prerelease: false
|
190
176
|
version_requirements: !ruby/object:Gem::Requirement
|
191
177
|
requirements:
|
192
|
-
- - "
|
178
|
+
- - ">="
|
193
179
|
- !ruby/object:Gem::Version
|
194
|
-
version:
|
180
|
+
version: '0'
|
195
181
|
- !ruby/object:Gem::Dependency
|
196
182
|
name: simplecov
|
197
183
|
requirement: !ruby/object:Gem::Requirement
|
198
184
|
requirements:
|
199
|
-
- - "
|
185
|
+
- - ">="
|
200
186
|
- !ruby/object:Gem::Version
|
201
|
-
version: 0
|
187
|
+
version: '0'
|
202
188
|
type: :development
|
203
189
|
prerelease: false
|
204
190
|
version_requirements: !ruby/object:Gem::Requirement
|
205
191
|
requirements:
|
206
|
-
- - "
|
192
|
+
- - ">="
|
207
193
|
- !ruby/object:Gem::Version
|
208
|
-
version: 0
|
194
|
+
version: '0'
|
209
195
|
- !ruby/object:Gem::Dependency
|
210
196
|
name: simplecov-console
|
211
197
|
requirement: !ruby/object:Gem::Requirement
|
212
198
|
requirements:
|
213
|
-
- - "
|
199
|
+
- - ">="
|
214
200
|
- !ruby/object:Gem::Version
|
215
|
-
version: 0
|
201
|
+
version: '0'
|
216
202
|
type: :development
|
217
203
|
prerelease: false
|
218
204
|
version_requirements: !ruby/object:Gem::Requirement
|
219
205
|
requirements:
|
220
|
-
- - "
|
206
|
+
- - ">="
|
221
207
|
- !ruby/object:Gem::Version
|
222
|
-
version: 0
|
208
|
+
version: '0'
|
223
209
|
description: Easily filter, sort, and paginate enumerable sets via web requests.
|
224
210
|
email:
|
225
211
|
- stephen.margheim@gmail.com
|
@@ -242,10 +228,21 @@ files:
|
|
242
228
|
- config.ru
|
243
229
|
- lib/action_set.rb
|
244
230
|
- lib/action_set/helpers/helper_methods.rb
|
231
|
+
- lib/action_set/helpers/pagination/current_page_description_for_helper.rb
|
232
|
+
- lib/action_set/helpers/pagination/current_page_for_helper.rb
|
233
|
+
- lib/action_set/helpers/pagination/first_page_link_for_helper.rb
|
234
|
+
- lib/action_set/helpers/pagination/last_page_link_for_helper.rb
|
245
235
|
- lib/action_set/helpers/pagination/links_for_helper.rb
|
236
|
+
- lib/action_set/helpers/pagination/next_page_link_for_helper.rb
|
237
|
+
- lib/action_set/helpers/pagination/page_size_for_helper.rb
|
246
238
|
- lib/action_set/helpers/pagination/path_for_helper.rb
|
239
|
+
- lib/action_set/helpers/pagination/prev_page_link_for_helper.rb
|
240
|
+
- lib/action_set/helpers/pagination/total_pages_for_helper.rb
|
241
|
+
- lib/action_set/helpers/params/current_helper.rb
|
242
|
+
- lib/action_set/helpers/params/form_for_object_helper.rb
|
247
243
|
- lib/action_set/helpers/sort/current_direction_for_helper.rb
|
248
244
|
- lib/action_set/helpers/sort/description_for_helper.rb
|
245
|
+
- lib/action_set/helpers/sort/formatting_helper.rb
|
249
246
|
- lib/action_set/helpers/sort/link_for_helper.rb
|
250
247
|
- lib/action_set/helpers/sort/next_direction_for_helper.rb
|
251
248
|
- lib/action_set/helpers/sort/path_for_helper.rb
|