You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_form.html.erb 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <% attachment_param ||= 'attachments' %>
  2. <% saved_attachments ||= container.saved_attachments if defined?(container) && container %>
  3. <% multiple = true unless defined?(multiple) && multiple == false %>
  4. <% show_add = multiple || saved_attachments.blank? %>
  5. <% description = (defined?(description) && description == false ? false : true) %>
  6. <% css_class = (defined?(filedrop) && filedrop == false ? '' : 'filedrop') %>
  7. <span class="attachments_form">
  8. <span class="attachments_fields">
  9. <% if saved_attachments.present? %>
  10. <% saved_attachments.each_with_index do |attachment, i| %>
  11. <span id="attachments_p<%= i %>">
  12. <%= text_field_tag("#{attachment_param}[p#{i}][filename]", attachment.filename, :class => 'filename') %>
  13. <% if attachment.container_id.present? %>
  14. <%= link_to l(:label_delete), "#", :onclick => "$(this).closest('.attachments_form').find('.add_attachment').show(); $(this).parent().remove(); return false;", :class => 'icon-only icon-del' %>
  15. <%= hidden_field_tag "#{attachment_param}[p#{i}][id]", attachment.id %>
  16. <% else %>
  17. <%= text_field_tag("#{attachment_param}[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description') if description %>
  18. <%= link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %>
  19. <%= hidden_field_tag "#{attachment_param}[p#{i}][token]", attachment.token %>
  20. <% end %>
  21. </span>
  22. <% end %>
  23. <% end %>
  24. </span>
  25. <span class="add_attachment" style="<%= show_add ? nil : 'display:none;' %>">
  26. <%= file_field_tag "#{attachment_param}[dummy][file]",
  27. :id => nil,
  28. :class => "file_selector #{css_class}",
  29. :multiple => multiple,
  30. :onchange => 'addInputFiles(this);',
  31. :data => {
  32. :max_file_size => Setting.attachment_max_size.to_i.kilobytes,
  33. :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
  34. :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
  35. :upload_path => uploads_path(:format => 'js'),
  36. :param => attachment_param,
  37. :description => description,
  38. :description_placeholder => l(:label_optional_description)
  39. } %>
  40. (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
  41. </span>
  42. </span>
  43. <% content_for :header_tags do %>
  44. <%= javascript_include_tag 'attachments' %>
  45. <% end %>