Notification: UI
This commit is contained in:
parent
1644fd9059
commit
ed6828c66c
7 changed files with 75 additions and 1 deletions
|
@ -3,3 +3,7 @@
|
|||
.mb-1 {
|
||||
margin-bottom: $default-spacer;
|
||||
}
|
||||
|
||||
.mr-1 {
|
||||
margin-right: $default-spacer;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,12 @@
|
|||
h1 {
|
||||
color: $black;
|
||||
font-size: 22px;
|
||||
margin-bottom: 2 * $default-padding;
|
||||
margin-bottom: 1 * $default-padding;
|
||||
}
|
||||
|
||||
a.notifications {
|
||||
display: inline-block;
|
||||
margin-bottom: 1 * $default-padding;
|
||||
}
|
||||
|
||||
.dossiers-table {
|
||||
|
|
|
@ -186,6 +186,18 @@ module NewGestionnaire
|
|||
end
|
||||
end
|
||||
|
||||
def email_notifications
|
||||
@procedure = procedure
|
||||
@assign_to = assign_to
|
||||
end
|
||||
|
||||
def update_email_notifications
|
||||
assign_to.update!(email_notifications_enabled: params[:assign_to][:email_notifications_enabled])
|
||||
|
||||
flash.notice = 'Vos notifications sont enregistrées.'
|
||||
redirect_to gestionnaire_procedure_path(procedure)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_field(table, column)
|
||||
|
@ -196,6 +208,10 @@ module NewGestionnaire
|
|||
field.values_at('table', 'column').join('/')
|
||||
end
|
||||
|
||||
def assign_to
|
||||
current_gestionnaire.assign_to.find_by(procedure: procedure)
|
||||
end
|
||||
|
||||
def statut
|
||||
@statut ||= (params[:statut].presence || 'a-suivre')
|
||||
end
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
- content_for(:title, "Notifications pour #{@procedure.libelle}")
|
||||
|
||||
= render partial: 'new_administrateur/breadcrumbs',
|
||||
locals: { steps: [link_to(@procedure.libelle, procedure_path(@procedure)),
|
||||
'Notifications'] }
|
||||
|
||||
.container
|
||||
%h1 Notifications par email
|
||||
|
||||
= form_for @assign_to, url: update_email_notifications_gestionnaire_procedure_path(@procedure), html: { class: 'form' } do |form|
|
||||
= form.label :email_notification, "Recevoir une fois par jour, du lundi au samedi vers 10 h, un email de notification me signalant le dépôt de nouveaux dossiers ou des changements sur mes dossiers en cours"
|
||||
|
||||
.radios
|
||||
%label
|
||||
= form.radio_button :email_notifications_enabled, true
|
||||
Oui
|
||||
|
||||
%label
|
||||
= form.radio_button :email_notifications_enabled, false
|
||||
Non
|
||||
|
||||
.send-wrapper
|
||||
= link_to "Revenir à la procédure", gestionnaire_procedure_path(@procedure), class: 'button mr-1'
|
||||
= form.submit "Enregistrer", class: "button primary"
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
.procedure-header
|
||||
%h1= procedure_libelle @procedure
|
||||
= link_to 'configurez vos notifications', email_notifications_gestionnaire_procedure_path(@procedure), class: 'notifications'
|
||||
|
||||
|
||||
%ul.tabs
|
||||
= tab_item('à suivre',
|
||||
|
|
|
@ -315,6 +315,8 @@ Rails.application.routes.draw do
|
|||
post 'add_filter'
|
||||
get 'remove_filter/:statut/:table/:column/:value' => 'procedures#remove_filter', as: 'remove_filter'
|
||||
get 'download_dossiers'
|
||||
get 'email_notifications'
|
||||
patch 'update_email_notifications'
|
||||
|
||||
resources :dossiers, only: [:show], param: :dossier_id do
|
||||
member do
|
||||
|
|
|
@ -336,4 +336,25 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#update_email_notifications' do
|
||||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
let!(:procedure) { create(:procedure, gestionnaires: [gestionnaire]) }
|
||||
|
||||
context "when logged in" do
|
||||
before { sign_in(gestionnaire) }
|
||||
|
||||
it { expect(gestionnaire.procedures_with_email_notifications).to be_empty }
|
||||
|
||||
context 'when the gestionnaire update its preferences' do
|
||||
let(:assign_to) { gestionnaire.assign_to.find_by(procedure: procedure) }
|
||||
|
||||
before do
|
||||
patch :update_email_notifications, params: { procedure_id: procedure.id, assign_to: { id: assign_to.id, email_notifications_enabled: true } }
|
||||
end
|
||||
|
||||
it { expect(gestionnaire.procedures_with_email_notifications).to eq([procedure]) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue