Merge pull request #140 from sgmap/remove_facade_data_view
Remove @facade_data_view from left_panel view
This commit is contained in:
commit
8fdb61ae54
5 changed files with 56 additions and 26 deletions
|
@ -98,6 +98,10 @@ class Gestionnaire < ActiveRecord::Base
|
||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def dossiers_with_notifications_count
|
||||||
|
notifications.pluck(:dossier_id).uniq.count
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def valid_couple_table_attr? table, column
|
def valid_couple_table_attr? table, column
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
class Notification < ActiveRecord::Base
|
class Notification < ActiveRecord::Base
|
||||||
belongs_to :dossier
|
belongs_to :dossier
|
||||||
|
|
||||||
# after_save :broadcast_notification
|
|
||||||
|
|
||||||
enum type_notif: {
|
enum type_notif: {
|
||||||
commentaire: 'commentaire',
|
commentaire: 'commentaire',
|
||||||
cerfa: 'cerfa',
|
cerfa: 'cerfa',
|
||||||
|
@ -10,10 +7,5 @@ class Notification < ActiveRecord::Base
|
||||||
champs: 'champs',
|
champs: 'champs',
|
||||||
submitted: 'submitted'
|
submitted: 'submitted'
|
||||||
}
|
}
|
||||||
|
scope :unread, -> { where(already_read: false) }
|
||||||
# def broadcast_notification
|
|
||||||
# ActionCable.server.broadcast 'notifications',
|
|
||||||
# message: "Dossier nº #{self.dossier.id} : #{self.liste.last}",
|
|
||||||
# dossier: {id: self.dossier.id}
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,7 @@ class Procedure < ActiveRecord::Base
|
||||||
has_many :types_de_champ, class_name: 'TypeDeChampPublic', dependent: :destroy
|
has_many :types_de_champ, class_name: 'TypeDeChampPublic', dependent: :destroy
|
||||||
has_many :types_de_champ_private, dependent: :destroy
|
has_many :types_de_champ_private, dependent: :destroy
|
||||||
has_many :dossiers
|
has_many :dossiers
|
||||||
|
has_many :notifications, through: :dossiers
|
||||||
|
|
||||||
has_one :procedure_path, dependent: :destroy
|
has_one :procedure_path, dependent: :destroy
|
||||||
|
|
||||||
|
@ -47,6 +48,8 @@ class Procedure < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
scope :not_archived, -> { where(archived: false) }
|
scope :not_archived, -> { where(archived: false) }
|
||||||
|
scope :by_libelle, -> { order(libelle: :asc) }
|
||||||
|
|
||||||
|
|
||||||
def path
|
def path
|
||||||
procedure_path.path unless procedure_path.nil?
|
procedure_path.path unless procedure_path.nil?
|
||||||
|
|
|
@ -1,42 +1,42 @@
|
||||||
%div#first-block
|
#first-block
|
||||||
.dossiers-en-cours
|
.dossiers-en-cours
|
||||||
.count= @facade_data_view.total_dossier_follow
|
.count= current_gestionnaire.dossiers_follow.count
|
||||||
.text SUIVIS
|
.text SUIVIS
|
||||||
.nouveaux-dossiers
|
.nouveaux-dossiers
|
||||||
.count= @facade_data_view.total_new_dossier
|
.count= current_gestionnaire.dossiers.nouveaux.count
|
||||||
.text NOUVEAUX
|
.text NOUVEAUX
|
||||||
.nouvelles-notifications
|
.nouvelles-notifications
|
||||||
.count= @facade_data_view.dossiers_with_unread_notifications.count
|
.count= current_gestionnaire.dossiers_with_notifications_count
|
||||||
.text MODIFIÉS
|
.text MODIFIÉS
|
||||||
|
|
||||||
%div#action-block
|
#action-block
|
||||||
|
|
||||||
%div#menu-block
|
#menu-block
|
||||||
.split-hr-left
|
.split-hr-left
|
||||||
#switch-buttons
|
#switch-buttons
|
||||||
#switch-procedures.active Procédures
|
#switch-procedures.active Procédures
|
||||||
#switch-notifications Notifications
|
#switch-notifications Notifications
|
||||||
|
|
||||||
%div#infos-block
|
#infos-block
|
||||||
.split-hr-left
|
.split-hr-left
|
||||||
#procedure-list
|
#procedure-list
|
||||||
- @facade_data_view.gestionnaire_procedures_name_and_id_list.each do |procedure|
|
- current_gestionnaire.procedures.by_libelle.each do |procedure|
|
||||||
|
= link_to backoffice_dossiers_procedure_path(procedure.id), { title: procedure.libelle } do
|
||||||
= link_to backoffice_dossiers_procedure_path(procedure[:id]), { title: procedure[:libelle] } do
|
.procedure-list-element{ class: ('active' if procedure.id.to_s == params[:id]) }
|
||||||
.procedure-list-element{ class: ('active' if procedure[:id] == @facade_data_view.procedure.id rescue '') }
|
= procedure.libelle.truncate(50)
|
||||||
= truncate(procedure[:libelle], length: 50)
|
- total_new = procedure.dossiers.nouveaux.count
|
||||||
- total_new = @facade_data_view.new_dossier_number procedure[:id]
|
|
||||||
- if total_new > 0
|
- if total_new > 0
|
||||||
.badge.progress-bar-success{ title: 'Nouveaux dossiers' }
|
.badge.progress-bar-success{ title: 'Nouveaux dossiers' }
|
||||||
= total_new
|
= total_new
|
||||||
- if procedure[:unread_notifications] > 0
|
- unread_notif_count = procedure.notifications.unread.count
|
||||||
|
- if unread_notif_count > 0
|
||||||
.badge.progress-bar-warning{ title: 'Notifications' }
|
.badge.progress-bar-warning{ title: 'Notifications' }
|
||||||
= procedure[:unread_notifications]
|
= unread_notif_count
|
||||||
#notifications-list.hidden
|
#notifications-list.hidden
|
||||||
- if @facade_data_view.dossiers_with_unread_notifications.empty?
|
- if current_gestionnaire.notifications.empty?
|
||||||
.no-notification Aucune notification pour le moment.
|
.no-notification Aucune notification pour le moment.
|
||||||
- else
|
- else
|
||||||
- @facade_data_view.dossiers_with_unread_notifications.each do |dossier|
|
- current_gestionnaire.notifications.includes(:dossier).map(&:dossier).uniq.each do |dossier|
|
||||||
= link_to backoffice_dossier_path(dossier.id) do
|
= link_to backoffice_dossier_path(dossier.id) do
|
||||||
.notification
|
.notification
|
||||||
.dossier-index= "Dossier nº #{dossier.id}"
|
.dossier-index= "Dossier nº #{dossier.id}"
|
||||||
|
|
|
@ -272,6 +272,37 @@ describe Gestionnaire, type: :model do
|
||||||
it { is_expected.to be_nil }
|
it { is_expected.to be_nil }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#dossiers_with_notifications_count' do
|
||||||
|
subject { gestionnaire.dossiers_with_notifications_count }
|
||||||
|
|
||||||
|
context 'when there is no notifications' do
|
||||||
|
it { is_expected.to eq(0) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when there is one notification for one dossier' do
|
||||||
|
let(:notification){ create(:notification, already_read: false) }
|
||||||
|
let!(:follow){ create(:follow, dossier: notification.dossier, gestionnaire: gestionnaire) }
|
||||||
|
|
||||||
|
it { is_expected.to eq(1) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when there are many notifications for one dossier' do
|
||||||
|
let(:notification){ create(:notification, already_read: false) }
|
||||||
|
let(:notification2){ create(:notification, already_read: false, dossier: notification.dossier) }
|
||||||
|
let!(:follow){ create(:follow, dossier: notification.dossier, gestionnaire: gestionnaire) }
|
||||||
|
|
||||||
|
it { is_expected.to eq(1) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when there are many notifications for many dossiers' do
|
||||||
|
let(:notification){ create(:notification, already_read: false) }
|
||||||
|
let(:notification2){ create(:notification, already_read: false) }
|
||||||
|
let!(:follow){ create(:follow, dossier: notification.dossier, gestionnaire: gestionnaire) }
|
||||||
|
let!(:follow2){ create(:follow, dossier: notification2.dossier, gestionnaire: gestionnaire) }
|
||||||
|
|
||||||
|
it { is_expected.to eq(2) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue