diff --git a/app/assets/stylesheets/procedure_champs_editor.scss b/app/assets/stylesheets/procedure_champs_editor.scss index afc3960bd..72e8cf4bb 100644 --- a/app/assets/stylesheets/procedure_champs_editor.scss +++ b/app/assets/stylesheets/procedure_champs_editor.scss @@ -5,6 +5,11 @@ .types-de-champ-editor { > .types-de-champ-block { padding-bottom: 50px; + + .types-de-champ-errors { + background-color: $background-red; + padding: $default-padding; + } } .type-de-champ { diff --git a/app/components/types_de_champ_editor/champ_component.rb b/app/components/types_de_champ_editor/champ_component.rb index 856d0d06a..b2e12aca6 100644 --- a/app/components/types_de_champ_editor/champ_component.rb +++ b/app/components/types_de_champ_editor/champ_component.rb @@ -1,10 +1,11 @@ class TypesDeChampEditor::ChampComponent < ApplicationComponent attr_reader :coordinate, :upper_coordinates - def initialize(coordinate:, upper_coordinates:, focused: false) + def initialize(coordinate:, upper_coordinates:, focused: false, errors: '') @coordinate = coordinate @focused = focused @upper_coordinates = upper_coordinates + @errors = errors end private diff --git a/app/components/types_de_champ_editor/champ_component/champ_component.html.haml b/app/components/types_de_champ_editor/champ_component/champ_component.html.haml index 9c5eb4f21..07b26cca4 100644 --- a/app/components/types_de_champ_editor/champ_component/champ_component.html.haml +++ b/app/components/types_de_champ_editor/champ_component/champ_component.html.haml @@ -6,6 +6,10 @@ .icon.delete %span.sr-only Supprimer + - if @errors.present? + .types-de-champ-errors + = @errors + .flex.justify-start.section.ml-1 = form_for(type_de_champ, form_options) do |form| .flex.justify-start diff --git a/spec/components/previews/types_de_champ_editor/champ_component_preview.rb b/spec/components/previews/types_de_champ_editor/champ_component_preview.rb index 7c718a976..12b5e3a68 100644 --- a/spec/components/previews/types_de_champ_editor/champ_component_preview.rb +++ b/spec/components/previews/types_de_champ_editor/champ_component_preview.rb @@ -6,10 +6,12 @@ class TypesDeChampEditor::ChampComponentPreview < ViewComponent::Preview procedure = Procedure.new(id: 123) coordinate = ProcedureRevisionTypeDeChamp.new(type_de_champ: tdc, procedure:) upper_coordinates = [] + errors = 'une grosse erreur' render_with_template(locals: { coordinate:, - upper_coordinates: + upper_coordinates:, + errors: }) end end diff --git a/spec/components/previews/types_de_champ_editor/champ_component_preview/nominal.html.haml b/spec/components/previews/types_de_champ_editor/champ_component_preview/nominal.html.haml index 5b2cf2746..0c2a82ea3 100644 --- a/spec/components/previews/types_de_champ_editor/champ_component_preview/nominal.html.haml +++ b/spec/components/previews/types_de_champ_editor/champ_component_preview/nominal.html.haml @@ -4,4 +4,5 @@ %ul.types-de-champ-block = render TypesDeChampEditor::ChampComponent.new(coordinate:, upper_coordinates:, - focused: false) + focused: false, + errors:)