diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 1b18662ad..687937576 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -149,7 +149,7 @@ class AttachmentsController < ApplicationController respond_to do |format| format.html { redirect_to_referer_or project_path(@project) } - format.js + format.js { render :json => {:id => @attachment.id, :attachments_count => @attachment.container.attachments.length}, :content_type => 'application/json' if @attachment.container } format.api { render_api_ok } end end diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index 0a9f5e3eb..c34ab5034 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -6,9 +6,9 @@ :class => 'icon-only icon-edit' ) if options[:editable] %> - +
<% for attachment in attachments %> - +
<%= link_to_attachment attachment, class: 'icon icon-attachment' -%> (<%= number_to_human_size attachment.filesize %>) @@ -23,7 +23,7 @@ <% if options[:deletable] %> <%= link_to l(:button_delete), attachment_path(attachment), - :data => {:confirm => l(:text_are_you_sure)}, + :data => {:confirm => l(:text_are_you_sure), :remote => true}, :method => :delete, :class => 'delete icon-only icon-del', :title => l(:button_delete) %> @@ -37,9 +37,15 @@ <% if images.any? %>
<% images.each do |attachment| %> -
<%= thumbnail_tag(attachment) %>
+
<%= thumbnail_tag(attachment) %>
<% end %>
<% end %> <% end %> +<%= javascript_tag do %> +$('a.delete').on('ajax:success', function(event, data, status, xhr){ + $('tr#attachment-' + data.id + ', div#thumbnail-' + data.id).remove(); + if (data.attachments_count=='0'){ $('div.attachments div.contextual, table#existing-attachments-table, div.thumbnails').remove(); } +}); +<% end %> diff --git a/app/views/issues/_edit.html.erb b/app/views/issues/_edit.html.erb index fe2119a07..50650c067 100644 --- a/app/views/issues/_edit.html.erb +++ b/app/views/issues/_edit.html.erb @@ -44,7 +44,7 @@
<%= link_to l(:label_edit_attachments), '#', :onclick => "$('#existing-attachments').toggle(); return false;" %>
<% @issue.attachments.each do |attachment| %> - + <%= text_field_tag '', attachment.filename, :class => "icon icon-attachment filename", :disabled => true %>