Merge pull request #10127 from demarches-simplifiees/feat/10005
ETQ expert, je veux pouvoir gérer les notifications que je reçois depuis mon interface
This commit is contained in:
commit
e73318e3bb
13 changed files with 182 additions and 13 deletions
|
@ -59,7 +59,9 @@ module CreateAvisConcern
|
|||
persisted.each do |avis|
|
||||
avis.dossier.demander_un_avis!(avis)
|
||||
if avis.dossier == dossier
|
||||
AvisMailer.avis_invitation(avis).deliver_later
|
||||
if avis.experts_procedure.notify_on_new_avis?
|
||||
AvisMailer.avis_invitation(avis).deliver_later
|
||||
end
|
||||
sent_emails_addresses << avis.expert.email
|
||||
# the email format is already verified, we update value to nil
|
||||
avis.update_column(:email, nil)
|
||||
|
|
|
@ -4,10 +4,11 @@ module Experts
|
|||
include Zipline
|
||||
|
||||
before_action :authenticate_expert!, except: [:sign_up, :update_expert]
|
||||
before_action :check_if_avis_revoked, except: [:index, :procedure]
|
||||
before_action :check_if_avis_revoked, except: [:index, :procedure, :notification_settings, :update_notification_settings]
|
||||
before_action :redirect_if_no_sign_up_needed, only: [:sign_up, :update_expert]
|
||||
before_action :set_avis_and_dossier, only: [:show, :instruction, :avis_list, :avis_new, :messagerie, :create_commentaire, :delete_commentaire, :update, :telecharger_pjs]
|
||||
before_action :check_messaging_allowed, only: [:messagerie, :create_commentaire]
|
||||
before_action :set_procedure, only: [:notification_settings, :update_notification_settings]
|
||||
|
||||
A_DONNER_STATUS = 'a-donner'
|
||||
DONNES_STATUS = 'donnes'
|
||||
|
@ -66,6 +67,20 @@ module Experts
|
|||
def avis_list
|
||||
end
|
||||
|
||||
def expert_procedure
|
||||
ExpertsProcedure.find_by!(expert_id: current_expert.id, procedure_id: @procedure.id)
|
||||
end
|
||||
|
||||
def notification_settings
|
||||
@expert_procedure = expert_procedure
|
||||
end
|
||||
|
||||
def update_notification_settings
|
||||
expert_procedure.update!(expert_procedure_params)
|
||||
flash.notice = 'Vos notifications sont enregistrées.'
|
||||
redirect_to procedure_expert_avis_index_path(@procedure)
|
||||
end
|
||||
|
||||
def avis_new
|
||||
@new_avis = Avis.new
|
||||
if @dossier.procedure.experts_require_administrateur_invitation?
|
||||
|
@ -167,6 +182,15 @@ module Experts
|
|||
|
||||
private
|
||||
|
||||
def expert_procedure_params
|
||||
params.require(:experts_procedure)
|
||||
.permit(:notify_on_new_avis, :notify_on_new_message)
|
||||
end
|
||||
|
||||
def set_procedure
|
||||
@procedure = current_expert.procedures.find(params[:procedure_id])
|
||||
end
|
||||
|
||||
def check_messaging_allowed
|
||||
if !@avis.procedure.allow_expert_messaging
|
||||
flash[:alert] = "Vous n'êtes pas autorisé à acceder à la messagerie"
|
||||
|
|
|
@ -120,7 +120,8 @@ class Commentaire < ApplicationRecord
|
|||
experts_contactes = Set.new
|
||||
|
||||
dossier.avis.includes(:expert).find_each do |avis|
|
||||
if avis.expert.present?
|
||||
expert_procedure = avis.expert.experts_procedures.find_by(procedure_id: dossier.procedure.id)
|
||||
if expert_procedure.notify_on_new_message? && avis.expert.present?
|
||||
expert_id = avis.expert.id
|
||||
if !experts_contactes.include?(expert_id)
|
||||
AvisMailer.notify_new_commentaire_to_expert(dossier, avis, avis.expert).deliver_later
|
||||
|
|
60
app/views/experts/avis/notification_settings.html.haml
Normal file
60
app/views/experts/avis/notification_settings.html.haml
Normal file
|
@ -0,0 +1,60 @@
|
|||
|
||||
.sub-header
|
||||
.fr-container.flex
|
||||
|
||||
.procedure-logo{ style: "background-image: url(#{@procedure.logo_url})",
|
||||
role: 'img', 'aria-label': "logo de la démarche #{@procedure.libelle}" }
|
||||
|
||||
.procedure-header
|
||||
%h1.fr-h3= procedure_libelle @procedure
|
||||
|
||||
.fr-container
|
||||
%h1.fr-h3
|
||||
= t('.title')
|
||||
|
||||
= form_for @expert_procedure, url: update_notification_settings_expert_procedure_path(@procedure), html: { class: 'form' } do |form|
|
||||
= render Dsfr::AlertComponent.new(state: :info, size: :sm, extra_class_names: 'fr-mb-2w') do |c|
|
||||
- c.with_body do
|
||||
%p
|
||||
= t('.subtitle')
|
||||
|
||||
%fieldset.fr-fieldset
|
||||
%legend.fr-fieldset__legend
|
||||
= t(".for_each_avis_submitted.title")
|
||||
%span.fr-hint-text= t('.for_each_avis_submitted.notice_1')
|
||||
%span.fr-hint-text= t('.for_each_avis_submitted.notice_2')
|
||||
.fr-fieldset__element.fr-fieldset__element--inline
|
||||
.fr-radio-group
|
||||
= form.radio_button :notify_on_new_avis, true, id: 'notify_on_new_avis_true'
|
||||
%label.fr-label{ for: 'notify_on_new_avis_true' }
|
||||
= t('.utils.positive')
|
||||
|
||||
|
||||
.fr-fieldset__element.fr-fieldset__element--inline
|
||||
.fr-radio-group
|
||||
= form.radio_button :notify_on_new_avis, false, id: 'notify_on_new_avis_false'
|
||||
%label.fr-label{ for: 'notify_on_new_avis_false' }
|
||||
= t('.utils.negative')
|
||||
|
||||
|
||||
%fieldset.fr-fieldset
|
||||
%legend.fr-fieldset__legend
|
||||
= t(".for_each_message_submitted.title")
|
||||
%span.fr-hint-text= t('.for_each_message_submitted.notice_1')
|
||||
%span.fr-hint-text= t('.for_each_message_submitted.notice_2')
|
||||
.fr-fieldset__element.fr-fieldset__element--inline
|
||||
.fr-radio-group
|
||||
= form.radio_button :notify_on_new_message, true, id: 'notify_on_new_message_true'
|
||||
%label.fr-label{ for: 'notify_on_new_message_true' }
|
||||
= t('.utils.positive')
|
||||
|
||||
|
||||
.fr-fieldset__element.fr-fieldset__element--inline
|
||||
.fr-radio-group
|
||||
= form.radio_button :notify_on_new_message, false, id: 'notify_on_new_message_false'
|
||||
%label.fr-label{ for: 'notify_on_new_message_false' }
|
||||
= t('.utils.negative')
|
||||
|
||||
%ul.fr-btns-group.fr-btns-group--inline
|
||||
%li= form.submit t('.buttons.save'), class: "fr-btn"
|
||||
%li= link_to t('.buttons.back_to_procedure', procedure_id: @procedure.id), procedure_expert_avis_index_path(@procedure), class: 'fr-btn fr-btn--secondary'
|
|
@ -10,6 +10,9 @@
|
|||
|
||||
.procedure-header
|
||||
%h1.fr-h3= procedure_libelle @procedure
|
||||
= link_to t('.management', procedure_id: @procedure.id), notification_settings_expert_procedure_path(@procedure), class: 'header-link'
|
||||
|
||||
|
||||
|
||||
%nav.fr-tabs
|
||||
%ul.fr-tabs__list{ role: 'tablist' }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue