feat(champ_component): add errors banner

This commit is contained in:
simon lehericey 2023-04-05 11:02:28 +02:00
parent 362c220587
commit 80b5f6bc1d
5 changed files with 16 additions and 3 deletions

View file

@ -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 {

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -4,4 +4,5 @@
%ul.types-de-champ-block
= render TypesDeChampEditor::ChampComponent.new(coordinate:,
upper_coordinates:,
focused: false)
focused: false,
errors:)