]> source.dussan.org Git - redmine.git/commitdiff
Display the position of the current issue in the query results.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 16 Jan 2012 18:24:59 +0000 (18:24 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 16 Jan 2012 18:24:59 +0000 (18:24 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8663 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb
app/views/issues/show.html.erb
test/functional/issues_controller_test.rb

index 8cd34d08ea2f7a386b3ad35accc05c4a499afb97..358faf5078ef4a58b5944df1be52c9e1e3fefb33 100644 (file)
@@ -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
index a0bbf61fec24e2e07b785decb6726aa346349ba9..8c8c9070ab205904bbad26626a191510f78c00f0 100644 (file)
@@ -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),
index 391b8f839b859fcb6e381feeb0f0a5d4687f89d2..13002c296fb7d950c504c2c1a9baf856e1cdb6a8 100644 (file)
@@ -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