Patch #7594 » proper-pagination-1.1.0.patch
| redmine-1.1.0-proper-pagination/app/helpers/application_helper.rb 2011-02-09 12:42:19.711990100 -0700 | ||
|---|---|---|
|
|
||
|
html = ''
|
||
|
if paginator.current.previous
|
||
|
html << link_to_remote_content_update('« ' + l(:label_previous), url_param.merge(page_param => paginator.current.previous)) + ' '
|
||
|
html << pagination_link('« ' + l(:label_previous), url_param.merge(page_param => paginator.current.previous)) + ' '
|
||
|
end
|
||
|
|
||
|
html << (pagination_links_each(paginator, options) do |n|
|
||
|
link_to_remote_content_update(n.to_s, url_param.merge(page_param => n))
|
||
|
pagination_link(n.to_s, url_param.merge(page_param => n))
|
||
|
end || '')
|
||
|
|
||
|
if paginator.current.next
|
||
|
html << ' ' + link_to_remote_content_update((l(:label_next) + ' »'), url_param.merge(page_param => paginator.current.next))
|
||
|
html << ' ' + pagination_link((l(:label_next) + ' »'), url_param.merge(page_param => paginator.current.next))
|
||
|
end
|
||
|
|
||
|
unless count.nil?
|
||
| ... | ... | |
|
url_param.clear if url_param.has_key?(:set_filter)
|
||
|
|
||
|
links = Setting.per_page_options_array.collect do |n|
|
||
|
n == selected ? n : link_to_remote(n, {:update => "content",
|
||
|
:url => params.dup.merge(:per_page => n),
|
||
|
:method => :get},
|
||
|
{:href => url_for(url_param.merge(:per_page => n))})
|
||
|
n == selected ? n : pagination_link(n, url_param.merge(:per_page => n))
|
||
|
end
|
||
|
links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil
|
||
|
end
|
||
|
|
||
|
def pagination_link(text, url_params)
|
||
|
# !!!HACK!!!
|
||
|
# To use direct link pagination for improved browser history and bookmarking, we want to
|
||
|
# trim the number of paramters down to the normal ones you'd see in an non-Ajax update link.
|
||
|
# However, this causes problems with some controllers, as parameters can be lost. Use a hash
|
||
|
# to isolate these parameters and controllers rather than implementing a real pagination fix.
|
||
|
controller_show_params = { "all" => ["action", "query_id", "page", "per_page", "controller"],
|
||
|
"users" => ["status", "name"] }
|
||
|
#logger.error("#{url_params.inspect}") # peek at URL parameters for improving the above hash
|
||
|
show_params = (controller_show_params['all'] << controller_show_params[url_params['controller']]).flatten
|
||
|
url_params.delete_if {|p, v| !show_params.include?(p)}
|
||
|
link_to(text, url_for(url_params))
|
||
|
end
|
||
|
|
||
|
def reorder_links(name, url)
|
||
|
link_to(image_tag('2uparrow.png', :alt => l(:label_sort_highest)), url.merge({"#{name}[move_to]" => 'highest'}), :method => :post, :title => l(:label_sort_highest)) +
|
||
|
link_to(image_tag('1uparrow.png', :alt => l(:label_sort_higher)), url.merge({"#{name}[move_to]" => 'higher'}), :method => :post, :title => l(:label_sort_higher)) +
|
||