summaryrefslogtreecommitdiffstats
path: root/app/controllers/issues_controller.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-03 20:09:44 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-03 20:09:44 +0000
commitb1504ceb434c0fd2543db2f27b46c25898e72f6d (patch)
tree458144eea3f95ddb835a35250cac9be0535d2d4c /app/controllers/issues_controller.rb
parentbbe1ff3ec97b5e7865309a4ebe08623a7feb8b40 (diff)
downloadredmine-b1504ceb434c0fd2543db2f27b46c25898e72f6d.tar.gz
redmine-b1504ceb434c0fd2543db2f27b46c25898e72f6d.zip
Adds previous/next links to issue (#2850).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8488 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/issues_controller.rb')
-rw-r--r--app/controllers/issues_controller.rb19
1 files changed, 18 insertions, 1 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index 353a3b977..7b3684c85 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -120,7 +120,10 @@ class IssuesController < ApplicationController
@priorities = IssuePriority.active
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
respond_to do |format|
- format.html { render :template => 'issues/show' }
+ format.html {
+ retrieve_previous_and_next_issue_ids
+ render :template => 'issues/show'
+ }
format.api
format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
@@ -277,6 +280,20 @@ private
render_404
end
+ def retrieve_previous_and_next_issue_ids
+ retrieve_query_from_session
+ if @query
+ sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
+ sort_update(@query.sortable_columns, 'issues_index_sort')
+ limit = 500
+ issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1))
+ if (idx = issue_ids.index(@issue.id.to_s)) && idx < limit
+ @prev_issue_id = issue_ids[idx - 1].to_i if idx > 0
+ @next_issue_id = issue_ids[idx + 1].to_i if idx < (issue_ids.size - 1)
+ end
+ end
+ end
+
# Used by #edit and #update to set some common instance variables
# from the params
# TODO: Refactor, not everything in here is needed by #edit