diff --git a/app/views/administrateurs/procedures/_unpublished_changes_navbar.html.haml b/app/views/administrateurs/procedures/_unpublished_changes_navbar.html.haml deleted file mode 100644 index 97158037e24..00000000000 --- a/app/views/administrateurs/procedures/_unpublished_changes_navbar.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -.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 t('.publish_changes'), admin_procedure_publish_revision_path(procedure), class: 'fr-btn', method: :post, data: { disable_with: "Publication...", confirm: 'Êtes-vous sûr de vouloir publier les modifications ?' } diff --git a/app/views/administrateurs/procedures/_unpublished_changes_sticky_header.html.haml b/app/views/administrateurs/procedures/_unpublished_changes_sticky_header.html.haml new file mode 100644 index 00000000000..af2ec32b4eb --- /dev/null +++ b/app/views/administrateurs/procedures/_unpublished_changes_sticky_header.html.haml @@ -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') diff --git a/app/views/administrateurs/procedures/champs.html.haml b/app/views/administrateurs/procedures/champs.html.haml index fb85b6aeee2..e2a33167fef 100644 --- a/app/views/administrateurs/procedures/champs.html.haml +++ b/app/views/administrateurs/procedures/champs.html.haml @@ -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)], diff --git a/app/views/administrateurs/types_de_champ/_insert.turbo_stream.haml b/app/views/administrateurs/types_de_champ/_insert.turbo_stream.haml index ccf49114e74..7a246c79ad7 100644 --- a/app/views/administrateurs/types_de_champ/_insert.turbo_stream.haml +++ b/app/views/administrateurs/types_de_champ/_insert.turbo_stream.haml @@ -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", "" diff --git a/config/locales/views/administrateurs/procedures/en.yml b/config/locales/views/administrateurs/procedures/en.yml index 24fb5ebe0af..0f043ce36db 100644 --- a/config/locales/views/administrateurs/procedures/en.yml +++ b/config/locales/views/administrateurs/procedures/en.yml @@ -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 after the next publication see_changes: View changes publish_changes: Publish changes diff --git a/config/locales/views/administrateurs/procedures/fr.yml b/config/locales/views/administrateurs/procedures/fr.yml index 18c934906b5..320daad342d 100644 --- a/config/locales/views/administrateurs/procedures/fr.yml +++ b/config/locales/views/administrateurs/procedures/fr.yml @@ -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 qu'à la prochaine publication see_changes: Voir les modifications publish_changes: Publier les modifications diff --git a/spec/system/administrateurs/types_de_champ_spec.rb b/spec/system/administrateurs/types_de_champ_spec.rb index b25e6408756..e2852ac847a 100644 --- a/spec/system/administrateurs/types_de_champ_spec.rb +++ b/spec/system/administrateurs/types_de_champ_spec.rb @@ -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') @@ -378,6 +379,8 @@ 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') @@ -385,20 +388,17 @@ 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)