[Fix #1016] display notifications for avis
This commit is contained in:
parent
8e67e5c057
commit
c3e7e39947
5 changed files with 33 additions and 6 deletions
|
@ -5,6 +5,7 @@ module NewGestionnaire
|
||||||
|
|
||||||
after_action :mark_demande_as_read, only: :show
|
after_action :mark_demande_as_read, only: :show
|
||||||
after_action :mark_messagerie_as_read, only: [:messagerie, :create_commentaire]
|
after_action :mark_messagerie_as_read, only: [:messagerie, :create_commentaire]
|
||||||
|
after_action :mark_avis_as_read, only: [:avis, :create_avis]
|
||||||
|
|
||||||
def attestation
|
def attestation
|
||||||
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
|
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
|
||||||
|
@ -25,8 +26,7 @@ module NewGestionnaire
|
||||||
end
|
end
|
||||||
|
|
||||||
def avis
|
def avis
|
||||||
dossier.notifications.avis.mark_as_read
|
@avis_seen_at = current_gestionnaire.follows.find_by(dossier: dossier)&.avis_seen_at
|
||||||
current_gestionnaire.mark_tab_as_seen(dossier, :avis)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def personnes_impliquees
|
def personnes_impliquees
|
||||||
|
@ -203,5 +203,10 @@ module NewGestionnaire
|
||||||
dossier.notifications.messagerie.mark_as_read
|
dossier.notifications.messagerie.mark_as_read
|
||||||
current_gestionnaire.mark_tab_as_seen(dossier, :messagerie)
|
current_gestionnaire.mark_tab_as_seen(dossier, :messagerie)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mark_avis_as_read
|
||||||
|
dossier.notifications.avis.mark_as_read
|
||||||
|
current_gestionnaire.mark_tab_as_seen(dossier, :avis)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
%span.confidentiel
|
%span.confidentiel
|
||||||
confidentiel
|
confidentiel
|
||||||
%span.icon.lock{ title: "Cet avis n'est pas affiché avec les autres experts consultés" }
|
%span.icon.lock{ title: "Cet avis n'est pas affiché avec les autres experts consultés" }
|
||||||
%span.date Demande d'avis envoyée le #{I18n.l(avis.created_at.localtime, format: '%d/%m/%y')}
|
%span.date{ class: highlight_if_unseen_class(avis_seen_at, avis.created_at) }
|
||||||
|
Demande d'avis envoyée le #{I18n.l(avis.created_at.localtime, format: '%d/%m/%y à %H:%M')}
|
||||||
%p= avis.introduction
|
%p= avis.introduction
|
||||||
|
|
||||||
.answer.flex.align-start
|
.answer.flex.align-start
|
||||||
|
@ -24,7 +25,8 @@
|
||||||
%h2.gestionnaire
|
%h2.gestionnaire
|
||||||
= (avis.email_to_display == current_gestionnaire.email) ? 'Vous' : avis.email_to_display
|
= (avis.email_to_display == current_gestionnaire.email) ? 'Vous' : avis.email_to_display
|
||||||
- if avis.answer.present?
|
- if avis.answer.present?
|
||||||
%span.date Réponse donnée le #{I18n.l(avis.updated_at.localtime, format: '%d/%m/%y')}
|
%span.date{ class: highlight_if_unseen_class(avis_seen_at, avis.updated_at) }
|
||||||
|
Réponse donnée le #{I18n.l(avis.updated_at.localtime, format: '%d/%m/%y à %H:%M')}
|
||||||
- else
|
- else
|
||||||
%span.waiting En attente de réponse
|
%span.waiting En attente de réponse
|
||||||
%p= avis.answer
|
%p= avis.answer
|
||||||
|
|
|
@ -42,4 +42,4 @@
|
||||||
.send-wrapper
|
.send-wrapper
|
||||||
= f.submit 'Demander un avis', class: 'button send'
|
= f.submit 'Demander un avis', class: 'button send'
|
||||||
|
|
||||||
= render partial: 'avis_list', locals: { avis: @dossier.avis_for(current_gestionnaire) }
|
= render partial: 'avis_list', locals: { avis: @dossier.avis_for(current_gestionnaire), avis_seen_at: nil }
|
||||||
|
|
|
@ -17,4 +17,4 @@
|
||||||
.send-wrapper
|
.send-wrapper
|
||||||
= f.submit 'Demander un avis', class: 'button send', data: { disable_with: "Envoi..." }
|
= f.submit 'Demander un avis', class: 'button send', data: { disable_with: "Envoi..." }
|
||||||
|
|
||||||
= render partial: 'new_gestionnaire/avis/avis_list', locals: { avis: @dossier.avis }
|
= render partial: 'new_gestionnaire/avis/avis_list', locals: { avis: @dossier.avis, avis_seen_at: @avis_seen_at }
|
||||||
|
|
20
spec/views/new_gestionnaire/avis/avis_list.html.haml_spec.rb
Normal file
20
spec/views/new_gestionnaire/avis/avis_list.html.haml_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
describe 'new_gestionnaire/avis/avis_list.html.haml', type: :view do
|
||||||
|
before { view.extend DossierHelper }
|
||||||
|
|
||||||
|
subject { render 'new_gestionnaire/avis/avis_list.html.haml', avis: avis, avis_seen_at: seen_at, current_gestionnaire: gestionnaire }
|
||||||
|
|
||||||
|
let(:gestionnaire) { create(:gestionnaire) }
|
||||||
|
let(:avis) { [create(:avis, claimant: gestionnaire)] }
|
||||||
|
|
||||||
|
context "with a seen_at after avis created_at" do
|
||||||
|
let(:seen_at) { avis.first.created_at + 1.hour }
|
||||||
|
|
||||||
|
it { is_expected.not_to have_css(".highlighted") }
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with a seen_at after avis created_at" do
|
||||||
|
let(:seen_at) { avis.first.created_at - 1.hour }
|
||||||
|
|
||||||
|
it { is_expected.to have_css(".highlighted") }
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue