add errors_summary component
This commit is contained in:
parent
a98484809f
commit
f4b465a03f
6 changed files with 36 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
||||||
.types-de-champ-editor.editor-root{ 'data-turbo': 'true', id: dom_id(@revision, :types_de_champ_editor) }
|
.types-de-champ-editor.editor-root{ 'data-turbo': 'true', id: dom_id(@revision, :types_de_champ_editor) }
|
||||||
|
= render TypesDeChampEditor::ErrorsSummary.new(revision: @revision)
|
||||||
= render TypesDeChampEditor::BlockComponent.new(block: @revision, coordinates: coordinates)
|
= render TypesDeChampEditor::BlockComponent.new(block: @revision, coordinates: coordinates)
|
||||||
.buttons
|
.buttons
|
||||||
= render TypesDeChampEditor::AddChampButtonComponent.new(revision: @revision, is_annotation: annotations?)
|
= render TypesDeChampEditor::AddChampButtonComponent.new(revision: @revision, is_annotation: annotations?)
|
||||||
|
|
18
app/components/types_de_champ_editor/errors_summary.rb
Normal file
18
app/components/types_de_champ_editor/errors_summary.rb
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
class TypesDeChampEditor::ErrorsSummary < ApplicationComponent
|
||||||
|
def initialize(revision:)
|
||||||
|
@revision = revision
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def error_message
|
||||||
|
@revision.errors
|
||||||
|
.map { |error| error.options[:type_de_champ] }
|
||||||
|
.map { |tdc| tag.li(tdc_anchor(tdc)) }
|
||||||
|
.then { |lis| tag.ul(lis.reduce(&:+)) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def tdc_anchor(tdc)
|
||||||
|
tag.a(tdc.libelle, href: champs_admin_procedure_path(@revision.procedure_id, anchor: dom_id(tdc.stable_self, :conditions)), data: { turbo: false })
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
fr:
|
||||||
|
fix:
|
||||||
|
one: 'Corrigez le champ suivant :'
|
||||||
|
other: 'Corrigez les champs suivants :'
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#errors-summary
|
||||||
|
- if @revision.invalid?
|
||||||
|
.card.warning
|
||||||
|
.card-title La logique conditionnelle est devenue invalide
|
||||||
|
|
||||||
|
%p.mb-2= t('.fix', count: @revision.errors.count)
|
||||||
|
= error_message
|
|
@ -38,6 +38,9 @@
|
||||||
%span.icon.archive
|
%span.icon.archive
|
||||||
Clore
|
Clore
|
||||||
|
|
||||||
|
.container
|
||||||
|
= render TypesDeChampEditor::ErrorsSummary.new(revision: @procedure.draft_revision)
|
||||||
|
|
||||||
- if @procedure.draft_changed?
|
- if @procedure.draft_changed?
|
||||||
.container
|
.container
|
||||||
.card.featured
|
.card.featured
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
= turbo_stream.replace 'errors-summary', render(TypesDeChampEditor::ErrorsSummary.new(revision: @procedure.draft_revision))
|
||||||
|
|
||||||
- if @destroyed.present?
|
- if @destroyed.present?
|
||||||
= turbo_stream.remove dom_id(@destroyed, :type_de_champ_editor)
|
= turbo_stream.remove dom_id(@destroyed, :type_de_champ_editor)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue