fix(instructeur): procedure form preview
This commit is contained in:
parent
7d2821aa81
commit
874f992e5e
9 changed files with 59 additions and 4 deletions
|
@ -20,4 +20,13 @@ class EditableChamp::ChampLabelContentComponent < ApplicationComponent
|
||||||
def highlight?
|
def highlight?
|
||||||
@champ.updated_at.present? && @seen_at&.<(@champ.updated_at)
|
@champ.updated_at.present? && @seen_at&.<(@champ.updated_at)
|
||||||
end
|
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
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
%span.updated-at{ class: highlight_if_unseen_class }
|
%span.updated-at{ class: highlight_if_unseen_class }
|
||||||
= t('.modified_at', datetime: try_format_datetime(@champ.updated_at))
|
= 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
|
%span.updated-at.highlighted
|
||||||
= t('.check_content_rebased')
|
= t('.check_content_rebased')
|
||||||
|
|
||||||
|
|
|
@ -266,6 +266,12 @@ module Instructeurs
|
||||||
@administrateurs = procedure.administrateurs
|
@administrateurs = procedure.administrateurs
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def apercu
|
||||||
|
@procedure = procedure
|
||||||
|
@dossier = procedure.active_revision.dossier_for_preview(current_user)
|
||||||
|
DossierPreloader.load_one(@dossier)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def assign_to_params
|
def assign_to_params
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
%li
|
%li
|
||||||
= link_to t('instructeurs.dossiers.header.banner.contact_users'), email_usagers_instructeur_procedure_path(procedure), class: 'fr-nav__link'
|
= link_to t('instructeurs.dossiers.header.banner.contact_users'), email_usagers_instructeur_procedure_path(procedure), class: 'fr-nav__link'
|
||||||
%li
|
%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
|
%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
|
= 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')
|
= t('instructeurs.dossiers.header.banner.copy_link_button')
|
||||||
|
|
15
app/views/instructeurs/procedures/apercu.html.haml
Normal file
15
app/views/instructeurs/procedures/apercu.html.haml
Normal file
|
@ -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 }
|
|
@ -26,5 +26,6 @@ en:
|
||||||
buttons:
|
buttons:
|
||||||
back_to_procedure: Back to procedure
|
back_to_procedure: Back to procedure
|
||||||
save: Save
|
save: Save
|
||||||
|
apercu:
|
||||||
|
title_with_libelle: Preview of « %{libelle} »
|
||||||
|
title: Procedure preview
|
||||||
|
|
|
@ -30,3 +30,6 @@ fr:
|
||||||
buttons:
|
buttons:
|
||||||
back_to_procedure: Revenir à la procédure
|
back_to_procedure: Revenir à la procédure
|
||||||
save: Enregistrer
|
save: Enregistrer
|
||||||
|
apercu:
|
||||||
|
title_with_libelle: Prévisualisation de « %{libelle} »
|
||||||
|
title: Prévisualisation de la démarche
|
||||||
|
|
|
@ -490,6 +490,7 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get 'apercu'
|
||||||
get 'download_export'
|
get 'download_export'
|
||||||
post 'download_export'
|
post 'download_export'
|
||||||
get 'polling_last_export'
|
get 'polling_last_export'
|
||||||
|
|
|
@ -926,4 +926,24 @@ describe Instructeurs::ProceduresController, type: :controller do
|
||||||
it { is_expected.to have_http_status(:forbidden) }
|
it { is_expected.to have_http_status(:forbidden) }
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue