Avis instruction: can ask for a confidentiel avis
This commit is contained in:
parent
4dd20c17d1
commit
caaa3169e5
6 changed files with 137 additions and 9 deletions
|
@ -9,10 +9,30 @@
|
|||
margin-bottom: $default-padding;
|
||||
}
|
||||
|
||||
.avis-notice {
|
||||
.lock {
|
||||
margin-right: $default-spacer;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-weight: bold;
|
||||
margin-bottom: $default-padding;
|
||||
}
|
||||
|
||||
.introduction {
|
||||
margin-bottom: $default-padding;
|
||||
}
|
||||
|
||||
.confidentiel {
|
||||
color: $grey;
|
||||
font-weight: normal;
|
||||
margin-bottom: 2 * $default-padding;
|
||||
}
|
||||
|
||||
.date {
|
||||
font-size: 12px;
|
||||
color: $grey;
|
||||
margin-bottom: 2 * $default-padding;
|
||||
float: right;
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +44,7 @@
|
|||
}
|
||||
|
||||
.avis-notice {
|
||||
font-size: 12px;
|
||||
font-size: 14px;
|
||||
color: $grey;
|
||||
margin-bottom: 2 * $default-padding;
|
||||
}
|
||||
|
@ -32,6 +52,23 @@
|
|||
input[type=email] {
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
form > label {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.confidentiel {
|
||||
color: $grey;
|
||||
font-weight: normal;
|
||||
margin-bottom: 2 * $default-padding;
|
||||
}
|
||||
|
||||
.confidentiel-wrapper {
|
||||
label,
|
||||
select {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.list-avis {
|
||||
|
@ -57,6 +94,10 @@
|
|||
border-top: 1px solid $grey;
|
||||
padding: $default-padding 0;
|
||||
|
||||
.lock {
|
||||
margin-right: $default-spacer;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-weight: bold;
|
||||
margin-bottom: $default-spacer;
|
||||
|
@ -73,6 +114,18 @@
|
|||
.avis-icon {
|
||||
margin-right: $default-spacer;
|
||||
}
|
||||
|
||||
.confidentiel {
|
||||
color: $grey;
|
||||
font-size: 12px;
|
||||
|
||||
.lock {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
background-size: 12px 12px;
|
||||
vertical-align: sub;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.date,
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
align-items: flex-start;
|
||||
}
|
||||
|
||||
&.align-baseline {
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
&.justify-between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,12 @@ module NewGestionnaire
|
|||
redirect_to messagerie_avis_path(avis)
|
||||
end
|
||||
|
||||
def create_avis
|
||||
confidentiel = avis.confidentiel || params[:avis][:confidentiel]
|
||||
Avis.create(create_avis_params.merge(claimant: current_gestionnaire, dossier: avis.dossier, confidentiel: confidentiel))
|
||||
redirect_to instruction_avis_path(avis)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def avis
|
||||
|
@ -58,5 +64,9 @@ module NewGestionnaire
|
|||
def commentaire_params
|
||||
params.require(:commentaire).permit(:body)
|
||||
end
|
||||
|
||||
def create_avis_params
|
||||
params.require(:avis).permit(:email, :introduction)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,21 +4,39 @@
|
|||
.container
|
||||
%section.give-avis
|
||||
%h1 Donner votre avis
|
||||
%p.avis-notice= "#{@avis.claimant.email}: #{@avis.introduction}"
|
||||
%h2.claimant
|
||||
= @avis.claimant.email
|
||||
%span.date Demande d'avis envoyée le #{I18n.l(@avis.created_at.localtime, format: '%d/%m/%y')}
|
||||
%p.introduction= @avis.introduction
|
||||
|
||||
= form_for @avis, url: avis_path(@avis), html: { class: 'form' } do |f|
|
||||
= f.text_area :answer, rows: 3, placeholder: 'Votre avis', required: true
|
||||
.send-wrapper
|
||||
= f.submit 'Envoyer votre avis', class: 'button send'
|
||||
.flex.justify-between.align-baseline
|
||||
%p.confidentiel
|
||||
%i.lock
|
||||
Cet avis est confidentiel et n'est pas affiché aux autres experts consultés
|
||||
.send-wrapper
|
||||
= f.submit 'Envoyer votre avis', class: 'button send'
|
||||
|
||||
%section.ask-avis
|
||||
%h1 Inviter une personne à donner son avis
|
||||
%p.avis-notice L'invité pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais il ne pourra le modifier.
|
||||
|
||||
= form_for Avis.new, url: avis_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' } do |f|
|
||||
= form_for Avis.new, url: avis_avis_path(@avis), html: { class: 'form' } do |f|
|
||||
= f.email_field :email, placeholder: 'Adresse email', required: true
|
||||
= f.text_area :introduction, rows: 3, value: 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true
|
||||
.send-wrapper
|
||||
= f.submit 'Demander un avis', class: 'button send'
|
||||
.flex.justify-between.align-baseline
|
||||
- if @avis.confidentiel?
|
||||
%p.confidentiel
|
||||
%i.lock
|
||||
Cet avis est confidentiel et n'est pas affiché aux autres experts consultés
|
||||
.send-wrapper
|
||||
= f.submit 'Demander un avis', class: 'button send'
|
||||
- else
|
||||
.confidentiel-wrapper
|
||||
= f.label :confidentiel, 'Cet avis est'
|
||||
= f.select :confidentiel, [['partagé avec les autres experts', false], ['confidentiel', true]]
|
||||
.send-wrapper
|
||||
= f.submit 'Demander un avis', class: 'button send'
|
||||
|
||||
= render partial: 'avis_list', locals: { avis: @dossier.avis_for(current_gestionnaire) }
|
||||
|
|
|
@ -263,6 +263,7 @@ Rails.application.routes.draw do
|
|||
get 'instruction'
|
||||
get 'messagerie'
|
||||
post 'commentaire' => 'avis#create_commentaire'
|
||||
post 'avis' => 'avis#create_avis'
|
||||
end
|
||||
end
|
||||
get "recherche" => "recherches#index"
|
||||
|
|
|
@ -70,4 +70,46 @@ describe NewGestionnaire::AvisController, type: :controller do
|
|||
it { expect(response).to redirect_to(messagerie_avis_path(avis_without_answer)) }
|
||||
it { expect(dossier.commentaires.map(&:body)).to match(['commentaire body']) }
|
||||
end
|
||||
|
||||
describe '#create_avis' do
|
||||
let!(:previous_avis) { Avis.create(dossier: dossier, claimant: claimant, gestionnaire: gestionnaire, confidentiel: previous_avis_confidentiel) }
|
||||
let(:email) { 'a@b.com' }
|
||||
let(:intro) { 'introduction' }
|
||||
let(:created_avis) { Avis.last }
|
||||
|
||||
before do
|
||||
post :create_avis, { id: previous_avis.id, avis: { email: email, introduction: intro, confidentiel: asked_confidentiel } }
|
||||
end
|
||||
|
||||
context 'when the previous avis is public' do
|
||||
let(:previous_avis_confidentiel) { false }
|
||||
|
||||
context 'when the user asked for a public avis' do
|
||||
let(:asked_confidentiel) { false }
|
||||
|
||||
it { expect(created_avis.confidentiel).to be(false) }
|
||||
it { expect(created_avis.email).to eq(email) }
|
||||
it { expect(created_avis.introduction).to eq(intro) }
|
||||
it { expect(created_avis.dossier).to eq(previous_avis.dossier) }
|
||||
it { expect(created_avis.claimant).to eq(gestionnaire) }
|
||||
it { expect(response).to redirect_to(instruction_avis_path(previous_avis)) }
|
||||
end
|
||||
|
||||
context 'when the user asked for a confidentiel avis' do
|
||||
let(:asked_confidentiel) { true }
|
||||
|
||||
it { expect(created_avis.confidentiel).to be(true) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the preivous avis is confidentiel' do
|
||||
let(:previous_avis_confidentiel) { true }
|
||||
|
||||
context 'when the user asked for a public avis' do
|
||||
let(:asked_confidentiel) { false }
|
||||
|
||||
it { expect(created_avis.confidentiel).to be(true) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue