feat(champ_component): add errors banner
This commit is contained in:
parent
362c220587
commit
80b5f6bc1d
5 changed files with 16 additions and 3 deletions
|
@ -5,6 +5,11 @@
|
||||||
.types-de-champ-editor {
|
.types-de-champ-editor {
|
||||||
> .types-de-champ-block {
|
> .types-de-champ-block {
|
||||||
padding-bottom: 50px;
|
padding-bottom: 50px;
|
||||||
|
|
||||||
|
.types-de-champ-errors {
|
||||||
|
background-color: $background-red;
|
||||||
|
padding: $default-padding;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.type-de-champ {
|
.type-de-champ {
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
class TypesDeChampEditor::ChampComponent < ApplicationComponent
|
class TypesDeChampEditor::ChampComponent < ApplicationComponent
|
||||||
attr_reader :coordinate, :upper_coordinates
|
attr_reader :coordinate, :upper_coordinates
|
||||||
|
|
||||||
def initialize(coordinate:, upper_coordinates:, focused: false)
|
def initialize(coordinate:, upper_coordinates:, focused: false, errors: '')
|
||||||
@coordinate = coordinate
|
@coordinate = coordinate
|
||||||
@focused = focused
|
@focused = focused
|
||||||
@upper_coordinates = upper_coordinates
|
@upper_coordinates = upper_coordinates
|
||||||
|
@errors = errors
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
.icon.delete
|
.icon.delete
|
||||||
%span.sr-only Supprimer
|
%span.sr-only Supprimer
|
||||||
|
|
||||||
|
- if @errors.present?
|
||||||
|
.types-de-champ-errors
|
||||||
|
= @errors
|
||||||
|
|
||||||
.flex.justify-start.section.ml-1
|
.flex.justify-start.section.ml-1
|
||||||
= form_for(type_de_champ, form_options) do |form|
|
= form_for(type_de_champ, form_options) do |form|
|
||||||
.flex.justify-start
|
.flex.justify-start
|
||||||
|
|
|
@ -6,10 +6,12 @@ class TypesDeChampEditor::ChampComponentPreview < ViewComponent::Preview
|
||||||
procedure = Procedure.new(id: 123)
|
procedure = Procedure.new(id: 123)
|
||||||
coordinate = ProcedureRevisionTypeDeChamp.new(type_de_champ: tdc, procedure:)
|
coordinate = ProcedureRevisionTypeDeChamp.new(type_de_champ: tdc, procedure:)
|
||||||
upper_coordinates = []
|
upper_coordinates = []
|
||||||
|
errors = 'une grosse erreur'
|
||||||
|
|
||||||
render_with_template(locals: {
|
render_with_template(locals: {
|
||||||
coordinate:,
|
coordinate:,
|
||||||
upper_coordinates:
|
upper_coordinates:,
|
||||||
|
errors:
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,4 +4,5 @@
|
||||||
%ul.types-de-champ-block
|
%ul.types-de-champ-block
|
||||||
= render TypesDeChampEditor::ChampComponent.new(coordinate:,
|
= render TypesDeChampEditor::ChampComponent.new(coordinate:,
|
||||||
upper_coordinates:,
|
upper_coordinates:,
|
||||||
focused: false)
|
focused: false,
|
||||||
|
errors:)
|
||||||
|
|
Loading…
Reference in a new issue