diff --git a/app/controllers/users/description_controller.rb b/app/controllers/users/description_controller.rb index ac5abf6ab..f83751f33 100644 --- a/app/controllers/users/description_controller.rb +++ b/app/controllers/users/description_controller.rb @@ -100,7 +100,13 @@ class Users::DescriptionController < UsersController private def redirect_to_description_with_errors(dossier, errors) - flash.alert = errors + errors_to_display = if errors.count > 3 + errors.take(3) + ['...'] + else + errors + end + + flash.alert = errors_to_display redirect_to users_dossier_description_path(dossier_id: dossier.id) end diff --git a/app/services/champs_service.rb b/app/services/champs_service.rb index 40c46a993..62a1d7342 100644 --- a/app/services/champs_service.rb +++ b/app/services/champs_service.rb @@ -8,7 +8,7 @@ class ChampsService def build_error_messages(champs) champs.select(&:mandatory_and_blank?) - .map { |c| "Le champ #{c.libelle} doit être rempli." } + .map { |c| "Le champ #{c.libelle.truncate(200)} doit être rempli." } end private diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index 8003e3c92..106526e06 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -38,7 +38,7 @@ class PiecesJustificativesService type_de_piece_justificative: tpj, user: user) - pj.save ? nil : "le fichier #{content.original_filename} (#{pj.libelle}) n'a pas pu être sauvegardé" + pj.save ? nil : "le fichier #{content.original_filename} (#{pj.libelle.truncate(200)}) n'a pas pu être sauvegardé" end def self.missing_pj_error_messages(dossier) @@ -46,6 +46,6 @@ class PiecesJustificativesService present_pjs = dossier.pieces_justificatives.map(&:type_de_piece_justificative) missing_pjs = mandatory_pjs - present_pjs - missing_pjs.map { |pj| "La pièce jointe #{pj.libelle} doit être fournie." } + missing_pjs.map { |pj| "La pièce jointe #{pj.libelle.truncate(200)} doit être fournie." } end end