Procedure Index: add notification icon
This commit is contained in:
parent
ff3120bf6c
commit
3e93d21bf5
6 changed files with 53 additions and 0 deletions
9
app/assets/stylesheets/new_design/notifications.scss
Normal file
9
app/assets/stylesheets/new_design/notifications.scss
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
@import "colors";
|
||||||
|
|
||||||
|
span.notifications {
|
||||||
|
position: absolute;
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: $orange;
|
||||||
|
}
|
|
@ -40,6 +40,7 @@
|
||||||
min-height: 36px;
|
min-height: 36px;
|
||||||
border-left: 1px solid $border-grey;
|
border-left: 1px solid $border-grey;
|
||||||
width: 90px;
|
width: 90px;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
border-right: 1px solid $border-grey;
|
border-right: 1px solid $border-grey;
|
||||||
|
@ -60,5 +61,10 @@
|
||||||
color: $grey;
|
color: $grey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notifications {
|
||||||
|
top: 3px;
|
||||||
|
right: 18px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ module NewGestionnaire
|
||||||
.group(:procedure_id)
|
.group(:procedure_id)
|
||||||
.reorder(nil)
|
.reorder(nil)
|
||||||
.count
|
.count
|
||||||
|
|
||||||
|
@notifications_count_per_procedure = current_gestionnaire.notifications_count_per_procedure
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
|
@ -93,6 +93,14 @@ class Gestionnaire < ActiveRecord::Base
|
||||||
Notification.unread.where(dossier_id: followed_dossiers_id).select(:dossier_id).distinct(:dossier_id).count
|
Notification.unread.where(dossier_id: followed_dossiers_id).select(:dossier_id).distinct(:dossier_id).count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def notifications_count_per_procedure
|
||||||
|
followed_dossiers
|
||||||
|
.joins(:notifications)
|
||||||
|
.where(notifications: { already_read: false })
|
||||||
|
.group('procedure_id')
|
||||||
|
.count
|
||||||
|
end
|
||||||
|
|
||||||
def dossiers_with_notifications_count
|
def dossiers_with_notifications_count
|
||||||
notifications.pluck(:dossier_id).uniq.count
|
notifications.pluck(:dossier_id).uniq.count
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
.stats-legend
|
.stats-legend
|
||||||
à suivre
|
à suivre
|
||||||
%li
|
%li
|
||||||
|
- if @notifications_count_per_procedure[p.id].present?
|
||||||
|
%span.notifications{ 'aria-label': "notifications" }
|
||||||
- followed_count = @followed_dossiers_count_per_procedure[p.id] || 0
|
- followed_count = @followed_dossiers_count_per_procedure[p.id] || 0
|
||||||
.stats-number
|
.stats-number
|
||||||
= followed_count
|
= followed_count
|
||||||
|
|
|
@ -356,4 +356,30 @@ describe Gestionnaire, type: :model do
|
||||||
it { expect(subject).to be false }
|
it { expect(subject).to be false }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#notifications_count_per_procedure' do
|
||||||
|
subject { gestionnaire.notifications_count_per_procedure }
|
||||||
|
|
||||||
|
let(:dossier_with_unread_notification) do
|
||||||
|
create(:dossier, notifications: [Notification.create(type_notif: 'champs', already_read: false)])
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:dossier_with_no_unread_notification) do
|
||||||
|
create(:dossier, notifications: [Notification.create(type_notif: 'champs', already_read: true)])
|
||||||
|
end
|
||||||
|
|
||||||
|
before { gestionnaire.followed_dossiers << followed_dossier }
|
||||||
|
|
||||||
|
context 'when a followed dossier has unread notification' do
|
||||||
|
let(:followed_dossier) { dossier_with_unread_notification }
|
||||||
|
|
||||||
|
it { is_expected.to eq({ dossier_with_unread_notification.procedure.id => 1 }) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when a followed dossier has unread notification' do
|
||||||
|
let(:followed_dossier) { dossier_with_no_unread_notification }
|
||||||
|
|
||||||
|
it { is_expected.to eq({ }) }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue