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 Instructeur je peux prévisualiser le formulaire d'une démarche #11083

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
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,13 @@
def highlight?
@champ.updated_at.present? && @seen_at&.<(@champ.updated_at)
end

def rebased?
return false if @champ.rebased_at.blank?
return false if @champ.rebased_at <= (@seen_at || @champ.updated_at)
return false if !current_user.owns_or_invite?(@champ.dossier)
return false if @champ.dossier.for_procedure_preview?

true

Check warning on line 30 in app/components/editable_champ/champ_label_content_component.rb

View check run for this annotation

Codecov / codecov/patch

app/components/editable_champ/champ_label_content_component.rb#L30

Added line #L30 was not covered by tests
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
%span.updated-at{ class: highlight_if_unseen_class }
= t('.modified_at', datetime: try_format_datetime(@champ.updated_at))

- if @champ.rebased_at.present? && @champ.rebased_at > (@seen_at || @champ.updated_at) && current_user.owns_or_invite?(@champ.dossier)
- if rebased?
%span.updated-at.highlighted
= t('.check_content_rebased')

Expand Down
6 changes: 6 additions & 0 deletions app/controllers/instructeurs/procedures_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ def administrateurs
@administrateurs = procedure.administrateurs
end

def apercu
@procedure = procedure
@dossier = procedure.active_revision.dossier_for_preview(current_user)
DossierPreloader.load_one(@dossier)
end

private

def assign_to_params
Expand Down
2 changes: 1 addition & 1 deletion app/views/instructeurs/procedures/_header.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
%li
= link_to t('instructeurs.dossiers.header.banner.contact_users'), email_usagers_instructeur_procedure_path(procedure), class: 'fr-nav__link'
%li
= link_to t('instructeurs.dossiers.header.banner.preview'), apercu_admin_procedure_path(@procedure), target: "_blank", rel: "noopener", class: 'fr-nav__link'
= link_to t('instructeurs.dossiers.header.banner.preview'), apercu_instructeur_procedure_path(@procedure), target: "_blank", rel: "noopener", class: 'fr-nav__link'
%li
= link_to "#", class: "fr-nav__link fr-link fr-link--md fr-link--icon-left fr-icon-clipboard-line", data: {controller: "clipboard", clipboard_text_value: commencer_url(@procedure.path), action: "click->clipboard#copy" } do
= t('instructeurs.dossiers.header.banner.copy_link_button')
Expand Down
15 changes: 15 additions & 0 deletions app/views/instructeurs/procedures/apercu.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- content_for(:title, t('.title_with_libelle', libelle: @dossier.procedure.libelle))

.sub-header
.fr-container.flex.column
= render partial: 'instructeurs/breadcrumbs',
locals: { steps: [[t('show_procedure', scope: [:layouts, :breadcrumb], libelle: @procedure.libelle.truncate(22)), instructeur_procedure_path(@procedure)],
[t('instructeurs.dossiers.header.banner.preview')]] }
= render partial: 'instructeurs/procedures/header',
locals: { procedure: @procedure }


.fr-container
%h2.fr-h4= t('.title')

= render partial: "shared/dossiers/edit", locals: { dossier: @dossier }
2 changes: 1 addition & 1 deletion app/views/shared/dossiers/_edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
= render partial: "shared/dossiers/france_connect_informations_notice", locals: { user_information: dossier.user.france_connect_informations.first }


.dossier-edit.container.counter-start-header-section
.dossier-edit.fr-container.counter-start-header-section
= render partial: "shared/dossiers/submit_is_over", locals: { dossier: dossier }
= render NestedForms::FormOwnerComponent.new
= form_for dossier_for_editing, url: brouillon_dossier_url(dossier), method: :patch, html: { id: 'dossier-edit-form', class: 'form', multipart: true, novalidate: 'novalidate' } do |f|
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/dossiers/_edit_annotations.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.container.dossier-edit
.fr-container.dossier-edit
- if dossier.has_annotations?
%section.counter-start-header-section
= render NestedForms::FormOwnerComponent.new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ en:
buttons:
back_to_procedure: Back to procedure
save: Save


apercu:
title_with_libelle: Preview of « %{libelle} »
title: Procedure preview
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ fr:
buttons:
back_to_procedure: Revenir à la procédure
save: Enregistrer
apercu:
title_with_libelle: Prévisualisation de « %{libelle} »
title: Prévisualisation de la démarche
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@
end
end

get 'apercu'
get 'download_export'
post 'download_export'
get 'polling_last_export'
Expand Down
20 changes: 20 additions & 0 deletions spec/controllers/instructeurs/procedures_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -926,4 +926,24 @@
it { is_expected.to have_http_status(:forbidden) }
end
end

describe '#preview' do
render_views

let(:instructeur) { create(:instructeur) }
let(:procedure) { create(:procedure, types_de_champ_public: [type: :text, libelle: "Premier champ"]) }

before do
sign_in(instructeur.user)
create(:groupe_instructeur, procedure:, instructeurs: [instructeur])
end

it 'displays preview' do
get :apercu, params: { procedure_id: procedure.id }

expect(response).to have_http_status(:success)
expect(response.body).to include("Premier champ")
expect(response.body).not_to include("Déposer")
end
end
end
Loading