Merge pull request #1453 from tchak/show-notifications-on-dossiers-termine
Show notifications on dossiers terminé
This commit is contained in:
commit
3bdf9b1985
3 changed files with 23 additions and 7 deletions
|
@ -101,14 +101,28 @@ class Gestionnaire < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def notifications_for_procedure(procedure)
|
||||
dossiers = procedure.dossiers.en_cours.followed_by(self)
|
||||
def notifications_for_procedure(procedure, state = :en_cours)
|
||||
dossiers = case state
|
||||
when :termine
|
||||
procedure.dossiers.termine
|
||||
when :not_archived
|
||||
procedure.dossiers.not_archived
|
||||
else
|
||||
procedure.dossiers.en_cours
|
||||
end.followed_by(self)
|
||||
|
||||
dossiers_id_with_notifications(dossiers)
|
||||
end
|
||||
|
||||
def notifications_per_procedure
|
||||
dossiers = Dossier.en_cours.followed_by(self)
|
||||
def notifications_per_procedure(state = :en_cours)
|
||||
dossiers = case state
|
||||
when :termine
|
||||
Dossier.termine
|
||||
when :not_archived
|
||||
Dossier.not_archived
|
||||
else
|
||||
Dossier.en_cours
|
||||
end.followed_by(self)
|
||||
|
||||
Dossier.where(id: dossiers_id_with_notifications(dossiers)).group(:procedure_id).count
|
||||
end
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
%li
|
||||
%object
|
||||
= link_to(procedure_path(p, statut: 'traites')) do
|
||||
- if current_gestionnaire.notifications_per_procedure(:termine)[p.id].present?
|
||||
%span.notifications{ 'aria-label': "notifications" }
|
||||
- termines_count = @dossiers_termines_count_per_procedure[p.id] || 0
|
||||
.stats-number
|
||||
= termines_count
|
||||
|
|
|
@ -23,13 +23,13 @@
|
|||
%span.badge= @followed_dossiers.count
|
||||
|
||||
%li{ class: (@statut == 'traites') ? 'active' : nil }>
|
||||
- if current_gestionnaire.notifications_for_procedure(@procedure, :termine).present?
|
||||
%span.notifications{ 'aria-label': 'notifications' }
|
||||
= link_to(procedure_path(@procedure, statut: 'traites')) do
|
||||
= t('pluralize.processed', count: @termines_dossiers.count)
|
||||
%span.badge= @termines_dossiers.count
|
||||
|
||||
%li{ class: (@statut == 'tous') ? 'active' : nil }>
|
||||
- if current_gestionnaire.notifications_for_procedure(@procedure).present?
|
||||
%span.notifications{ 'aria-label': 'notifications' }
|
||||
= link_to(procedure_path(@procedure, statut: 'tous')) do
|
||||
tous les dossiers
|
||||
%span.badge= @all_state_dossiers.count
|
||||
|
@ -96,7 +96,7 @@
|
|||
%td.folder-col
|
||||
= link_to(dossier_path(@procedure, dossier), class: 'cell-link') do
|
||||
%span.icon.folder
|
||||
- if current_gestionnaire.notifications_for_procedure(@procedure).include?(dossier.id)
|
||||
- if current_gestionnaire.notifications_for_procedure(@procedure, :not_archived).include?(dossier.id)
|
||||
%span.notifications{ 'aria-label': 'notifications' }
|
||||
|
||||
%td.number-col
|
||||
|
|
Loading…
Reference in a new issue