https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292018-07-09T06:30:04ZRedmineRedmine - Defect #28953: Issue content gets lost if user deletes an attachmenthttps://www.redmine.org/issues/28953?journal_id=861332018-07-09T06:30:04ZTakenori TAKAKItakenory@gmail.com
<ul><li><strong>File</strong> <a href="/attachments/21058">diff-r17439.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/21058/diff-r17439.patch">diff-r17439.patch</a> added</li></ul><p>I propose a patch to asynchronize deletion of attachment.<br />With this change, user will not lose his text changes.</p>
<p>This patch works with the latest Redmine trunk (<a class="changeset" title="Extend watched_by_me-issue filter to include all project-members instead of only <<me>>-substitut..." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/17439">r17439</a>).</p> Redmine - Defect #28953: Issue content gets lost if user deletes an attachmenthttps://www.redmine.org/issues/28953?journal_id=861402018-07-09T12:44:22ZGo MAEDA
<ul><li><strong>File</strong> <a href="/attachments/21061">edit-icon-remain-displayed@2x.png</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/21061/edit-icon-remain-displayed@2x.png">edit-icon-remain-displayed@2x.png</a> added</li></ul><p>Thank you for posting the interesting patch. But I found a behavior that needs to be fixed.</p>
<p>After deleting all attachments, the "Edit attached files" icon remains displayed (see the screenshot below). I think the icon should not appear if there are no attached files. If you click the icon when there are no attachments, you will see 404 error.</p>
<p>Could you fix the patch?</p>
<p><img src="https://www.redmine.org/attachments/download/21061/edit-icon-remain-displayed@2x.png" srcset="https://www.redmine.org/attachments/download/21061/edit-icon-remain-displayed@2x.png 2x" style="width: 689px;border: 1px solid #ccc;" alt="" /></p> Redmine - Defect #28953: Issue content gets lost if user deletes an attachmenthttps://www.redmine.org/issues/28953?journal_id=861462018-07-09T18:45:29ZMarius BÄ‚LTEANU
<ul></ul><p>I thought too on removing the attachments via ajax, but there are some cases that must be handled. For example, in addition to the problem reported by Go Maeda, in the issue page, we need to remove the attachment also from the "Edit attached files" section from the edit form.</p>
<p>To reproduce, go to an issue, delete an attachment, click "Edit" and then click "Edit attached files" and you'll see the attachment still in the page.</p>
<p>We can handle also this case in the <code>app/views/attachments/destroy.js.erb</code>, but the code will become quite complex (even with the proposed solution, when you delete an attachment from issue page, the response contains some code that is related to the wiki page). I think that we need a better way to handle these cases and I have in mind the following:<br />1. in the delete request, send also the entity (issue, wiki, etc) and treat the response depending on this<br />2. implement the delete logic on each view that has "special" needs by listening on the delete with success event (<a class="external" href="http://guides.rubyonrails.org/working_with_javascript_in_rails.html#rails-ujs-event-handlers">http://guides.rubyonrails.org/working_with_javascript_in_rails.html#rails-ujs-event-handlers</a>)</p> Redmine - Defect #28953: Issue content gets lost if user deletes an attachmenthttps://www.redmine.org/issues/28953?journal_id=861622018-07-11T08:25:14ZTakenori TAKAKItakenory@gmail.com
<ul></ul><p>Go MAEDA wrote:</p>
<blockquote>
<p>After deleting all attachments, the "Edit attached files" icon remains displayed (see the screenshot below). I think the icon should not appear if there are no attached files. If you click the icon when there are no attachments, you will see 404 error.</p>
<p>Could you fix the patch?</p>
</blockquote>
<p>Thank you for pointing out the problem.<br />I would like to fixe the problem and recreate the patch.</p> Redmine - Defect #28953: Issue content gets lost if user deletes an attachmenthttps://www.redmine.org/issues/28953?journal_id=861632018-07-11T09:12:23ZTakenori TAKAKItakenory@gmail.com
<ul><li><strong>File</strong> <a href="/attachments/21080">diff-r17442.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/21080/diff-r17442.patch">diff-r17442.patch</a> added</li></ul><p>Marius BALTEANU wrote:</p>
<blockquote>
<p>I thought too on removing the attachments via ajax, but there are some cases that must be handled. For example, in addition to the problem reported by Go Maeda, in the issue page, we need to remove the attachment also from the "Edit attached files" section from the edit form.</p>
</blockquote>
<p>I could not realize that attachments and "Edit attached files" is out there...<br />Thank you for pointing out the problem.</p>
<p>Marius BALTEANU wrote:</p>
<blockquote>
<p>We can handle also this case in the <code>app/views/attachments/destroy.js.erb</code>, but the code will become quite complex (even with the proposed solution, when you delete an attachment from issue page, the response contains some code that is related to the wiki page). I think that we need a better way to handle these cases and I have in mind the following:<br />1. in the delete request, send also the entity (issue, wiki, etc) and treat the response depending on this<br />2. implement the delete logic on each view that has "special" needs by listening on the delete with success event (<a class="external" href="http://guides.rubyonrails.org/working_with_javascript_in_rails.html#rails-ujs-event-handlers">http://guides.rubyonrails.org/working_with_javascript_in_rails.html#rails-ujs-event-handlers</a>)</p>
</blockquote>
<p>Thanks for great suggestions!<br />I recreated the patch with the following way.<br /> 1. In the delete request, switch the response data with js / json depending on the presence of "@attachment.container" <br /> 2. Implement the delete logic that has required on each view (The way <a class="user active" href="https://www.redmine.org/users/27597">Marius Ionescu</a> suggested)</p>
<p>This patch works with the latest Redmine trunk (<a class="changeset" title="Test for r17441 (#29189). Contributed by Mizuki ISHIKAWA." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/17442">r17442</a>).</p>