Merge pull request #10608 from mfo/US/fix-regexp-error

Correctif: ETQ administrateur je souhaite qu'un type de champ expression régulière ne bloque pas l'edition de ma demarche
This commit is contained in:
mfo 2024-07-15 09:34:16 +00:00 committed by GitHub
commit ad8a664fe4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 2 deletions

View file

@ -4,7 +4,11 @@ class TypesDeChamp::ExpressionReguliereValidator < ActiveModel::EachValidator
.flat_map { _1.repetition? ? procedure.draft_revision.children_of(_1) : _1 }
.each do |tdc|
if tdc.expression_reguliere? && tdc.invalid_regexp?
procedure.errors.add(:expression_reguliere, type_de_champ: tdc)
procedure.errors.add(
attribute,
procedure.errors.generate_message(attribute, :expression_reguliere_invalid, { value: tdc.libelle }),
type_de_champ: tdc
)
end
end
end

View file

@ -76,12 +76,14 @@ en:
empty_repetition: 'requires at least one field'
empty_drop_down: 'requires at least one option'
inconsistent_header_section: "%{custom_message}"
expression_reguliere_invalid: "is invalid"
draft_types_de_champ_private:
format: 'Private field %{message}'
invalid_condition: "have an invalid logic"
empty_repetition: 'requires at least one field'
empty_drop_down: 'requires at least one option'
inconsistent_header_section: "%{custom_message}"
expression_reguliere_invalid: "is invalid"
attestation_template:
format: "%{attribute} %{message}"
initiated_mail:

View file

@ -82,12 +82,14 @@ fr:
empty_repetition: 'doit comporter au moins un champ répétable'
empty_drop_down: 'doit comporter au moins un choix sélectionnable'
inconsistent_header_section: "%{custom_message}"
expression_reguliere_invalid: "est invalide, veuillez la corriger"
draft_types_de_champ_private:
format: 'Lannotation privée %{message}'
invalid_condition: "a une logique conditionnelle invalide"
empty_repetition: 'doit comporter au moins un champ répétable'
empty_drop_down: 'doit comporter au moins un choix sélectionnable'
inconsistent_header_section: "%{custom_message}"
expression_reguliere_invalid: "est invalide, veuillez la corriger"
attestation_template:
format: "%{attribute} %{message}"
initiated_mail:

View file

@ -50,7 +50,8 @@ describe Procedure::ErrorsSummary, type: :component do
{ libelle: 'repetition requires children', type: :repetition, children: [] },
{ libelle: 'drop down list requires options', type: :drop_down_list, options: [] },
{ libelle: 'invalid condition', type: :text, condition: ds_eq(constant(true), constant(1)) },
{ libelle: 'header sections must have consistent order', type: :header_section, level: 2 }
{ libelle: 'header sections must have consistent order', type: :header_section, level: 2 },
{ libelle: 'regexp invalid', type: :expression_reguliere, expression_reguliere_exemple_text: 'kthxbye', expression_reguliere: /{/ }
])
end
@ -70,6 +71,9 @@ describe Procedure::ErrorsSummary, type: :component do
expect(page).to have_selector("a", text: "header sections must have consistent order")
expect(page).to have_content("devrait être précédé d'un titre de niveau 1")
expect(page).to have_selector("a", text: "regexp invalid")
expect(page).to have_content("est invalide, veuillez la corriger")
end
end