diff --git a/app/components/attachment/edit_component.rb b/app/components/attachment/edit_component.rb index 5d8c11612..faee823c4 100644 --- a/app/components/attachment/edit_component.rb +++ b/app/components/attachment/edit_component.rb @@ -204,12 +204,14 @@ class Attachment::EditComponent < ApplicationComponent end def allowed_formats - return nil unless champ&.titre_identite? - @allowed_formats ||= begin - content_type_validator.options[:in].filter_map do |content_type| + formats = content_type_validator.options[:in].filter_map do |content_type| MiniMime.lookup_by_content_type(content_type)&.extension end.uniq.sort_by { EXTENSIONS_ORDER.index(_1) || 999 } + + # When too many formats are allowed, consider instead manually indicating + # above the input a more comprehensive of formats allowed, like "any image", or a simplified list. + formats.size > 5 ? [] : formats end end diff --git a/app/components/attachment/edit_component/edit_component.html.haml b/app/components/attachment/edit_component/edit_component.html.haml index 116271c19..d0d88b590 100644 --- a/app/components/attachment/edit_component/edit_component.html.haml +++ b/app/components/attachment/edit_component/edit_component.html.haml @@ -23,7 +23,7 @@ %p.fr-text--sm.fr-text-mention--grey.fr-mb-1w - if max_file_size.present? = t('.max_file_size', max_file_size: number_to_human_size(max_file_size)) - - if allowed_formats + - if allowed_formats.present? = t('.allowed_formats', formats: allowed_formats.join(', ')) diff --git a/app/views/administrateurs/groupe_instructeurs/_signature.html.haml b/app/views/administrateurs/groupe_instructeurs/_signature.html.haml index 6abd1ef27..42cfba025 100644 --- a/app/views/administrateurs/groupe_instructeurs/_signature.html.haml +++ b/app/views/administrateurs/groupe_instructeurs/_signature.html.haml @@ -1,10 +1,10 @@ .card.mt-2 = render NestedForms::FormOwnerComponent.new - = form_with url: { action: :add_signature }, method: :post, html: { multipart: true, class: 'form' } do |f| + = form_with url: { action: :add_signature }, method: :post, html: { multipart: true } do |f| .card-title Tampon de l'attestation - = render Attachment::EditComponent.new(attached_file: groupe_instructeur.signature, direct_upload: false) - %p.notice - Formats acceptés : JPG / JPEG / PNG. - %br - Dimensions conseillées : au minimum 500 px de largeur ou de hauteur, poids maximum : 0,5 Mo. = f.submit 'Ajouter signature', class: 'fr-btn' + + .fr-upload-group.fr-mb-4w + %p.fr-text--sm.fr-text-mention--grey.fr-mb-1w + Dimensions conseillées : au minimum 500 px de largeur ou de hauteur. + = render Attachment::EditComponent.new(attached_file: groupe_instructeur.signature, direct_upload: false)