Notifications: show dossiers with notification in first place

This commit is contained in:
Simon Lehericey 2017-11-01 20:40:33 +01:00
parent 8df9462d1a
commit 2b146a6d62
4 changed files with 41 additions and 8 deletions

View file

@ -33,17 +33,30 @@
}
.icon.folder {
margin-right: $default-spacer;
position: relative;
.notifications {
top: 0px;
right: -10px;
top: -3px;
right: -6px;
}
}
.notification-col {
width: 30px;
text-align: center;
a {
font-size: 16px;
}
}
.number-col {
width: 110px;
text-align: center;
}
.folder-col {
text-align: center;
}
.status-col {

View file

@ -240,7 +240,16 @@ module NewGestionnaire
includes = ''
where = ''
sorted_ids = nil
case table
when 'notifications'
dossiers_id_with_notification = current_gestionnaire.notifications_for_procedure(procedure)
if order == 'desc'
sorted_ids = dossiers_id_with_notification + (dossiers.order('dossiers.updated_at desc').ids - dossiers_id_with_notification)
else
sorted_ids = (dossiers.order('dossiers.updated_at asc').ids - dossiers_id_with_notification) + dossiers_id_with_notification
end
when 'self'
order = "dossiers.#{column} #{order}"
when'france_connect_information'
@ -255,7 +264,11 @@ module NewGestionnaire
order = "#{table.pluralize}.#{column} #{order}"
end
dossiers.includes(includes).where(where).order(Dossier.sanitize_for_order(order)).pluck(:id)
if sorted_ids.nil?
sorted_ids = dossiers.includes(includes).where(where).order(Dossier.sanitize_for_order(order)).pluck(:id)
end
sorted_ids
end
def current_filters

View file

@ -74,6 +74,11 @@
%table.table.dossiers-table.hoverable
%thead
%tr
- if @statut == 'suivis' || @statut == 'tous'
= render partial: "header_field", locals: { field: { "label" => "●", "table" => "notifications", "column" => "notifications" }, classname: "notification-col" }
- else
%th.notification-col
= render partial: "header_field", locals: { field: { "label" => "Nº dossier", "table" => "self", "column" => "id" }, classname: "number-col" }
- @displayed_fields.each do |field|
@ -96,11 +101,13 @@
%tbody
- @dossiers.each do |dossier|
%tr
%td.folder-col
.icon.folder
- if current_gestionnaire.notifications_for_procedure(@procedure).include?(dossier.id)
%span.notifications{ 'aria-label': 'notifications' }
%td.number-col
= link_to(dossier_path(@procedure, dossier), class: 'cell-link') do
.icon.folder
- if current_gestionnaire.notifications_for_procedure(@procedure).include?(dossier.id)
%span.notifications{ 'aria-label': 'notifications' }
= dossier.id
- @displayed_fields.each do |field|

View file

@ -295,7 +295,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do
let(:statut) { 'tous' }
it { expect(assigns(:statut)).to eq('tous') }
it { expect(assigns(:dossiers)).to match([a_suivre__dossier, new_followed_dossier, termine_dossier].sort_by(&:updated_at)) }
it { expect(assigns(:dossiers)).to match_array([a_suivre__dossier, new_followed_dossier, termine_dossier]) }
end
context 'when statut is archives' do