[#2397] Fixed sorting. Was an API change in the Redmine core.

This commit is contained in:
Eric Davis committed 2009-04-21 21:11:38 -07:00
1 parent c62d2c0a73
commit 1e10952506
1 file changed
+19 -20
+19 -20
View File
@@ -20,40 +20,39 @@ module RateSortHelperPatch
end end
# Allows more parameters than the standard sort_link and is hard coded to use # Allows more parameters than the standard sort_link and is hard coded to use
# the RatesController # the RatesController and to have an :method and :update options
def rate_sort_link(column, caption, default_order, options = { }) def rate_sort_link(column, caption, default_order, options = { })
key, order = session[@sort_name][:key], session[@sort_name][:order] css, order = nil, default_order
if key == column
if order.downcase == 'asc' if column.to_s == @sort_criteria.first_key
icon = 'sort_asc.png' if @sort_criteria.first_asc?
css = 'sort asc'
order = 'desc' order = 'desc'
else else
icon = 'sort_desc.png' css = 'sort desc'
order = 'asc' order = 'asc'
end end
else
icon = nil
order = default_order
end end
caption = titleize(Inflector::humanize(column)) unless caption caption = column.to_s.humanize unless caption
sort_options = { :sort_key => column, :sort_order => order} sort_options = { :sort => @sort_criteria.add(column.to_s, order).to_param }
# don't reuse params if filters are present # don't reuse params if filters are present
url_options = params.has_key?(:set_filter) ? sort_options : params.merge(sort_options) url_options = params.has_key?(:set_filter) ? sort_options : params.merge(sort_options)
# Add project_id to url_options
url_options = url_options.merge(:project_id => params[:project_id]) if params.has_key?(:project_id)
# Hard code url to the Rates index ##### Hard code url to the Rates index
url_options[:controller] = 'rates' url_options[:controller] = 'rates'
url_options[:action] = 'index' url_options[:action] = 'index'
url_options[:user_id] ||= options[:user_id] url_options[:user_id] ||= options[:user_id]
#####
link_to_remote(caption, link_to_remote(caption,
{ {:update => options[:update] || "content", :url => url_options, :method => options[:method] || :post},
:update => options[:update] || "content", {:href => url_for(url_options),
:url => url_options, :class => css})
:method => options[:method] || :post
},
{:href => url_for(url_options)}) +
(icon ? nbsp(2) + image_tag(icon) : '')
end end
end end