Feature #18556 » attachment_max_number_files.diff
| app/views/attachments/_form.html.erb | ||
|---|---|---|
|
:multiple => multiple,
|
||
|
:onchange => 'addInputFiles(this);',
|
||
|
:data => {
|
||
|
:max_number_of_files_message => l(:error_attachments_too_many, :max_number_of_files => (multiple ? 10 : 1)),
|
||
|
:attachment_max_number_files => Setting.attachment_max_number_files,
|
||
|
:max_number_of_files_message => l(:error_attachments_too_many, :max_number_of_files => (multiple ? Setting.attachment_max_number_files : 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,
|
||
| app/views/settings/_attachments.html.erb | ||
|---|---|---|
|
<p><%= setting_text_field :bulk_download_max_size, :size => 6 %> <%= l(:"number.human.storage_units.units.kb") %></p>
|
||
|
<p><%= setting_text_field :attachment_max_number_files, :size => 6 %> </p>
|
||
|
<p><%= setting_text_area :attachment_extensions_allowed %>
|
||
|
<em class="info"><%= l(:text_comma_separated) %> <%= l(:label_example) %>: txt, png</em></p>
|
||
| config/locales/en.yml | ||
|---|---|---|
|
setting_self_registration: Self-registration
|
||
|
setting_show_custom_fields_on_registration: Show custom fields on registration
|
||
|
setting_attachment_max_size: Maximum attachment size
|
||
|
setting_attachment_max_number_files: Maximum number of attachments
|
||
|
setting_bulk_download_max_size: Maximum total size for bulk download
|
||
|
setting_issues_export_limit: Issues export limit
|
||
|
setting_mail_from: Emission email address
|
||
| config/settings.yml | ||
|---|---|---|
|
bulk_download_max_size:
|
||
|
format: int
|
||
|
default: 102400
|
||
|
attachment_max_number_files:
|
||
|
format: int
|
||
|
default: 10
|
||
|
attachment_extensions_allowed:
|
||
|
default:
|
||
|
attachment_extensions_denied:
|
||
| public/javascripts/attachments.js | ||
|---|---|---|
|
/* Redmine - project management software
|
||
|
Copyright (C) 2006-2023 Jean-Philippe Lang */
|
||
|
/* garya 2026-02-06
|
||
|
Ideally, naxNumFilesMulti and similar values which come from Settings
|
||
|
would be retrieved as file-scope parameters here.
|
||
|
I don't know how to do that, so they are fetched in multiple places
|
||
|
within methods using the input context, inputEl.
|
||
|
For some reason I don't understand,
|
||
|
values with underscores in their names, e.g. Settings.attachment_max_number_files,
|
||
|
which were stored using the underscore in the key,
|
||
|
are retrieved using a key with the underscore replaced by a hyphen.
|
||
|
*/
|
||
|
function addFile(inputEl, file, eagerUpload) {
|
||
|
var attachmentsFields = $(inputEl).closest('.attachments_form').find('.attachments_fields');
|
||
|
var addAttachment = $(inputEl).closest('.attachments_form').find('.add_attachment');
|
||
|
var maxFiles = ($(inputEl).attr('multiple') == 'multiple' ? 10 : 1);
|
||
|
/* var maxFiles = ($(inputEl).attr('multiple') == 'multiple' ? 10 : 1); */
|
||
|
var maxNumFilesMulti = $(inputEl).data('attachment-max-number-files');
|
||
|
var maxFiles = ($(inputEl).attr('multiple') == 'multiple' ? maxNumFilesMulti : 1);
|
||
|
if (attachmentsFields.children().length < maxFiles) {
|
||
|
var attachmentId = addFile.nextAttachmentId++;
|
||
| ... | ... | |
|
var maxFileSize = $(inputEl).data('max-file-size');
|
||
|
var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
|
||
|
var maxNumFilesMulti = $(inputEl).data('attachment-max-number-files');
|
||
|
var sizeExceeded = false;
|
||
|
var filesLength = $(inputEl).closest('.attachments_form').find('.attachments_fields').children().length + files.length
|
||
| ... | ... | |
|
$.each(files, function() {addFile(inputEl, this, true);});
|
||
|
}
|
||
|
if (filesLength > ($(inputEl).attr('multiple') == 'multiple' ? 10 : 1)) {
|
||
|
if (filesLength > ($(inputEl).attr('multiple') == 'multiple' ? /*10*/ maxNumFilesMulti : 1)) {
|
||
|
window.alert($(inputEl).data('max-number-of-files-message'));
|
||
|
}
|
||
|
return sizeExceeded;
|
||