Skip to content

Commit

Permalink
feat(admin): disable publish button when there are errors
Browse files Browse the repository at this point in the history
  • Loading branch information
colinux committed Aug 21, 2024
1 parent d0837c5 commit eccfde8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
= t('.intro_html').html_safe
%span.no-wrap
= link_to t('.see_changes'), admin_procedure_path(procedure), class: 'fr-btn fr-btn--secondary fr-mr-2w'
= link_to t('.publish_changes'), admin_procedure_publish_revision_path(procedure), class: 'fr-btn', method: :put, data: { disable_with: "Publication...", confirm: 'Êtes-vous sûr de vouloir publier les modifications ?' }
= link_to_if procedure.draft_revision.valid? && procedure.valid?(:publication), t('.publish_changes'), admin_procedure_publish_revision_path(procedure), class: 'fr-btn', method: :put, data: { disable_with: "Publication...", confirm: 'Êtes-vous sûr de vouloir publier les modifications ?' } do
%button.fr-btn{ disabled: "disabled" }= t('.publish_changes')
3 changes: 3 additions & 0 deletions spec/system/administrateurs/types_de_champ_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,16 @@

within all('.type-de-champ').last do
fill_in 'Libellé du champ', with: 'Deuxième champ'
select 'Choix simple', from: 'Type de champ'
fill_in "Options de la liste", with: "" # make tdc invalid
end

expect(page).to have_field('Libellé du champ', with: 'Premier champ')
expect(page).to have_field('Libellé du champ', with: 'Deuxième champ')

expect(page).to have_selector('.sticky-header.sticky-header-warning')
expect(page).to have_content("Les modifications effectuées ne seront visibles qu'à la prochaine publication")
expect(page).to have_button('Publier les modifications', disabled: true)

# Supprime dernier champ
all('.fr-btn--tertiary-no-outline[title="Supprimer le champ"]').last.click
Expand Down

0 comments on commit eccfde8

Please sign in to comment.