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
|
||||||
end
|
end
|
||||||
|
|
||||||
def notifications_for_procedure(procedure)
|
def notifications_for_procedure(procedure, state = :en_cours)
|
||||||
dossiers = procedure.dossiers.en_cours.followed_by(self)
|
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)
|
dossiers_id_with_notifications(dossiers)
|
||||||
end
|
end
|
||||||
|
|
||||||
def notifications_per_procedure
|
def notifications_per_procedure(state = :en_cours)
|
||||||
dossiers = Dossier.en_cours.followed_by(self)
|
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
|
Dossier.where(id: dossiers_id_with_notifications(dossiers)).group(:procedure_id).count
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
%li
|
%li
|
||||||
%object
|
%object
|
||||||
= link_to(procedure_path(p, statut: 'traites')) do
|
= 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
|
- termines_count = @dossiers_termines_count_per_procedure[p.id] || 0
|
||||||
.stats-number
|
.stats-number
|
||||||
= termines_count
|
= termines_count
|
||||||
|
|
|
@ -23,13 +23,13 @@
|
||||||
%span.badge= @followed_dossiers.count
|
%span.badge= @followed_dossiers.count
|
||||||
|
|
||||||
%li{ class: (@statut == 'traites') ? 'active' : nil }>
|
%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
|
= link_to(procedure_path(@procedure, statut: 'traites')) do
|
||||||
= t('pluralize.processed', count: @termines_dossiers.count)
|
= t('pluralize.processed', count: @termines_dossiers.count)
|
||||||
%span.badge= @termines_dossiers.count
|
%span.badge= @termines_dossiers.count
|
||||||
|
|
||||||
%li{ class: (@statut == 'tous') ? 'active' : nil }>
|
%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
|
= link_to(procedure_path(@procedure, statut: 'tous')) do
|
||||||
tous les dossiers
|
tous les dossiers
|
||||||
%span.badge= @all_state_dossiers.count
|
%span.badge= @all_state_dossiers.count
|
||||||
|
@ -96,7 +96,7 @@
|
||||||
%td.folder-col
|
%td.folder-col
|
||||||
= link_to(dossier_path(@procedure, dossier), class: 'cell-link') do
|
= link_to(dossier_path(@procedure, dossier), class: 'cell-link') do
|
||||||
%span.icon.folder
|
%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' }
|
%span.notifications{ 'aria-label': 'notifications' }
|
||||||
|
|
||||||
%td.number-col
|
%td.number-col
|
||||||
|
|
Loading…
Reference in a new issue