Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ETQ admin: corrige le nouveau bouton de publication d'une démarche #10707

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.sticky-header.sticky-header-warning
.fr-container
%p.flex.justify-between.align-center.fr-text-default--warning
%span
= dsfr_icon("fr-icon-warning-fill fr-mr-1v")
= 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_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')
2 changes: 1 addition & 1 deletion app/views/administrateurs/procedures/champs.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

- if @procedure.draft_changed?
- content_for(:sticky_header) do
= render partial: 'administrateurs/procedures/unpublished_changes_navbar', locals: { procedure: @procedure }
= render partial: 'administrateurs/procedures/unpublished_changes_sticky_header', locals: { procedure: @procedure }
= render partial: 'administrateurs/breadcrumbs',
locals: { steps: [['Démarches', admin_procedures_back_path(@procedure)],
[@procedure.libelle.truncate_words(10), admin_procedure_path(@procedure)],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

- if @procedure.draft_changed?
= turbo_stream.update "sticky-header" do
= render partial: "administrateurs/procedures/unpublished_changes_navbar", locals: { procedure: @procedure }
= render partial: "administrateurs/procedures/unpublished_changes_sticky_header", locals: { procedure: @procedure }

- else
= turbo_stream.update "sticky-header", ""
2 changes: 1 addition & 1 deletion config/locales/views/administrateurs/procedures/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ en:
path_not_available:
owner: This URL is identical to another of your published procedures. If you publish this procedure, the old one will be unpublished and will no longer be accessible to the public.
not_owner: This URL is identical to another procedure, you must modify it.
unpublished_changes_navbar:
unpublished_changes_sticky_header:
intro_html: Changes made will only be visible <strong>after the next publication</strong>
see_changes: View changes
publish_changes: Publish changes
2 changes: 1 addition & 1 deletion config/locales/views/administrateurs/procedures/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fr:
path_not_available:
owner: Cette url est identique à celle d’une autre de vos démarches publiées. Si vous publiez cette démarche, l’ancienne sera dépubliée et ne sera plus accessible au public.
not_owner: Cette url est identique à celle d’une autre démarche, vous devez la modifier afin de pouvoir publier votre démarche.
unpublished_changes_navbar:
unpublished_changes_sticky_header:
intro_html: Les modifications effectuées ne seront visibles <strong>qu'à la prochaine publication</strong>
see_changes: Voir les modifications
publish_changes: Publier les modifications
22 changes: 11 additions & 11 deletions spec/system/administrateurs/types_de_champ_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@
fill_in 'Libellé du champ', with: 'Premier 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_link('Publier les modifications')

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

Expand All @@ -378,27 +379,26 @@

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)

# Supprimer les champs
# Supprime dernier champ
all('.fr-btn--tertiary-no-outline[title="Supprimer le champ"]').last.click
page.driver.browser.switch_to.alert.accept rescue nil

2.times do
initial_count = page.all('.type-de-champ').count
expect(page).to have_selector('.type-de-champ', count: 1, wait: 5)
click_on "Publier les modifications"

first('.fr-btn--tertiary-no-outline[title="Supprimer le champ"]').click

page.driver.browser.switch_to.alert.accept rescue nil

expect(page).to have_selector('.type-de-champ', count: initial_count - 1, wait: 5)
end

expect(page).not_to have_selector('.sticky-header.sticky-header-warning')
page.driver.browser.switch_to.alert.accept
expect(page).to have_content("démarche publiée")

unpublished_procedure = create(:procedure)
visit champs_admin_procedure_path(unpublished_procedure)
Expand Down
Loading