alphabetical_paginate 2.3.0 → 2.3.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.
data/README.md CHANGED
@@ -164,3 +164,11 @@ Also, there is one line in vendor/assets/javascripts that needs to be changed fo
164
164
  # Support
165
165
 
166
166
  Please feel free to reach out and contact if you find the gem useful at all! Also, feel free to report / fix any bugs or add features.
167
+
168
+ ## To run tests
169
+
170
+ rspec
171
+
172
+ ## To publish the gem
173
+
174
+ rake release
@@ -4,7 +4,7 @@ class Array
4
4
  paginate_all: false, numbers: true, include_all: true,
5
5
  others: true, pagination_class: "pagination-centered",
6
6
  js: true, support_language: :en, bootstrap3: false,
7
- slugged_link: false, slug_field: "slug"}
7
+ slugged_link: false, slug_field: "slug", all_as_link: true}
8
8
  params[:paginate_all] ||= false
9
9
  params[:support_language] ||= :en
10
10
  params[:language] = AlphabeticalPaginate::Language.new(params[:support_language])
@@ -17,6 +17,7 @@ class Array
17
17
  params[:slugged_link] ||= false
18
18
  params[:slugged_link] = params[:slugged_link] && defined?(Babosa)
19
19
  params[:slug_field] ||= "slug"
20
+ params[:all_as_link] = true if !params.has_key? :all_as_link
20
21
 
21
22
  output = []
22
23
  availableLetters = {}
@@ -11,7 +11,7 @@ module AlphabeticalPaginate
11
11
  db_field: "id", include_all: true,
12
12
  js: true, support_language: :en,
13
13
  bootstrap3: false, slugged_link: false,
14
- slug_field: "slug"}
14
+ slug_field: "slug", all_as_link: true}
15
15
  params[:paginate_all] ||= false
16
16
  params[:support_language] ||= :en
17
17
  params[:language] = AlphabeticalPaginate::Language.new(params[:support_language])
@@ -26,6 +26,7 @@ module AlphabeticalPaginate
26
26
  params[:slugged_link] ||= false
27
27
  params[:slugged_link] = params[:slugged_link] && defined?(Babosa)
28
28
  params[:slug_field] ||= "slug"
29
+ params[:all_as_link] = true if !params.has_key? :all_as_link
29
30
 
30
31
  output = []
31
32
 
@@ -1,3 +1,3 @@
1
1
  module AlphabeticalPaginate
2
- VERSION = "2.3.0"
2
+ VERSION = "2.3.1"
3
3
  end
@@ -23,8 +23,12 @@ module AlphabeticalPaginate
23
23
  if options[:slugged_link] && (l =~ options[:language].letters_regexp || l == "All")
24
24
  link_letter = options[:language].slugged_letters[l]
25
25
  end
26
+ letter_options = { letter: link_letter }
27
+ if !options[:all_as_link] && (l == "All")
28
+ letter_options[:letter] = nil
29
+ end
26
30
 
27
- url = options[:scope].url_for(:letter => link_letter)
31
+ url = options[:scope].url_for(letter_options)
28
32
  value = options[:language].output_letter(l)
29
33
  if l == options[:currentField]
30
34
  links += content_tag(:li, link_to(value, "#", "data-letter" => l), :class => "active")
@@ -50,8 +54,12 @@ module AlphabeticalPaginate
50
54
  if options[:slugged_link] && (l =~ options[:language].letters_regexp || l == "All")
51
55
  link_letter = options[:language].slugged_letters[l]
52
56
  end
57
+ letter_options = { letter: link_letter }
58
+ if !options[:all_as_link] && (l == "All")
59
+ letter_options[:letter] = nil
60
+ end
53
61
 
54
- url = options[:scope].url_for(:letter => link_letter)
62
+ url = options[:scope].url_for(letter_options)
55
63
  value = options[:language].output_letter(l)
56
64
  links += content_tag(:li, link_to(value, url, "data-letter" => l), :class => ("active" if l == options[:currentField] ))
57
65
  end
@@ -15,7 +15,7 @@ end
15
15
 
16
16
  class RouterMock
17
17
  def url_for(options)
18
- '?letter='+options[:letter]
18
+ options[:letter] ? '?letter='+options[:letter] : '/'
19
19
  end
20
20
  end
21
21
 
@@ -201,6 +201,18 @@ module AlphabeticalPaginate
201
201
  pagination.should include x
202
202
  end
203
203
  end
204
+
205
+ it "should include All as link" do
206
+ index, params = @list.alpha_paginate("A", { include_all: true })
207
+ pagination = alphabetical_paginate(params)
208
+ pagination.should include "href='?letter=All'"
209
+ end
210
+
211
+ it "should not include All as link" do
212
+ index, params = @list.alpha_paginate("A", { include_all: true, all_as_link: false })
213
+ pagination = alphabetical_paginate(params)
214
+ pagination.should_not include "href='?letter=All'"
215
+ end
204
216
  end
205
217
 
206
218
  describe "#alphabetical_paginate in russian characters" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alphabetical_paginate
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-16 00:00:00.000000000 Z
12
+ date: 2015-05-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler