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.9KB

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