searchgasm 1.5.0 → 1.5.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/CHANGELOG.rdoc +5 -0
- data/lib/searchgasm/config/helpers.rb +12 -1
- data/lib/searchgasm/helpers/control_types/links.rb +13 -6
- data/lib/searchgasm/version.rb +1 -1
- data/searchgasm.gemspec +2 -2
- metadata +1 -1
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",
|
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 =
|
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]
|
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
|
data/lib/searchgasm/version.rb
CHANGED
data/searchgasm.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
|
2
|
-
# Gem::Specification for Searchgasm-1.5.
|
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.
|
8
|
+
version: 1.5.1
|
9
9
|
platform: ruby
|
10
10
|
authors:
|
11
11
|
- Ben Johnson of Binary Logic
|