]> source.dussan.org Git - redmine.git/commitdiff
Fix that alerts may be displayed multiple times when the number of files attempting...
authorGo MAEDA <maeda@farend.jp>
Wed, 13 Jan 2021 06:12:14 +0000 (06:12 +0000)
committerGo MAEDA <maeda@farend.jp>
Wed, 13 Jan 2021 06:12:14 +0000 (06:12 +0000)
Patch by Mizuki ISHIKAWA.

git-svn-id: http://svn.redmine.org/redmine/trunk@20711 e93f8b46-1217-0410-a6f0-8f06a7374b81

public/javascripts/attachments.js

index 76203455e8514374c833ab5517448f97dc2858c2..7e66939d62dc29c8ff4480240ba169e9c2e41015 100644 (file)
@@ -29,8 +29,6 @@ function addFile(inputEl, file, eagerUpload) {
 
     addAttachment.toggle(attachmentsFields.children().length < maxFiles);
     return attachmentId;
-  } else {
-    alert($('input.file_selector').data('max-number-of-files-message'));
   }
   return null;
 }
@@ -161,6 +159,7 @@ function uploadAndAttachFiles(files, inputEl) {
   var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
 
   var sizeExceeded = false;
+  var filesLength = $(inputEl).closest('.attachments_form').find('.attachments_fields').children().length + files.length
   $.each(files, function() {
     if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) {sizeExceeded=true;}
   });
@@ -169,6 +168,10 @@ function uploadAndAttachFiles(files, inputEl) {
   } else {
     $.each(files, function() {addFile(inputEl, this, true);});
   }
+
+  if (filesLength > ($(inputEl).attr('multiple') == 'multiple' ? 10 : 1)) {
+    window.alert($(inputEl).data('max-number-of-files-message'));
+  }
   return sizeExceeded;
 }