Feature #18556 » attachment_max_number_files.diff
| app/views/attachments/_form.html.erb | ||
|---|---|---|
| 31 | 31 |
:multiple => multiple, |
| 32 | 32 |
:onchange => 'addInputFiles(this);', |
| 33 | 33 |
:data => {
|
| 34 |
:max_number_of_files_message => l(:error_attachments_too_many, :max_number_of_files => (multiple ? 10 : 1)), |
|
| 34 |
:attachment_max_number_files => Setting.attachment_max_number_files, |
|
| 35 |
:max_number_of_files_message => l(:error_attachments_too_many, :max_number_of_files => (multiple ? Setting.attachment_max_number_files : 1)), |
|
| 35 | 36 |
:max_file_size => Setting.attachment_max_size.to_i.kilobytes, |
| 36 | 37 |
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), |
| 37 | 38 |
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, |
| app/views/settings/_attachments.html.erb | ||
|---|---|---|
| 5 | 5 | |
| 6 | 6 |
<p><%= setting_text_field :bulk_download_max_size, :size => 6 %> <%= l(:"number.human.storage_units.units.kb") %></p> |
| 7 | 7 | |
| 8 |
<p><%= setting_text_field :attachment_max_number_files, :size => 6 %> </p> |
|
| 9 | ||
| 8 | 10 |
<p><%= setting_text_area :attachment_extensions_allowed %> |
| 9 | 11 |
<em class="info"><%= l(:text_comma_separated) %> <%= l(:label_example) %>: txt, png</em></p> |
| 10 | 12 | |
| config/locales/en.yml | ||
|---|---|---|
| 426 | 426 |
setting_self_registration: Self-registration |
| 427 | 427 |
setting_show_custom_fields_on_registration: Show custom fields on registration |
| 428 | 428 |
setting_attachment_max_size: Maximum attachment size |
| 429 |
setting_attachment_max_number_files: Maximum number of attachments |
|
| 429 | 430 |
setting_bulk_download_max_size: Maximum total size for bulk download |
| 430 | 431 |
setting_issues_export_limit: Issues export limit |
| 431 | 432 |
setting_mail_from: Emission email address |
| config/settings.yml | ||
|---|---|---|
| 76 | 76 |
bulk_download_max_size: |
| 77 | 77 |
format: int |
| 78 | 78 |
default: 102400 |
| 79 |
attachment_max_number_files: |
|
| 80 |
format: int |
|
| 81 |
default: 10 |
|
| 79 | 82 |
attachment_extensions_allowed: |
| 80 | 83 |
default: |
| 81 | 84 |
attachment_extensions_denied: |
| public/javascripts/attachments.js | ||
|---|---|---|
| 1 | 1 |
/* Redmine - project management software |
| 2 | 2 |
Copyright (C) 2006-2023 Jean-Philippe Lang */ |
| 3 | 3 | |
| 4 |
/* garya 2026-02-06 |
|
| 5 |
Ideally, naxNumFilesMulti and similar values which come from Settings |
|
| 6 |
would be retrieved as file-scope parameters here. |
|
| 7 |
I don't know how to do that, so they are fetched in multiple places |
|
| 8 |
within methods using the input context, inputEl. |
|
| 9 |
For some reason I don't understand, |
|
| 10 |
values with underscores in their names, e.g. Settings.attachment_max_number_files, |
|
| 11 |
which were stored using the underscore in the key, |
|
| 12 |
are retrieved using a key with the underscore replaced by a hyphen. |
|
| 13 |
*/ |
|
| 14 | ||
| 4 | 15 |
function addFile(inputEl, file, eagerUpload) {
|
| 5 | 16 |
var attachmentsFields = $(inputEl).closest('.attachments_form').find('.attachments_fields');
|
| 6 | 17 |
var addAttachment = $(inputEl).closest('.attachments_form').find('.add_attachment');
|
| 7 |
var maxFiles = ($(inputEl).attr('multiple') == 'multiple' ? 10 : 1);
|
|
| 18 |
/* var maxFiles = ($(inputEl).attr('multiple') == 'multiple' ? 10 : 1); */
|
|
| 19 |
var maxNumFilesMulti = $(inputEl).data('attachment-max-number-files');
|
|
| 20 |
var maxFiles = ($(inputEl).attr('multiple') == 'multiple' ? maxNumFilesMulti : 1);
|
|
| 8 | 21 | |
| 9 | 22 |
if (attachmentsFields.children().length < maxFiles) {
|
| 10 | 23 |
var attachmentId = addFile.nextAttachmentId++; |
| ... | ... | |
| 157 | 170 | |
| 158 | 171 |
var maxFileSize = $(inputEl).data('max-file-size');
|
| 159 | 172 |
var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
|
| 173 |
var maxNumFilesMulti = $(inputEl).data('attachment-max-number-files');
|
|
| 160 | 174 | |
| 161 | 175 |
var sizeExceeded = false; |
| 162 | 176 |
var filesLength = $(inputEl).closest('.attachments_form').find('.attachments_fields').children().length + files.length
|
| ... | ... | |
| 169 | 183 |
$.each(files, function() {addFile(inputEl, this, true);});
|
| 170 | 184 |
} |
| 171 | 185 | |
| 172 |
if (filesLength > ($(inputEl).attr('multiple') == 'multiple' ? 10 : 1)) {
|
|
| 186 |
if (filesLength > ($(inputEl).attr('multiple') == 'multiple' ? /*10*/ maxNumFilesMulti : 1)) {
|
|
| 173 | 187 |
window.alert($(inputEl).data('max-number-of-files-message'));
|
| 174 | 188 |
} |
| 175 | 189 |
return sizeExceeded; |
- « Previous
- 1
- 2
- 3
- 4
- Next »