]> source.dussan.org Git - redmine.git/commitdiff
Merged r21578-r21580 to 5.0-stable (#37053).
authorMarius Balteanu <marius.balteanu@zitec.com>
Mon, 16 May 2022 21:29:04 +0000 (21:29 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Mon, 16 May 2022 21:29:04 +0000 (21:29 +0000)
git-svn-id: https://svn.redmine.org/redmine/branches/5.0-stable@21581 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/views/issues/edit.js.erb
public/javascripts/application.js
test/system/issues_test.rb

index ed8fc3ca832a02b8741db4a6e04878b24d2ff8dd..e953368243f7fe6109af5a401241ab29524b6de7 100644 (file)
@@ -1 +1,14 @@
-replaceIssueFormWith('<%= escape_javascript(render :partial => 'edit') %>');
+replaceIssueFormWith('<%= escape_javascript(render :partial => 'form') %>');
+<% if User.current.allowed_to?(:log_time, @issue.project) %>
+  $('#log_time').show();
+<% else %>
+  $('#log_time').hide();
+<% end %>
+
+<% if @issue.notes_addable? %>
+  $('#add_notes').show();
+  $('#add_attachments').show();
+<% else %>
+  $('#add_notes').hide();
+  $('#add_attachments').hide();
+<% end %>
\ No newline at end of file
index efff38da7dcdbf13ec590683eedb511fafbcd743..91da192290589e7243de65d5019a0888ff78fdbc 100644 (file)
@@ -622,13 +622,8 @@ function replaceIssueFormWith(html){
       replacement.find('#'+object_id).val($(this).val());
     }
   });
-
-  if ($('form.new_issue').length > 0) {
-    $('#all_attributes').empty();
-    $('#all_attributes').prepend(replacement);
-  } else {
-    $('#issue-form').replaceWith(replacement);
-  }
+  $('#all_attributes').empty();
+  $('#all_attributes').prepend(replacement);
 }
 
 function updateBulkEditFrom(url) {
index 2476dc43eb8483d5c2806e36d49bb93db466c0ba..5179c6e80b1f3ef55013509ff07714ebfd23eda0 100644 (file)
@@ -256,6 +256,26 @@ class IssuesSystemTest < ApplicationSystemTestCase
     assert_equal 5, issue.reload.status.id
   end
 
+  def test_update_issue_with_form_update_should_keep_newly_added_attachments
+    set_tmp_attachments_directory
+    log_user('jsmith', 'jsmith')
+
+    visit '/issues/2'
+    page.first(:link, 'Edit').click
+    attach_file 'attachments[dummy][file]', Rails.root.join('test/fixtures/files/testfile.txt')
+
+    assert page.has_css?('span#attachments_1')
+
+    page.find("#issue_status_id").select("Closed")
+
+    # check that attachment still exists on the page
+    assert page.has_css?('span#attachments_1')
+
+    click_on 'Submit'
+
+    assert_equal 1, Issue.find(2).attachments.count
+  end
+
   test "removing issue shows confirm dialog" do
     log_user('jsmith', 'jsmith')
     visit '/issues/1'