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

[admin] Ajout d'une page de confirmation après la publication d'une procédure - mise en avant de l'URL à partager #9672

Merged
merged 2 commits into from
Nov 16, 2023
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
28 changes: 15 additions & 13 deletions app/controllers/administrateurs/procedures_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class ProceduresController < AdministrateurController
layout 'all', only: [:all, :administrateurs]
respond_to :html, :xlsx

before_action :retrieve_procedure, only: [:champs, :annotations, :modifications, :edit, :zones, :monavis, :update_monavis, :jeton, :update_jeton, :publication, :publish, :transfert, :close, :allow_expert_review, :allow_expert_messaging, :experts_require_administrateur_invitation, :reset_draft]
before_action :retrieve_procedure, only: [:champs, :annotations, :modifications, :edit, :zones, :monavis, :update_monavis, :jeton, :update_jeton, :publication, :publish, :transfert, :close, :confirmation, :allow_expert_review, :allow_expert_messaging, :experts_require_administrateur_invitation, :reset_draft, :publish_revision]
before_action :draft_valid?, only: [:apercu]
after_action :reset_procedure, only: [:update]

Expand Down Expand Up @@ -277,18 +277,10 @@ def publication
def publish
@procedure.assign_attributes(publish_params)

@procedure.publish_or_reopen!(current_administrateur)

if @procedure.draft_changed?
if @procedure.close?
if @procedure.publish_or_reopen!(current_administrateur)
@procedure.publish_revision!
flash.notice = "Démarche publiée"
end
else
@procedure.publish_revision!
flash.notice = "Nouvelle version de la démarche publiée"
end
elsif @procedure.publish_or_reopen!(current_administrateur)
flash.notice = "Démarche publiée"
@procedure.publish_revision!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T'y es pour rien car ça vient du nommage des méthodes à cause du cas du reopen mais c'est un peu bizarre/pas intuitif d'avoir d'abord publish_or_reopen puis publish_revision si on a modifié le brouillon

end

if params[:old_procedure].present? && @procedure.errors.empty?
Expand All @@ -300,7 +292,7 @@ def publish
.update!(replaced_by_procedure: @procedure)
end

redirect_to admin_procedure_path(@procedure)
redirect_to admin_procedure_confirmation_path(@procedure)
rescue ActiveRecord::RecordInvalid
flash.alert = @procedure.errors.full_messages
redirect_to admin_procedure_publication_path(@procedure)
Expand All @@ -312,12 +304,22 @@ def reset_draft
redirect_to admin_procedure_path(@procedure)
end

def publish_revision
@procedure.publish_revision!
flash.notice = "Nouvelle version de la démarche publiée"

redirect_to admin_procedure_path(@procedure)
end

def transfert
end

def close
end

def confirmation
end

def allow_expert_review
@procedure.update!(allow_expert_review: [email protected]_expert_review)
flash.notice = @procedure.allow_expert_review? ? "Avis externes activés" : "Avis externes désactivés"
Expand Down
23 changes: 23 additions & 0 deletions app/views/administrateurs/procedures/confirmation.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
= render partial: 'administrateurs/breadcrumbs',
locals: { steps: [['Démarches', admin_procedures_back_path(@procedure)],
[@procedure.libelle.truncate_words(10), admin_procedure_path(@procedure)],
['Confirmation']] }

.fr-container
.fr-grid-row
.fr-col-12.fr-col-offset-md-2.fr-col-md-8
%h1= t('administrateurs.procedures.publication.confirmation')

= render Dsfr::CalloutComponent.new(title: nil) do |c|
- c.with_body do
%p= t('administrateurs.procedures.publication.share_link')
%p
%strong= commencer_url(@procedure.path)
= render Dsfr::CopyButtonComponent.new(text: commencer_url(@procedure.path), title: t("administrateurs.procedures.publication.copy_url"))

%ul.fr-mt-2w.fr-btns-group.fr-btns-group--inline
%li= link_to t('administrateurs.procedures.publication.back_to_procedure'), admin_procedure_path(id: @procedure), class: 'fr-btn'
%li= link_to t('administrateurs.procedures.publication.new_procedure'), new_from_existing_admin_procedures_path, class: 'fr-btn fr-btn--secondary'

.text-center
= image_tag('landing/hero/dematerialiser.svg', "aria-hidden": true)
5 changes: 4 additions & 1 deletion app/views/administrateurs/procedures/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@

- c.bottom do
%ul.fr-mt-2w.fr-btns-group.fr-btns-group--inline
%li= button_to 'Publier les modifications', admin_procedure_publication_path(@procedure), class: 'fr-btn', id: 'publish-procedure-link', data: { disable_with: "Publication..." }, disabled: [email protected]_revision.valid?, method: :get
- if @procedure.publiee?
%li= button_to 'Publier les modifications', admin_procedure_publish_revision_path(@procedure), class: 'fr-btn', id: 'publish-procedure-link', data: { disable_with: "Publication...", confirm: 'Êtes-vous sûr de vouloir publier les modifications ?' }, disabled: [email protected]_revision.valid?, method: :put
- else
%li= button_to 'Publier les modifications', admin_procedure_publication_path(@procedure), class: 'fr-btn', id: 'publish-procedure-link', data: { disable_with: "Publication..." }, disabled: [email protected]_revision.valid?, method: :get
%li= button_to "Réinitialiser les modifications", admin_procedure_reset_draft_path(@procedure), class: 'fr-btn fr-btn--secondary fr-mr-2w', data: { confirm: 'Êtes-vous sûr de vouloir réinitialiser les modifications ?' }, method: :put

- if [email protected]_expires_when_termine_enabled?
Expand Down
4 changes: 4 additions & 0 deletions config/locales/views/administrateurs/procedures/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ en:
other: "%{count} files « instructing » on this procedure version."
publication:
publish_title: Publish your procedure
confirmation: Your procedure is now published !
copy_url: Copy procedure URL
share_link: "To share your procedure, always use the full link below:"
closed_procedure_html: "This procedure is <strong>closed</strong> and is therefore no longer accessible to the public. You can publish it back"
draft_changed_procedure_html: "This procedure is already <strong>published</strong>. It has been <strong>edited</strong> since publication. You can publish the changes made in a new version."
published_procedure_html: "This procedure is <strong>published</strong>, some elements can no longer be modified. To access it you can use the link:"
Expand All @@ -34,6 +37,7 @@ en:
dubious_fields: "Please note that some fields cannot be requested by the administration. Here are the fields that look suspicious to us:"
click_here: Click here
back_to_procedure: Return to the procedure page
new_procedure: Create a new procedure
publication_form:
faq_test_alert: Have you thought about testing your procedure before publishing it? To help you in this test phase, you can
faq_test_alert_link: consult our best practices guide.
Expand Down
4 changes: 4 additions & 0 deletions config/locales/views/administrateurs/procedures/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ fr:
other: Il y a %{count} dossiers « en instruction » sur cette version de la démarche.
publication:
publish_title: Publier votre démarche
confirmation: Votre démarche est désormais publiée !
copy_url: Copiez le lien de la procédure
share_link: "Pour partager votre démarche, utilisez toujours le lien complet ci-dessous :"
closed_procedure_html: "Cette démarche est <strong>close</strong> et n’est donc plus accessible par le public. Vous pouvez la réactiver :"
draft_changed_procedure_html: "Cette démarche est déjà <strong>publiée</strong>. Elle a été <strong>modifiée</strong> depuis sa publication. Vous pouvez publier les changements effectués dans une nouvelle version de cette démarche :"
published_procedure_html: "Cette démarche est <strong>publiée</strong>, certains éléments ne peuvent plus être modifiés. Pour y accéder vous pouvez utiliser le lien :"
Expand All @@ -34,6 +37,7 @@ fr:
dubious_fields: "Attention, certains champs ne peuvent être demandés par l’administration. Voici les champs qui nous semblent suspects :"
click_here: Cliquez ici.
back_to_procedure: Revenir à la page de la démarche
new_procedure: Créer une nouvelle démarche
publication_form:
faq_test_alert: Avez-vous bien pensé à tester votre démarche avant de la publier ? Pour vous aider dans cette phase de test, vous pouvez
faq_test_alert_link: consulter notre guide de bonnes pratiques.
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,10 @@
get 'publication' => 'procedures#publication', as: :publication
put 'publish' => 'procedures#publish', as: :publish
put 'reset_draft' => 'procedures#reset_draft', as: :reset_draft
put 'publish_revision' => 'procedures#publish_revision', as: :publish_revision
get 'transfert' => 'procedures#transfert', as: :transfert
get 'close' => 'procedures#close', as: :close
get 'confirmation' => 'procedures#confirmation', as: :confirmation
post 'transfer' => 'procedures#transfer', as: :transfer
resources :mail_templates, only: [:edit, :update, :show]

Expand Down
10 changes: 4 additions & 6 deletions spec/controllers/administrateurs/procedures_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -965,10 +965,9 @@ def update_monavis
expect(procedure.lien_site_web).to eq(lien_site_web)
end

it 'redirects to the procedure page' do
it 'redirects to the confirmation page' do
expect(response.status).to eq 302
expect(response.body).to include(admin_procedure_path(procedure.id))
expect(flash[:notice]).to have_content 'Démarche publiée'
expect(response.body).to include(admin_procedure_confirmation_path(procedure.id))
end
end

Expand All @@ -992,10 +991,9 @@ def update_monavis
expect(procedure2.depubliee?).to be_truthy
end

it 'redirects to the procedures page' do
it 'redirects to the confirmation page' do
expect(response.status).to eq 302
expect(response.body).to include(admin_procedure_path(procedure.id))
expect(flash[:notice]).to have_content 'Démarche publiée'
expect(response.body).to include(admin_procedure_confirmation_path(procedure.id))
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def find_attestation_card(with_nested_selector: nil)
click_on("Publier")
# validate publication
within('form') { click_on 'Publier' }
click_on("Revenir à la page de la démarche")

# now process to disable attestation
find_attestation_card.click
Expand Down
7 changes: 4 additions & 3 deletions spec/system/administrateurs/procedure_publish_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
fill_in 'lien_site_web', with: 'http://some.website'
within('form') { click_on 'Publier' }

expect(page).to have_text('Démarche publiée')
expect(page).to have_text('Votre démarche est désormais publiée !')
expect(page).to have_button(title: 'Copiez le lien de la procédure')
end

context 'when the procedure has invalid champs' do
Expand Down Expand Up @@ -91,7 +92,7 @@
fill_in 'lien_site_web', with: 'http://some.website'
click_on 'publish'

expect(page).to have_text('Démarche publiée')
expect(page).to have_text('Votre démarche est désormais publiée !')
end
end

Expand Down Expand Up @@ -122,7 +123,7 @@
fill_in 'lien_site_web', with: 'http://some.website'
find('#publish').click

expect(page).to have_text('Démarche publiée')
expect(page).to have_text('Votre démarche est désormais publiée !')
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/system/api_particulier/api_particulier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
fill_in 'lien_site_web', with: 'http://some.website'
within('form') { click_on 'Publier' }

expect(page).to have_text('Démarche publiée')
expect(page).to have_text('Votre démarche est désormais publiée !')
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/system/routing/rules_full_scenario_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def publish_procedure(procedure)
fill_in 'lien_site_web', with: 'http://some.website'
within('form') { click_on 'Publier' }

expect(page).to have_text('Démarche publiée')
expect(page).to have_text('Votre démarche est désormais publiée !')
end

def user_send_dossier(user, groupe)
Expand Down