add autosave feedback when admin updates form

This commit is contained in:
Christophe Robillard 2023-11-15 12:14:12 +01:00
parent bacd8ab6f7
commit 2c6a9e7bf2
7 changed files with 13 additions and 1 deletions

View file

@ -1,4 +1,4 @@
%span.fill-duration{ id: dom_id(@revision, :estimated_fill_duration) } %span.fr-text--sm.fill-duration{ id: dom_id(@revision, :estimated_fill_duration) }
- if show? - if show?
= t('.estimated_fill_duration') = t('.estimated_fill_duration')
= link_to "#{DOC_URL}/tutoriels/tutoriel-administrateur#g.-estimation-de-la-duree-de-remplissage", target: "_blank", rel: "noopener noreferrer" do = link_to "#{DOC_URL}/tutoriels/tutoriel-administrateur#g.-estimation-de-la-duree-de-remplissage", target: "_blank", rel: "noopener noreferrer" do

View file

@ -0,0 +1 @@
#autosave-notice.fr-badge.fr-badge--sm.fr-badge--success= t(".form_saved")

View file

@ -19,4 +19,5 @@
%li %li
= link_to t('preview', scope: [:layouts, :breadcrumb]), apercu_admin_procedure_path(@procedure), target: "_blank", rel: "noopener", class: 'fr-btn fr-btn--secondary' = link_to t('preview', scope: [:layouts, :breadcrumb]), apercu_admin_procedure_path(@procedure), target: "_blank", rel: "noopener", class: 'fr-btn fr-btn--secondary'
.fr-ml-auto .fr-ml-auto
#autosave-notice.hidden
= render TypesDeChampEditor::EstimatedFillDurationComponent.new(revision: @procedure.draft_revision, is_annotation: false) = render TypesDeChampEditor::EstimatedFillDurationComponent.new(revision: @procedure.draft_revision, is_annotation: false)

View file

@ -6,6 +6,11 @@
= turbo_stream.replace 'errors-summary', render(TypesDeChampEditor::ErrorsSummary.new(revision: @procedure.draft_revision)) = turbo_stream.replace 'errors-summary', render(TypesDeChampEditor::ErrorsSummary.new(revision: @procedure.draft_revision))
- unless flash.alert
= turbo_stream.show 'autosave-notice'
= turbo_stream.replace 'autosave-notice', render(partial: 'administrateurs/autosave_notice')
= turbo_stream.hide 'autosave-notice', delay: 30000
- 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)

View file

@ -47,3 +47,5 @@ en:
dpd_part_4: How to do ? You can either send him the link to the procedure on test stage by email, or name him "administrator". In any case, publish your approach only after having had his opinion. dpd_part_4: How to do ? You can either send him the link to the procedure on test stage by email, or name him "administrator". In any case, publish your approach only after having had his opinion.
back_to_procedure: 'Cancel and return to the procedure page' back_to_procedure: 'Cancel and return to the procedure page'
submit: Publish submit: Publish
autosave_notice:
form_saved: "Form saved"

View file

@ -47,3 +47,5 @@ fr:
dpd_part_4: Comment faire ? Vous pouvez soit lui communiquer par email le lien vers la démarche en test, ou bien le nommer « administrateur ». Dans tous les cas, ne publiez votre démarche quaprès avoir eu son avis. dpd_part_4: Comment faire ? Vous pouvez soit lui communiquer par email le lien vers la démarche en test, ou bien le nommer « administrateur ». Dans tous les cas, ne publiez votre démarche quaprès avoir eu son avis.
back_to_procedure: 'Annuler et revenir à la page de la démarche' back_to_procedure: 'Annuler et revenir à la page de la démarche'
submit: Publier submit: Publier
autosave_notice:
form_saved: "Formulaire enregistré"

View file

@ -78,6 +78,7 @@ module SystemHelpers
expect(page).to have_button('Ajouter un champ', disabled: false) expect(page).to have_button('Ajouter un champ', disabled: false)
expect(page).to have_content('Formulaire enregistré') expect(page).to have_content('Formulaire enregistré')
execute_script("document.querySelector('#flash_message').remove();") execute_script("document.querySelector('#flash_message').remove();")
execute_script("document.querySelector('#autosave-notice').remove();")
end end
def blur def blur