Refactor Instructeur.notifications_* methods
- rename `dossiers_id_with_notifications` to `followed_dossiers_with_notifications`, - rename `notifications_per_procedure` to `procedures_with_notifications`, - return an ActiveRecord::Relation instead of the result of the query, so that the call place can compose it, - `merge` with the wanted Dossier scope in the call places, don’t bother passing it as a parameter, - use the “state” (now “scope”) parameter as a scope method that can be just applied on `Dossier`.
This commit is contained in:
parent
d7625e88ce
commit
a4166d3c57
6 changed files with 30 additions and 42 deletions
|
@ -27,7 +27,7 @@
|
|||
%li
|
||||
%object
|
||||
= link_to(instructeur_procedure_path(p, statut: 'suivis')) do
|
||||
- if current_instructeur.notifications_per_procedure(:en_cours)[p.id].present?
|
||||
- if current_instructeur.procedures_with_notifications(:en_cours).include?(p)
|
||||
%span.notifications{ 'aria-label': "notifications" }
|
||||
- followed_count = @followed_dossiers_count_per_procedure[p.id] || 0
|
||||
.stats-number
|
||||
|
@ -37,7 +37,7 @@
|
|||
%li
|
||||
%object
|
||||
= link_to(instructeur_procedure_path(p, statut: 'traites')) do
|
||||
- if current_instructeur.notifications_per_procedure(:termine)[p.id].present?
|
||||
- if current_instructeur.procedures_with_notifications(:termine).include?(p)
|
||||
%span.notifications{ 'aria-label': "notifications" }
|
||||
- termines_count = @dossiers_termines_count_per_procedure[p.id] || 0
|
||||
.stats-number
|
||||
|
|
|
@ -116,7 +116,7 @@
|
|||
%td.folder-col
|
||||
= link_to(instructeur_dossier_path(@procedure, dossier), class: 'cell-link') do
|
||||
%span.icon.folder
|
||||
- if current_instructeur.notifications_for_procedure(@procedure, :not_archived).include?(dossier.id)
|
||||
- if current_instructeur.notifications_for_procedure(@procedure, :not_archived).include?(dossier)
|
||||
%span.notifications{ 'aria-label': 'notifications' }
|
||||
|
||||
%td.number-col
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue