@@ -191,7 +191,7 class IssuesController < ApplicationController | |||||
191 | flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? |
|
191 | flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? | |
192 |
|
192 | |||
193 | respond_to do |format| |
|
193 | respond_to do |format| | |
194 | format.html { redirect_back_or_default issue_path(@issue) } |
|
194 | format.html { redirect_back_or_default issue_path(@issue, previous_and_next_issue_ids_params) } | |
195 | format.api { render_api_ok } |
|
195 | format.api { render_api_ok } | |
196 | end |
|
196 | end | |
197 | else |
|
197 | else | |
@@ -354,23 +354,39 class IssuesController < ApplicationController | |||||
354 | private |
|
354 | private | |
355 |
|
355 | |||
356 | def retrieve_previous_and_next_issue_ids |
|
356 | def retrieve_previous_and_next_issue_ids | |
357 | retrieve_query_from_session |
|
357 | if params[:prev_issue_id].present? || params[:next_issue_id].present? | |
358 | if @query |
|
358 | @prev_issue_id = params[:prev_issue_id].presence.try(:to_i) | |
359 | sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria) |
|
359 | @next_issue_id = params[:next_issue_id].presence.try(:to_i) | |
360 | sort_update(@query.sortable_columns, 'issues_index_sort') |
|
360 | @issue_position = params[:issue_position].presence.try(:to_i) | |
361 | limit = 500 |
|
361 | @issue_count = params[:issue_count].presence.try(:to_i) | |
362 | issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1), :include => [:assigned_to, :tracker, :priority, :category, :fixed_version]) |
|
362 | else | |
363 | if (idx = issue_ids.index(@issue.id)) && idx < limit |
|
363 | retrieve_query_from_session | |
364 | if issue_ids.size < 500 |
|
364 | if @query | |
365 | @issue_position = idx + 1 |
|
365 | sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria) | |
366 | @issue_count = issue_ids.size |
|
366 | sort_update(@query.sortable_columns, 'issues_index_sort') | |
|
367 | limit = 500 | |||
|
368 | issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1), :include => [:assigned_to, :tracker, :priority, :category, :fixed_version]) | |||
|
369 | if (idx = issue_ids.index(@issue.id)) && idx < limit | |||
|
370 | if issue_ids.size < 500 | |||
|
371 | @issue_position = idx + 1 | |||
|
372 | @issue_count = issue_ids.size | |||
|
373 | end | |||
|
374 | @prev_issue_id = issue_ids[idx - 1] if idx > 0 | |||
|
375 | @next_issue_id = issue_ids[idx + 1] if idx < (issue_ids.size - 1) | |||
367 | end |
|
376 | end | |
368 | @prev_issue_id = issue_ids[idx - 1] if idx > 0 |
|
|||
369 | @next_issue_id = issue_ids[idx + 1] if idx < (issue_ids.size - 1) |
|
|||
370 | end |
|
377 | end | |
371 | end |
|
378 | end | |
372 | end |
|
379 | end | |
373 |
|
380 | |||
|
381 | def previous_and_next_issue_ids_params | |||
|
382 | { | |||
|
383 | :prev_issue_id => params[:prev_issue_id], | |||
|
384 | :next_issue_id => params[:next_issue_id], | |||
|
385 | :issue_position => params[:issue_position], | |||
|
386 | :issue_count => params[:issue_count] | |||
|
387 | }.reject {|k,v| k.blank?} | |||
|
388 | end | |||
|
389 | ||||
374 | # Used by #edit and #update to set some common instance variables |
|
390 | # Used by #edit and #update to set some common instance variables | |
375 | # from the params |
|
391 | # from the params | |
376 | def update_issue_from_params |
|
392 | def update_issue_from_params |
@@ -49,6 +49,11 | |||||
49 | <%= submit_tag l(:button_submit) %> |
|
49 | <%= submit_tag l(:button_submit) %> | |
50 | <%= preview_link preview_edit_issue_path(:project_id => @project, :id => @issue), 'issue-form' %> |
|
50 | <%= preview_link preview_edit_issue_path(:project_id => @project, :id => @issue), 'issue-form' %> | |
51 | | <%= link_to l(:button_cancel), {}, :onclick => "$('#update').hide(); return false;" %> |
|
51 | | <%= link_to l(:button_cancel), {}, :onclick => "$('#update').hide(); return false;" %> | |
|
52 | ||||
|
53 | <%= hidden_field_tag 'prev_issue_id', @prev_issue_id if @prev_issue_id %> | |||
|
54 | <%= hidden_field_tag 'next_issue_id', @next_issue_id if @next_issue_id %> | |||
|
55 | <%= hidden_field_tag 'issue_position', @issue_position if @issue_position %> | |||
|
56 | <%= hidden_field_tag 'issue_count', @issue_count if @issue_count %> | |||
52 | <% end %> |
|
57 | <% end %> | |
53 |
|
58 | |||
54 | <div id="preview" class="wiki"></div> |
|
59 | <div id="preview" class="wiki"></div> |
@@ -1423,6 +1423,17 class IssuesControllerTest < ActionController::TestCase | |||||
1423 | end |
|
1423 | end | |
1424 | end |
|
1424 | end | |
1425 |
|
1425 | |||
|
1426 | def test_show_should_display_prev_next_links_when_request_has_previous_and_next_issue_ids_params | |||
|
1427 | get :show, :id => 1, :prev_issue_id => 1, :next_issue_id => 3, :issue_position => 2, :issue_count => 4 | |||
|
1428 | assert_response :success | |||
|
1429 | ||||
|
1430 | assert_select 'div.next-prev-links' do | |||
|
1431 | assert_select 'a[href="/issues/1"]', :text => /Previous/ | |||
|
1432 | assert_select 'a[href="/issues/3"]', :text => /Next/ | |||
|
1433 | assert_select 'span.position', :text => "2 of 4" | |||
|
1434 | end | |||
|
1435 | end | |||
|
1436 | ||||
1426 | def test_show_should_display_category_field_if_categories_are_defined |
|
1437 | def test_show_should_display_category_field_if_categories_are_defined | |
1427 | Issue.update_all :category_id => nil |
|
1438 | Issue.update_all :category_id => nil | |
1428 |
|
1439 | |||
@@ -3681,6 +3692,19 class IssuesControllerTest < ActionController::TestCase | |||||
3681 | assert_response :redirect |
|
3692 | assert_response :redirect | |
3682 | assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id |
|
3693 | assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id | |
3683 | end |
|
3694 | end | |
|
3695 | ||||
|
3696 | def test_put_update_should_redirect_with_previous_and_next_issue_ids_params | |||
|
3697 | @request.session[:user_id] = 2 | |||
|
3698 | ||||
|
3699 | put :update, :id => 11, | |||
|
3700 | :issue => {:status_id => 6, :notes => 'Notes'}, | |||
|
3701 | :prev_issue_id => 8, | |||
|
3702 | :next_issue_id => 12, | |||
|
3703 | :issue_position => 2, | |||
|
3704 | :issue_count => 3 | |||
|
3705 | ||||
|
3706 | assert_redirected_to '/issues/11?issue_count=3&issue_position=2&next_issue_id=12&prev_issue_id=8' | |||
|
3707 | end | |||
3684 |
|
3708 | |||
3685 | def test_get_bulk_edit |
|
3709 | def test_get_bulk_edit | |
3686 | @request.session[:user_id] = 2 |
|
3710 | @request.session[:user_id] = 2 |
General Comments 0
You need to be logged in to leave comments.
Login now