Display the position of the current issue in the query results.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8663 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
dfe26befdd
commit
44a898a210
|
@ -330,6 +330,10 @@ private
|
|||
limit = 500
|
||||
issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1), :include => [:assigned_to, :tracker, :priority, :category, :fixed_version])
|
||||
if (idx = issue_ids.index(@issue.id)) && idx < limit
|
||||
if issue_ids.size < 500
|
||||
@issue_position = idx + 1
|
||||
@issue_count = issue_ids.size
|
||||
end
|
||||
@prev_issue_id = issue_ids[idx - 1] if idx > 0
|
||||
@next_issue_id = issue_ids[idx + 1] if idx < (issue_ids.size - 1)
|
||||
end
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
"\xc2\xab #{l(:label_previous)}",
|
||||
issue_path(@prev_issue_id),
|
||||
:title => "##{@prev_issue_id}" %> |
|
||||
<% if @issue_position && @issue_count %>
|
||||
<span class="position"><%= "#{@issue_position}/#{@issue_count}" %></span> |
|
||||
<% end %>
|
||||
<%= link_to_if @next_issue_id,
|
||||
"#{l(:label_next)} \xc2\xbb",
|
||||
issue_path(@next_issue_id),
|
||||
|
|
|
@ -928,6 +928,8 @@ class IssuesControllerTest < ActionController::TestCase
|
|||
assert_response :success
|
||||
assert_nil assigns(:prev_issue_id)
|
||||
assert_nil assigns(:next_issue_id)
|
||||
|
||||
assert_no_tag 'div', :attributes => {:class => /next-prev-links/}
|
||||
end
|
||||
|
||||
def test_show_should_display_prev_next_links_with_query_in_session
|
||||
|
@ -943,8 +945,12 @@ class IssuesControllerTest < ActionController::TestCase
|
|||
assert_equal 2, assigns(:prev_issue_id)
|
||||
assert_equal 5, assigns(:next_issue_id)
|
||||
|
||||
assert_tag 'div', :attributes => {:class => /next-prev-links/}
|
||||
assert_tag 'a', :attributes => {:href => '/issues/2'}, :content => /Previous/
|
||||
assert_tag 'a', :attributes => {:href => '/issues/5'}, :content => /Next/
|
||||
|
||||
count = Issue.open.visible.count
|
||||
assert_tag 'span', :attributes => {:class => 'position'}, :content => "3/#{count}"
|
||||
end
|
||||
|
||||
def test_show_should_display_prev_next_links_with_saved_query_in_session
|
||||
|
|
Loading…
Reference in New Issue