searchgasm 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ == 1.5.1 released 2008-10-20
2
+
3
+ * Fixed bug with per_page_links
4
+ * Added "ordering_by" class for per_page_links
5
+
1
6
  == 1.5.0 released 2008-10-20
2
7
 
3
8
  * Merge array of conditions with or or and where it makes sense. Begins with condition does not make sense to join with and, so instead join with or.
@@ -65,6 +65,17 @@ module Searchgasm
65
65
  end
66
66
  attr_writer :order_by_link_desc_indicator
67
67
 
68
+ # The class name used in order_by_links for the link that it is currently ordering by
69
+ #
70
+ # * <tt>Default:</tt> "# The class name for used in the page_link helper
71
+ #
72
+ # * <tt>Default:</tt> "page"
73
+ # * <tt>Accepts:</tt> String
74
+ def order_by_links_ordering_by_class_name
75
+ @order_by_links_ordering_by_class_name ||= "ordering_by"
76
+ end
77
+ attr_writer :order_by_links_ordering_by_class_name
78
+
68
79
  # The class name for used in the order_by_select helper
69
80
  #
70
81
  # * <tt>Default:</tt> "order_by"
@@ -222,7 +233,7 @@ module Searchgasm
222
233
  def per_page_select_choices
223
234
  return @per_page_select_choices if @per_page_select_choices
224
235
  @per_page_select_choices = []
225
- [10, 25, 50, 100, 150, 200].each { |choice| @per_page_select_choices << ["#{choice} per page", 25] }
236
+ [10, 25, 50, 100, 150, 200].each { |choice| @per_page_select_choices << ["#{choice} per page", choice] }
226
237
  @per_page_select_choices << ["Show all", nil]
227
238
  end
228
239
  attr_writer :per_page_select_choices
@@ -72,9 +72,10 @@ module Searchgasm
72
72
  links_options.delete(:choices)
73
73
  html = ""
74
74
  options[:choices].each do |choice|
75
- link_options = links_option.deep_dup
75
+ link_options = links_options.deep_dup
76
76
  text, value = option_text_and_value(choice)
77
77
  link_options[:text] ||= text
78
+ searchgasm_add_class!(link_options[:html], Config.helpers.order_by_links_ordering_by_class_name) if link_options[:search_obj].per_page == value
78
79
  html += per_page_link(value, link_options)
79
80
  end
80
81
  html
@@ -177,20 +178,26 @@ module Searchgasm
177
178
  def add_per_page_links_defaults!(options)
178
179
  add_searchgasm_control_defaults!(options)
179
180
  options[:choices] ||= Config.helpers.per_page_links_choices.dup
180
- if !options[:search_obj].per_page.blank? && !options[:choices].include?(options[:search_obj].per_page)
181
- options[:choices] << options[:search_obj].per_page
182
- has_nil = options[:choices].include?(nil)
183
- options[:choices].compact!
181
+ if !options[:search_obj].per_page.blank? && !choices_include?(options[:choices], options[:search_obj].per_page)
182
+ options[:choices] << ["#{options[:search_obj].per_page} per page", options[:search_obj].per_page]
184
183
  options[:choices].sort! do |a, b|
185
184
  a_value = (a.is_a?(Array) ? a.last : a).to_i
185
+ return -1 if a_value == 0
186
186
  b_value = (b.is_a?(Array) ? b.last : b).to_i
187
187
  a_value <=> b_value
188
188
  end
189
- options[:choices] << nil if has_nil
190
189
  end
191
190
  options
192
191
  end
193
192
 
193
+ def choices_include?(choices, includes)
194
+ choices.each do |choice|
195
+ value = choice.is_a?(Array) ? choice.last : choice
196
+ return true if value == includes
197
+ end
198
+ false
199
+ end
200
+
194
201
  def add_page_links_defaults!(options)
195
202
  add_searchgasm_control_defaults!(options)
196
203
  options[:first_page] ||= 1
@@ -67,7 +67,7 @@ module Searchgasm
67
67
 
68
68
  MAJOR = 1
69
69
  MINOR = 5
70
- TINY = 0
70
+ TINY = 1
71
71
 
72
72
  # The current version as a Version instance
73
73
  CURRENT = new(MAJOR, MINOR, TINY)
data/searchgasm.gemspec CHANGED
@@ -1,11 +1,11 @@
1
1
 
2
- # Gem::Specification for Searchgasm-1.5.0
2
+ # Gem::Specification for Searchgasm-1.5.1
3
3
  # Originally generated by Echoe
4
4
 
5
5
  --- !ruby/object:Gem::Specification
6
6
  name: searchgasm
7
7
  version: !ruby/object:Gem::Version
8
- version: 1.5.0
8
+ version: 1.5.1
9
9
  platform: ruby
10
10
  authors:
11
11
  - Ben Johnson of Binary Logic
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searchgasm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Johnson of Binary Logic