diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb
index 6dd07a9d4369a3d7e5eb3de0881ef4014f8a7060..7bda59c95b9555e5af14acd6400ab6d5dc2400d4 100644
--- a/app/views/attachments/_form.html.erb
+++ b/app/views/attachments/_form.html.erb
@@ -1,9 +1,10 @@
<% attachment_param ||= 'attachments' %>
+<% attachment_format_custom_field ||= false %>
<% saved_attachments ||= container.saved_attachments if defined?(container) && container %>
<% multiple = true unless defined?(multiple) && multiple == false %>
<% show_add = multiple || saved_attachments.blank? %>
<% description = (defined?(description) && description == false ? false : true) %>
-<% css_class = (defined?(filedrop) && filedrop == false ? '' : 'filedrop') %>
+<% css_class = (defined?(filedrop) && filedrop == false ? '' : (attachment_format_custom_field ? 'custom-field-filedrop' : 'filedrop')) %>
@@ -30,7 +31,7 @@
:multiple => multiple,
:onchange => 'addInputFiles(this);',
:data => {
- :max_number_of_files_message => l(:error_attachments_too_many, :max_number_of_files => 10),
+ :max_number_of_files_message => l(:error_attachments_too_many, :max_number_of_files => (multiple ? 10 : 1)),
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
diff --git a/lib/redmine/field_format.rb b/lib/redmine/field_format.rb
index bcf100e3b0e0c04098c6c6b17339edd762a160af..c3fff6be57b2975d46f3e3d5b193391296b5f294 100644
--- a/lib/redmine/field_format.rb
+++ b/lib/redmine/field_format.rb
@@ -1033,7 +1033,8 @@ module Redmine
:multiple => false,
:description => false,
:saved_attachments => [attachment].compact,
- :filedrop => false
+ :filedrop => true,
+ :attachment_format_custom_field => true
})
end
end
diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js
index 76203455e8514374c833ab5517448f97dc2858c2..bd7139fa2167c0824079c2658cff35f73ec701d1 100644
--- a/public/javascripts/attachments.js
+++ b/public/javascripts/attachments.js
@@ -179,7 +179,11 @@ function handleFileDropEvent(e) {
if ($.inArray('Files', e.dataTransfer.types) > -1) {
handleFileDropEvent.target = e.target;
- uploadAndAttachFiles(e.dataTransfer.files, $('input:file.filedrop').first());
+ if ($(this).hasClass('custom-field-filedroplistner')){
+ uploadAndAttachFiles(e.dataTransfer.files, $(this).find('input:file.custom-field-filedrop').first());
+ } else {
+ uploadAndAttachFiles(e.dataTransfer.files, $(this).find('input:file.filedrop').first());
+ }
}
}
handleFileDropEvent.target = '';
@@ -208,6 +212,14 @@ function setupFileDrop() {
paste: copyImageFromClipboard
}).addClass('filedroplistner');
});
+
+ $('form div.box input:file.custom-field-filedrop').closest('p').not('.custom-field-filedroplistner').each(function() {
+ $(this).on({
+ dragover: dragOverHandler,
+ dragleave: dragOutHandler,
+ drop: handleFileDropEvent
+ }).addClass('custom-field-filedroplistner');
+ });
}
}
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 78857fcc3f9e721c276cf91051ecaa0cbc2cb1cd..87257f5927efb8748b06aba99270e35eb747b937 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -924,7 +924,7 @@ span.required {color: #bb0000;}
a.remove-upload:hover {text-decoration:none !important;}
.existing-attachment.deleted .filename {text-decoration:line-through; color:#999 !important;}
-div.fileover { background-color: lavender; }
+div.fileover, p.custom-field-filedroplistner.fileover { background-color: lavender; }
div.attachments p { margin:4px 0 2px 0; }
div.attachments img { vertical-align: middle; }