Project

General

Profile

Defect #38493 » 0001-Rerender-the-status-of-related-issues.patch

Takashi Kato, 2023-10-27 12:49

View differences:

app/controllers/issue_relations_controller.rb
68 68
    respond_to do |format|
69 69
      format.html {redirect_to issue_path(@issue)}
70 70
      format.js do
71
        @relations = @issue.reload.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible?}
71
        @relations = select_relations(@issue)
72 72
        @unsaved_relations = unsaved_relations
73 73
      end
74 74
      format.api do
......
89 89

  
90 90
    respond_to do |format|
91 91
      format.html {redirect_to issue_path(@relation.issue_from)}
92
      format.js
92
      format.js do
93
        find_issue
94
        @relations = select_relations(@issue)
95
      end
93 96
      format.api  {render_api_ok}
94 97
    end
95 98
  end
......
123 126
    # ToDo: Find a better method to return an error if the param is missing.
124 127
    ['']
125 128
  end
129

  
130
  def select_relations(issue)
131
    issue.reload.relations.select {|r| r.other_issue(issue) && r.other_issue(issue).visible?}
132
  end
126 133
end
app/helpers/issues_helper.rb
208 208
        if manage_relations
209 209
          link_to(
210 210
            l(:label_relation_delete),
211
            relation_path(relation),
211
            relation_path(relation, issue_id: issue.id),
212 212
            :remote => true,
213 213
            :method => :delete,
214 214
            :data => {:confirm => l(:text_are_you_sure)},
app/views/issue_relations/destroy.js.erb
1 1
$('#relation-<%= @relation.id %>').remove();
2
$(".issues-stat").replaceWith('<%= escape_javascript(render_relations_stats(@issue, @relations)) %>')
test/functional/issue_relations_controller_test.rb
316 316
    end
317 317

  
318 318
    assert_difference 'IssueRelation.count', -1 do
319
      delete(:destroy, :params => {:id => '2'}, :xhr => true)
319
      delete(:destroy, :params => {:id => '2', :issue_id => '2'}, :xhr => true)
320 320
      assert_response :success
321 321
      assert_equal 'text/javascript', response.media_type
322 322
      assert_include 'relation-2', response.body
(2-2/2)