Defect #28953 » diff-r17439.patch
| app/views/attachments/_links.html.erb | ||
|---|---|---|
|
</div>
|
||
|
<table>
|
||
|
<% for attachment in attachments %>
|
||
|
<tr>
|
||
|
<tr id="attachment_<%= attachment.id %>">
|
||
|
<td>
|
||
|
<%= link_to_attachment attachment, class: 'icon icon-attachment' -%>
|
||
|
<span class="size">(<%= number_to_human_size attachment.filesize %>)</span>
|
||
| ... | ... | |
|
<td>
|
||
|
<% 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) %>
|
||
| ... | ... | |
|
<% if images.any? %>
|
||
|
<div class="thumbnails">
|
||
|
<% images.each do |attachment| %>
|
||
|
<div><%= thumbnail_tag(attachment) %></div>
|
||
|
<div id="thumbnail_<%= attachment.id %>"><%= thumbnail_tag(attachment) %></div>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
<% end %>
|
||
| app/views/attachments/destroy.js.erb | ||
|---|---|---|
|
$('#attachments_<%= j params[:attachment_id] %>').closest('.attachments_form').find('.add_attachment').show();
|
||
|
$('#attachments_<%= j params[:attachment_id] %>').remove();
|
||
|
$('#attachments_<%= j params[:attachment_id] %>, tr#attachment_<%= j params[:id] %>, div#thumbnail_<%= j params[:id] %>').remove();
|
||
|
$('#attachments_count').html('<%= @attachment.container.try(:attachments).try(:length) %>');
|
||
| app/views/wiki/show.html.erb | ||
|---|---|---|
|
<%= render(:partial => "wiki/content", :locals => {:content => @content}) %>
|
||
|
<fieldset class="collapsible collapsed">
|
||
|
<legend onclick="toggleFieldset(this);"><%= l(:label_attachment_plural) %> (<%= @page.attachments.length %>)</legend>
|
||
|
<legend onclick="toggleFieldset(this);"><%= l(:label_attachment_plural) %> (<span id="attachments_count"><%= @page.attachments.length %></span>)</legend>
|
||
|
<div style="display: none;">
|
||
|
<%= link_to_attachments @page, :thumbnails => true %>
|
||
| test/functional/attachments_controller_test.rb | ||
|---|---|---|
|
assert_response 302
|
||
|
assert Attachment.find_by_id(3)
|
||
|
end
|
||
|
def test_destroy_xhr
|
||
|
set_tmp_attachments_directory
|
||
|
@request.session[:user_id] = 2
|
||
|
@attachment_count = Attachment.find(9).container.try(:attachments).try(:length)
|
||
|
assert_difference 'Attachment.count', -1 do
|
||
|
delete :destroy, :params => {
|
||
|
:id => 9
|
||
|
},
|
||
|
:xhr => true
|
||
|
assert_response :success
|
||
|
assert_equal 'text/javascript', response.content_type
|
||
|
assert_include (@attachment_count - 1).to_s, response.body
|
||
|
end
|
||
|
end
|
||
|
end
|
||