diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-03-19 09:00:36 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-03-19 09:00:36 +0000 |
commit | 17ea1539ef03607a1dfac792e43fe7c2c9c8bf7d (patch) | |
tree | 6d382a557e61293f0aef2b6d7bea65d8ca912a1b /app/controllers | |
parent | 5d9b87de3a9df6fcb256efa5f2274845b6050085 (diff) | |
download | redmine-17ea1539ef03607a1dfac792e43fe7c2c9c8bf7d.tar.gz redmine-17ea1539ef03607a1dfac792e43fe7c2c9c8bf7d.zip |
Previous/next links may be lost after editing the issue (#14462).
git-svn-id: http://svn.redmine.org/redmine/trunk@15253 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/issues_controller.rb | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 71d06f1ae..51999544f 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -191,7 +191,7 @@ class IssuesController < ApplicationController flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? respond_to do |format| - format.html { redirect_back_or_default issue_path(@issue) } + format.html { redirect_back_or_default issue_path(@issue, previous_and_next_issue_ids_params) } format.api { render_api_ok } end else @@ -354,23 +354,39 @@ class IssuesController < ApplicationController private 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), :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 + if params[:prev_issue_id].present? || params[:next_issue_id].present? + @prev_issue_id = params[:prev_issue_id].presence.try(:to_i) + @next_issue_id = params[:next_issue_id].presence.try(:to_i) + @issue_position = params[:issue_position].presence.try(:to_i) + @issue_count = params[:issue_count].presence.try(:to_i) + else + 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), :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 - @prev_issue_id = issue_ids[idx - 1] if idx > 0 - @next_issue_id = issue_ids[idx + 1] if idx < (issue_ids.size - 1) end end end + def previous_and_next_issue_ids_params + { + :prev_issue_id => params[:prev_issue_id], + :next_issue_id => params[:next_issue_id], + :issue_position => params[:issue_position], + :issue_count => params[:issue_count] + }.reject {|k,v| k.blank?} + end + # Used by #edit and #update to set some common instance variables # from the params def update_issue_from_params |