Merge pull request #7708 from betagouv/add_errors_summary_component
ajoute un résumé des erreurs présentes dans l'éditeur de champ
This commit is contained in:
commit
e521e9f376
6 changed files with 64 additions and 27 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
|
|
@ -4,41 +4,45 @@
|
||||||
metadatas: ["Créée le #{@procedure.created_at.strftime('%d/%m/%Y')} - n° #{@procedure.id}", "#{@procedure.close? ? "Close le #{@procedure.closed_at.strftime('%d/%m/%Y')}" : @procedure.locked? ? "Publiée - #{procedure_lien(@procedure)}" : "Brouillon"}"] }
|
metadatas: ["Créée le #{@procedure.created_at.strftime('%d/%m/%Y')} - n° #{@procedure.id}", "#{@procedure.close? ? "Close le #{@procedure.closed_at.strftime('%d/%m/%Y')}" : @procedure.locked? ? "Publiée - #{procedure_lien(@procedure)}" : "Brouillon"}"] }
|
||||||
|
|
||||||
.container.procedure-admin-container
|
.container.procedure-admin-container
|
||||||
- if !@procedure.brouillon?
|
- if @procedure.draft_revision.valid?
|
||||||
= link_to admin_procedure_archives_path(@procedure), class: 'button', id: "archive-procedure" do
|
- if !@procedure.brouillon?
|
||||||
%span.icon.download
|
= link_to admin_procedure_archives_path(@procedure), class: 'button', id: "archive-procedure" do
|
||||||
Télécharger
|
%span.icon.download
|
||||||
|
Télécharger
|
||||||
|
|
||||||
= link_to @procedure.active_revision.draft? ? commencer_dossier_vide_test_path(path: @procedure.path) : commencer_dossier_vide_path(path: @procedure.path), target: "_blank", rel: "noopener", class: 'button', id: "pdf-procedure" do
|
= link_to @procedure.active_revision.draft? ? commencer_dossier_vide_test_path(path: @procedure.path) : commencer_dossier_vide_path(path: @procedure.path), target: "_blank", rel: "noopener", class: 'button', id: "pdf-procedure" do
|
||||||
%span.icon.printer
|
%span.icon.printer
|
||||||
PDF
|
PDF
|
||||||
|
|
||||||
= link_to apercu_admin_procedure_path(@procedure), target: "_blank", rel: "noopener", class: 'button', id: "preview-procedure" do
|
= link_to apercu_admin_procedure_path(@procedure), target: "_blank", rel: "noopener", class: 'button', id: "preview-procedure" do
|
||||||
%span.icon.preview
|
%span.icon.preview
|
||||||
Prévisualiser
|
Prévisualiser
|
||||||
|
|
||||||
- if @procedure.brouillon? || @procedure.draft_changed?
|
- if @procedure.brouillon? || @procedure.draft_changed?
|
||||||
= link_to sanitize_url(@procedure_lien_test), target: :blank, rel: :noopener, class: 'button' do
|
= link_to sanitize_url(@procedure_lien_test), target: :blank, rel: :noopener, class: 'button' do
|
||||||
%span.icon.in-progress
|
%span.icon.in-progress
|
||||||
Tester
|
Tester
|
||||||
|
|
||||||
- if @procedure.publiee? || @procedure.brouillon?
|
- if @procedure.publiee? || @procedure.brouillon?
|
||||||
= link_to admin_procedure_transfert_path(@procedure), class: 'button' do
|
= link_to admin_procedure_transfert_path(@procedure), class: 'button' do
|
||||||
%span.icon.reply
|
%span.icon.reply
|
||||||
Envoyer une copie
|
Envoyer une copie
|
||||||
|
|
||||||
- if !@procedure.publiee? && !@procedure.close? && !@procedure.depubliee?
|
- if !@procedure.publiee? && !@procedure.close? && !@procedure.depubliee?
|
||||||
= link_to 'Publier', admin_procedure_publication_path(@procedure), class: 'button primary', id: 'publish-procedure-link', data: { disable_with: "Publication..." }
|
= link_to 'Publier', admin_procedure_publication_path(@procedure), class: 'button primary', id: 'publish-procedure-link', data: { disable_with: "Publication..." }
|
||||||
|
|
||||||
- if (@procedure.close? || @procedure.depubliee?) && !@procedure.draft_changed?
|
- if (@procedure.close? || @procedure.depubliee?) && !@procedure.draft_changed?
|
||||||
= link_to 'Réactiver', admin_procedure_publication_path(@procedure), class: 'button primary', id: 'publish-procedure-link', data: { disable_with: "Publication..." }
|
= link_to 'Réactiver', admin_procedure_publication_path(@procedure), class: 'button primary', id: 'publish-procedure-link', data: { disable_with: "Publication..." }
|
||||||
|
|
||||||
- if @procedure.locked? && !@procedure.close?
|
- if @procedure.locked? && !@procedure.close?
|
||||||
= link_to admin_procedure_archive_path(procedure_id: @procedure.id), method: :put, class: 'button', id: "close-procedure-link", data: { confirm: "Voulez-vous vraiment clore la démarche ? \nLes dossiers en cours pourront être instruits, mais aucun nouveau dossier ne pourra plus être déposé.", disable_with: "Archivage..."} do
|
= link_to admin_procedure_archive_path(procedure_id: @procedure.id), method: :put, class: 'button', id: "close-procedure-link", data: { confirm: "Voulez-vous vraiment clore la démarche ? \nLes dossiers en cours pourront être instruits, mais aucun nouveau dossier ne pourra plus être déposé.", disable_with: "Archivage..."} do
|
||||||
%span.icon.archive
|
%span.icon.archive
|
||||||
Clore
|
Clore
|
||||||
|
|
||||||
- if @procedure.draft_changed?
|
.container
|
||||||
|
= render TypesDeChampEditor::ErrorsSummary.new(revision: @procedure.draft_revision)
|
||||||
|
|
||||||
|
- if @procedure.draft_changed? && @procedure.draft_revision.valid?
|
||||||
.container
|
.container
|
||||||
.card.featured
|
.card.featured
|
||||||
.card-title
|
.card-title
|
||||||
|
|
|
@ -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…
Reference in a new issue