From: Go MAEDA Date: Sun, 29 Oct 2023 11:45:56 +0000 (+0000) Subject: Merged r22395 from trunk to 5.1-stable (#38493). X-Git-Tag: 5.1.0~9 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=67c268476ab38d7e1fa70ae02cd348da702a679a;p=redmine.git Merged r22395 from trunk to 5.1-stable (#38493). git-svn-id: https://svn.redmine.org/redmine/branches/5.1-stable@22396 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/controllers/issue_relations_controller.rb b/app/controllers/issue_relations_controller.rb index 91297ac76..519cb9922 100644 --- a/app/controllers/issue_relations_controller.rb +++ b/app/controllers/issue_relations_controller.rb @@ -68,7 +68,7 @@ class IssueRelationsController < ApplicationController respond_to do |format| format.html {redirect_to issue_path(@issue)} format.js do - @relations = @issue.reload.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible?} + @relations = select_relations(@issue) @unsaved_relations = unsaved_relations end format.api do @@ -89,7 +89,10 @@ class IssueRelationsController < ApplicationController respond_to do |format| format.html {redirect_to issue_path(@relation.issue_from)} - format.js + format.js do + find_issue + @relations = select_relations(@issue) + end format.api {render_api_ok} end end @@ -123,4 +126,8 @@ class IssueRelationsController < ApplicationController # ToDo: Find a better method to return an error if the param is missing. [''] end + + def select_relations(issue) + issue.reload.relations.select {|r| r.other_issue(issue) && r.other_issue(issue).visible?} + end end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 9a40b0188..80e3de855 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -208,7 +208,7 @@ module IssuesHelper if manage_relations link_to( l(:label_relation_delete), - relation_path(relation), + relation_path(relation, issue_id: issue.id), :remote => true, :method => :delete, :data => {:confirm => l(:text_are_you_sure)}, diff --git a/app/views/issue_relations/destroy.js.erb b/app/views/issue_relations/destroy.js.erb index f5f29d31d..49e5fa051 100644 --- a/app/views/issue_relations/destroy.js.erb +++ b/app/views/issue_relations/destroy.js.erb @@ -1 +1,2 @@ $('#relation-<%= @relation.id %>').remove(); +$(".issues-stat").replaceWith('<%= escape_javascript(render_relations_stats(@issue, @relations)) %>') diff --git a/test/functional/issue_relations_controller_test.rb b/test/functional/issue_relations_controller_test.rb index 7bb269ce9..ff92e1be5 100644 --- a/test/functional/issue_relations_controller_test.rb +++ b/test/functional/issue_relations_controller_test.rb @@ -316,7 +316,7 @@ class IssueRelationsControllerTest < Redmine::ControllerTest end assert_difference 'IssueRelation.count', -1 do - delete(:destroy, :params => {:id => '2'}, :xhr => true) + delete(:destroy, :params => {:id => '2', :issue_id => '2'}, :xhr => true) assert_response :success assert_equal 'text/javascript', response.media_type assert_include 'relation-2', response.body