summaryrefslogtreecommitdiffstats
path: root/app
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
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')
-rw-r--r--app/controllers/issues_controller.rb19
-rw-r--r--app/helpers/queries_helper.rb12
-rw-r--r--app/helpers/sort_helper.rb3
-rw-r--r--app/views/issues/show.html.erb9
4 files changed, 40 insertions, 3 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
diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb
index c2d72fb59..afb560c61 100644
--- a/app/helpers/queries_helper.rb
+++ b/app/helpers/queries_helper.rb
@@ -92,6 +92,18 @@ module QueriesHelper
end
end
+ def retrieve_query_from_session
+ if session[:query]
+ @query = Query.new(:name => "_", :filters => session[:query][:filters], :group_by => session[:query][:group_by], :column_names => session[:query][:column_names])
+ if session[:query].has_key?(:project_id)
+ @query.project_id = session[:query][:project_id]
+ else
+ @query.project = @project
+ end
+ @query
+ end
+ end
+
def build_query_from_params
if params[:fields] || params[:f]
@query.filters = {}
diff --git a/app/helpers/sort_helper.rb b/app/helpers/sort_helper.rb
index 9f8ac6470..9fda5982b 100644
--- a/app/helpers/sort_helper.rb
+++ b/app/helpers/sort_helper.rb
@@ -160,7 +160,8 @@ module SortHelper
# sort_clause.
# - criteria can be either an array or a hash of allowed keys
#
- def sort_update(criteria)
+ def sort_update(criteria, sort_name=nil)
+ sort_name ||= self.sort_name
@sort_criteria = SortCriteria.new
@sort_criteria.available_criteria = criteria
@sort_criteria.from_param(params[:sort] || session[sort_name])
diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb
index c3e23a776..d23458a1f 100644
--- a/app/views/issues/show.html.erb
+++ b/app/views/issues/show.html.erb
@@ -3,7 +3,14 @@
<h2><%= issue_heading(@issue) %></h2>
<div class="<%= @issue.css_classes %> details">
- <%= avatar(@issue.author, :size => "50") %>
+ <% if @prev_issue_id || @next_issue_id %>
+ <div class="next-prev-links contextual">
+ <%= link_to_if @prev_issue_id, '&#171; Previous', issue_path(@prev_issue_id), :title => "##{@prev_issue_id}" %> |
+ <%= link_to_if @next_issue_id, 'Next &#187;', issue_path(@next_issue_id), :title => "##{@next_issue_id}" %>
+ </div>
+ <% end %>
+
+ <%= avatar(@issue.author, :size => "50") %>
<div class="subject">
<%= render_issue_subject_with_tree(@issue) %>