Added some compatibility wrappers for the stable 0.8.x version of Redmine.

This commit is contained in:
Eric Davis
2009-04-21 21:35:13 -07:00
parent 1e10952506
commit df0ecda7ff
2 changed files with 50 additions and 0 deletions
+45
View File
@@ -22,6 +22,17 @@ module RateSortHelperPatch
# Allows more parameters than the standard sort_link and is hard coded to use
# the RatesController and to have an :method and :update options
def rate_sort_link(column, caption, default_order, options = { })
# 0.8.x compatibility
if SortHelper.const_defined? 'SortCriteria'
rate_sort_link_trunk_version(column, caption, default_order, options)
else
rate_sort_link_08_version(column, caption, default_order, options)
end
end
private
# Trunk version of sort_link. Was modified in r2571 of Redmine
def rate_sort_link_trunk_version(column, caption, default_order, options = { })
css, order = nil, default_order
if column.to_s == @sort_criteria.first_key
@@ -54,6 +65,40 @@ module RateSortHelperPatch
{:href => url_for(url_options),
:class => css})
end
private
# 0.8.x branch of sort_link.
def rate_sort_link_08_version(column, caption, default_order, options = { })
key, order = session[@sort_name][:key], session[@sort_name][:order]
if key == column
if order.downcase == 'asc'
icon = 'sort_asc.png'
order = 'desc'
else
icon = 'sort_desc.png'
order = 'asc'
end
else
icon = nil
order = default_order
end
caption = titleize(Inflector::humanize(column)) unless caption
sort_options = { :sort_key => column, :sort_order => order }
# don't reuse params if filters are present
url_options = params.has_key?(:set_filter) ? sort_options : params.merge(sort_options)
##### Hard code url to the Rates index
url_options[:controller] = 'rates'
url_options[:action] = 'index'
url_options[:user_id] ||= options[:user_id]
#####
link_to_remote(caption,
{:update => options[:update] || "content", :url => url_options, :method => options[:method] || :post},
{:href => url_for(url_options)}) +
(icon ? nbsp(2) + image_tag(icon) : '')
end
end
end