tech(extraction.erreurs): isole l'affichage des erreurs d'un champs ds un composant
This commit is contained in:
parent
d164605f32
commit
b34b4fcb0c
3 changed files with 17 additions and 8 deletions
13
app/components/dsfr/input_status_message_component.rb
Normal file
13
app/components/dsfr/input_status_message_component.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
module Dsfr
|
||||
class InputStatusMessageComponent < ApplicationComponent
|
||||
def initialize(errors_on_attribute:, error_full_messages:, described_by:)
|
||||
@errors_on_attribute = errors_on_attribute
|
||||
@error_full_messages = error_full_messages
|
||||
@described_by = described_by
|
||||
end
|
||||
|
||||
def render?
|
||||
@errors_on_attribute
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
.fr-messages-group{ id: @describedby_id }
|
||||
- @error_full_messages.each do |error_message|
|
||||
%p{ class: class_names('fr-message' => true, "fr-message--#{@errors_on_attribute ? 'error' : 'valid'}" => true)}= error_message
|
|
@ -3,13 +3,6 @@
|
|||
= render EditableChamp::ChampLabelComponent.new form: @form, champ: @champ, seen_at: @seen_at
|
||||
= render component_class.new(form: @form, champ: @champ, seen_at: @seen_at)
|
||||
|
||||
- if errors_on_attribute?
|
||||
- if error_full_messages.size == 1
|
||||
%p.fr-error-text{ id: describedby_id }= error_full_messages.first
|
||||
- else
|
||||
.fr-error-text{ id: describedby_id }
|
||||
%ul.list-style-type-none.fr-pl-0
|
||||
- error_full_messages.each do |error_message|
|
||||
%li= error_message
|
||||
= render Dsfr::InputStatusMessageComponent.new(errors_on_attribute: errors_on_attribute?, error_full_messages: error_full_messages, described_by: describedby_id)
|
||||
|
||||
= @form.hidden_field :id, value: @champ.id
|
||||
|
|
Loading…
Reference in a new issue