Ajust count notification for procedure left panel in back office gestionnaire

This commit is contained in:
Xavier J 2017-01-02 18:27:01 +01:00
parent 70fcaf281f
commit c122a64237
4 changed files with 17 additions and 9 deletions

View file

@ -31,7 +31,7 @@ class DossiersListFacades
end
def gestionnaire_procedures_name_and_id_list
@current_devise_profil.procedures.order('libelle ASC').inject([]) { |acc, procedure| acc.push({id: procedure.id, libelle: procedure.libelle, unread_notifications: @current_devise_profil.notifications_for(procedure)}) }
@current_devise_profil.procedures.order('libelle ASC').inject([]) { |acc, procedure| acc.push({id: procedure.id, libelle: procedure.libelle, unread_notifications: @current_devise_profil.dossier_with_notification_for(procedure)}) }
end
def unread_notifications

View file

@ -79,6 +79,18 @@ class Gestionnaire < ActiveRecord::Base
0
end
def dossier_with_notification_for procedure
procedure_ids = dossiers_follow.pluck(:procedure_id)
if procedure_ids.include?(procedure.id)
return dossiers_follow.where(procedure_id: procedure.id)
.inject(0) do |acc, dossier|
acc += ((dossier.notifications.where(already_read: false).count) > 0 ? 1 : 0)
end
end
0
end
private
def valid_couple_table_attr? table, column

View file

@ -6,13 +6,8 @@
.count= @facade_data_view.total_new_dossier
.text= "NOUVEAUX"
%div.nouvelles-notifications
- new_notifications = @facade_data_view.dossiers_with_unread_notifications.count
- if new_notifications > 1
.count= new_notifications
.text= "MODIFIÉS"
- elsif new_notifications == 1
.count 1
.text= "MODIFIÉ"
.count= @facade_data_view.dossiers_with_unread_notifications.count
.text= "MODIFIÉS"
%div#action-block

View file

@ -14,5 +14,6 @@
= h @dossier.procedure.description.html_safe
- else
= image_tag(image_url(LOGO_NAME), {id: 'logo_tps'})
#logo_procedure.flag
= image_tag(image_url(LOGO_NAME), {id: 'logo_tps'})
%br