Merge pull request #826 from sgmap/less_cookie_overflow
[fix #728] Reduce flash error size to avoid cookies overflow
This commit is contained in:
commit
95236294e4
3 changed files with 10 additions and 4 deletions
|
@ -100,7 +100,13 @@ class Users::DescriptionController < UsersController
|
||||||
private
|
private
|
||||||
|
|
||||||
def redirect_to_description_with_errors(dossier, errors)
|
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)
|
redirect_to users_dossier_description_path(dossier_id: dossier.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ class ChampsService
|
||||||
|
|
||||||
def build_error_messages(champs)
|
def build_error_messages(champs)
|
||||||
champs.select(&:mandatory_and_blank?)
|
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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -38,7 +38,7 @@ class PiecesJustificativesService
|
||||||
type_de_piece_justificative: tpj,
|
type_de_piece_justificative: tpj,
|
||||||
user: user)
|
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
|
end
|
||||||
|
|
||||||
def self.missing_pj_error_messages(dossier)
|
def self.missing_pj_error_messages(dossier)
|
||||||
|
@ -46,6 +46,6 @@ class PiecesJustificativesService
|
||||||
present_pjs = dossier.pieces_justificatives.map(&:type_de_piece_justificative)
|
present_pjs = dossier.pieces_justificatives.map(&:type_de_piece_justificative)
|
||||||
missing_pjs = mandatory_pjs - present_pjs
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue