Project

General

Profile

Feature #30776 » fix-30776.diff

Mizuki ISHIKAWA, 2020-09-28 06:36

View differences:

app/views/attachments/_form.html.erb
1 1
<% attachment_param ||= 'attachments' %>
2
<% attachment_format_custom_field ||= false %>
2 3
<% saved_attachments ||= container.saved_attachments if defined?(container) && container %>
3 4
<% multiple = true unless defined?(multiple) && multiple == false %>
4 5
<% show_add = multiple || saved_attachments.blank? %>
5 6
<% description = (defined?(description) && description == false ? false : true) %>
6
<% css_class = (defined?(filedrop) && filedrop == false ? '' : 'filedrop') %>
7
<% css_class = (defined?(filedrop) && filedrop == false ? '' : (attachment_format_custom_field ? 'custom-field-filedrop' : 'filedrop')) %>
7 8

  
8 9
<span class="attachments_form">
9 10
  <span class="attachments_fields">
......
30 31
        :multiple => multiple,
31 32
        :onchange => 'addInputFiles(this);',
32 33
        :data => {
33
          :max_number_of_files_message => l(:error_attachments_too_many, :max_number_of_files => 10),
34
          :max_number_of_files_message => l(:error_attachments_too_many, :max_number_of_files => (multiple ? 10 : 1)),
34 35
          :max_file_size => Setting.attachment_max_size.to_i.kilobytes,
35 36
          :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
36 37
          :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
lib/redmine/field_format.rb
1033 1033
              :multiple => false,
1034 1034
              :description => false,
1035 1035
              :saved_attachments => [attachment].compact,
1036
              :filedrop => false
1036
              :filedrop => true,
1037
              :attachment_format_custom_field => true
1037 1038
            })
1038 1039
      end
1039 1040
    end
public/javascripts/attachments.js
179 179

  
180 180
  if ($.inArray('Files', e.dataTransfer.types) > -1) {
181 181
    handleFileDropEvent.target = e.target;
182
    uploadAndAttachFiles(e.dataTransfer.files, $('input:file.filedrop').first());
182
    if ($(this).hasClass('custom-field-filedroplistner')){
183
      uploadAndAttachFiles(e.dataTransfer.files, $(this).find('input:file.custom-field-filedrop').first());
184
    } else {
185
      uploadAndAttachFiles(e.dataTransfer.files, $(this).find('input:file.filedrop').first());
186
    }
183 187
  }
184 188
}
185 189
handleFileDropEvent.target = '';
......
208 212
          paste: copyImageFromClipboard
209 213
      }).addClass('filedroplistner');
210 214
    });
215

  
216
    $('form div.box input:file.custom-field-filedrop').closest('p').not('.custom-field-filedroplistner').each(function() {
217
      $(this).on({
218
          dragover: dragOverHandler,
219
          dragleave: dragOutHandler,
220
          drop: handleFileDropEvent
221
      }).addClass('custom-field-filedroplistner');
222
    });
211 223
  }
212 224
}
213 225

  
public/stylesheets/application.css
924 924
a.remove-upload:hover {text-decoration:none !important;}
925 925
.existing-attachment.deleted .filename {text-decoration:line-through; color:#999 !important;}
926 926

  
927
div.fileover { background-color: lavender; }
927
div.fileover, p.custom-field-filedroplistner.fileover { background-color: lavender; }
928 928

  
929 929
div.attachments p { margin:4px 0 2px 0; }
930 930
div.attachments img { vertical-align: middle; }
(3-3/3)