mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
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
This commit is contained in:
parent
5d9b87de3a
commit
17ea1539ef
@ -191,7 +191,7 @@ class IssuesController < ApplicationController
|
|||||||
flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
|
flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
|
||||||
|
|
||||||
respond_to do |format|
|
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 }
|
format.api { render_api_ok }
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -354,23 +354,39 @@ class IssuesController < ApplicationController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def retrieve_previous_and_next_issue_ids
|
def retrieve_previous_and_next_issue_ids
|
||||||
retrieve_query_from_session
|
if params[:prev_issue_id].present? || params[:next_issue_id].present?
|
||||||
if @query
|
@prev_issue_id = params[:prev_issue_id].presence.try(:to_i)
|
||||||
sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
|
@next_issue_id = params[:next_issue_id].presence.try(:to_i)
|
||||||
sort_update(@query.sortable_columns, 'issues_index_sort')
|
@issue_position = params[:issue_position].presence.try(:to_i)
|
||||||
limit = 500
|
@issue_count = params[:issue_count].presence.try(:to_i)
|
||||||
issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1), :include => [:assigned_to, :tracker, :priority, :category, :fixed_version])
|
else
|
||||||
if (idx = issue_ids.index(@issue.id)) && idx < limit
|
retrieve_query_from_session
|
||||||
if issue_ids.size < 500
|
if @query
|
||||||
@issue_position = idx + 1
|
sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
|
||||||
@issue_count = issue_ids.size
|
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
|
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
|
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
|
# Used by #edit and #update to set some common instance variables
|
||||||
# from the params
|
# from the params
|
||||||
def update_issue_from_params
|
def update_issue_from_params
|
||||||
|
|||||||
@ -49,6 +49,11 @@
|
|||||||
<%= submit_tag l(:button_submit) %>
|
<%= submit_tag l(:button_submit) %>
|
||||||
<%= preview_link preview_edit_issue_path(:project_id => @project, :id => @issue), 'issue-form' %>
|
<%= preview_link preview_edit_issue_path(:project_id => @project, :id => @issue), 'issue-form' %>
|
||||||
| <%= link_to l(:button_cancel), {}, :onclick => "$('#update').hide(); return false;" %>
|
| <%= link_to l(:button_cancel), {}, :onclick => "$('#update').hide(); return false;" %>
|
||||||
|
|
||||||
|
<%= hidden_field_tag 'prev_issue_id', @prev_issue_id if @prev_issue_id %>
|
||||||
|
<%= hidden_field_tag 'next_issue_id', @next_issue_id if @next_issue_id %>
|
||||||
|
<%= hidden_field_tag 'issue_position', @issue_position if @issue_position %>
|
||||||
|
<%= hidden_field_tag 'issue_count', @issue_count if @issue_count %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div id="preview" class="wiki"></div>
|
<div id="preview" class="wiki"></div>
|
||||||
|
|||||||
@ -1423,6 +1423,17 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_show_should_display_prev_next_links_when_request_has_previous_and_next_issue_ids_params
|
||||||
|
get :show, :id => 1, :prev_issue_id => 1, :next_issue_id => 3, :issue_position => 2, :issue_count => 4
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
assert_select 'div.next-prev-links' do
|
||||||
|
assert_select 'a[href="/issues/1"]', :text => /Previous/
|
||||||
|
assert_select 'a[href="/issues/3"]', :text => /Next/
|
||||||
|
assert_select 'span.position', :text => "2 of 4"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_show_should_display_category_field_if_categories_are_defined
|
def test_show_should_display_category_field_if_categories_are_defined
|
||||||
Issue.update_all :category_id => nil
|
Issue.update_all :category_id => nil
|
||||||
|
|
||||||
@ -3681,6 +3692,19 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id
|
assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_put_update_should_redirect_with_previous_and_next_issue_ids_params
|
||||||
|
@request.session[:user_id] = 2
|
||||||
|
|
||||||
|
put :update, :id => 11,
|
||||||
|
:issue => {:status_id => 6, :notes => 'Notes'},
|
||||||
|
:prev_issue_id => 8,
|
||||||
|
:next_issue_id => 12,
|
||||||
|
:issue_position => 2,
|
||||||
|
:issue_count => 3
|
||||||
|
|
||||||
|
assert_redirected_to '/issues/11?issue_count=3&issue_position=2&next_issue_id=12&prev_issue_id=8'
|
||||||
|
end
|
||||||
|
|
||||||
def test_get_bulk_edit
|
def test_get_bulk_edit
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user