Add total followers on dossier list and followers list on dossier page for gestionnaire
This commit is contained in:
parent
7d0bcfc35f
commit
127c9bb138
7 changed files with 82 additions and 27 deletions
|
@ -49,4 +49,8 @@ class DossierFacades
|
|||
def commentaires_files
|
||||
PieceJustificative.where(dossier_id: @dossier.id, type_de_piece_justificative_id: nil)
|
||||
end
|
||||
|
||||
def followers
|
||||
Gestionnaire.joins(:follows).where("follows.dossier_id=#{@dossier.id}")
|
||||
end
|
||||
end
|
|
@ -198,4 +198,8 @@ class Dossier < ActiveRecord::Base
|
|||
|
||||
update_attributes(autorisation_donnees: false)
|
||||
end
|
||||
|
||||
def total_follow
|
||||
follows.size
|
||||
end
|
||||
end
|
||||
|
|
4
app/views/backoffice/dossiers/_follow_action.html.haml
Normal file
4
app/views/backoffice/dossiers/_follow_action.html.haml
Normal file
|
@ -0,0 +1,4 @@
|
|||
- if current_gestionnaire.follow?(@facade.dossier.id)
|
||||
= link_to('Quitter'.html_safe, backoffice_dossier_follow_path(dossier_id: @facade.dossier.id), 'data-method' => :put, class: 'btn btn-md btn-danger', id: "suivre_dossier_#{@facade.dossier.id}")
|
||||
-else
|
||||
= link_to('Suivre', backoffice_dossier_follow_path(dossier_id: @facade.dossier.id), 'data-method' => :put, class: 'btn btn-md btn-primary', id: "suivre_dossier_#{@facade.dossier.id}")
|
14
app/views/backoffice/dossiers/_followers.html.haml
Normal file
14
app/views/backoffice/dossiers/_followers.html.haml
Normal file
|
@ -0,0 +1,14 @@
|
|||
%h3 Personnes suivant l'activité de ce dossier
|
||||
|
||||
%br
|
||||
.row
|
||||
.col-md-4.col-lg-4
|
||||
- if @facade.followers.size > 0
|
||||
%ul
|
||||
- @facade.followers.each do |follower|
|
||||
%li
|
||||
= follower.email
|
||||
- else
|
||||
Aucune personne ne suit ce dossier
|
||||
|
||||
|
|
@ -6,7 +6,8 @@
|
|||
%th= smart_listing.sortable 'État', 'state'
|
||||
%th= smart_listing.sortable 'Date de mise à jour', 'updated_at'
|
||||
- unless @liste == 'termine'
|
||||
%th Actions
|
||||
%th.center Actions
|
||||
%th.center Abonnés
|
||||
|
||||
- @dossiers.each do |dossier|
|
||||
- dossier = dossier.decorate
|
||||
|
@ -17,11 +18,13 @@
|
|||
%td= dossier.display_state
|
||||
%td= dossier.last_update
|
||||
- unless @liste == 'termine'
|
||||
%td
|
||||
%td.center
|
||||
- if current_gestionnaire.follow?(dossier.id)
|
||||
= link_to('Quitter'.html_safe, backoffice_dossier_follow_path(dossier_id: dossier.id), 'data-method' => :put, class: 'btn-sm btn-danger', id: "suivre_dossier_#{dossier.id}")
|
||||
-else
|
||||
= link_to('Suivre', backoffice_dossier_follow_path(dossier_id: dossier.id), 'data-method' => :put, class: 'btn-sm btn-primary', id: "suivre_dossier_#{dossier.id}")
|
||||
%td.center{style:"color: #{dossier.total_follow == 0 ? 'red' : ''}"}
|
||||
= dossier.total_follow
|
||||
|
||||
= smart_listing.paginate
|
||||
= smart_listing.pagination_per_page_links
|
||||
|
|
|
@ -6,10 +6,7 @@
|
|||
%h3{:class => 'text-success'}
|
||||
= @facade.dossier.display_state
|
||||
|
||||
- if current_gestionnaire.follow?(@facade.dossier.id)
|
||||
= link_to('Quitter'.html_safe, backoffice_dossier_follow_path(dossier_id: @facade.dossier.id), 'data-method' => :put, class: 'btn btn-md btn-danger', id: "suivre_dossier_#{@facade.dossier.id}")
|
||||
-else
|
||||
= link_to('Suivre', backoffice_dossier_follow_path(dossier_id: @facade.dossier.id), 'data-method' => :put, class: 'btn btn-md btn-primary', id: "suivre_dossier_#{@facade.dossier.id}")
|
||||
= render partial: 'follow_action'
|
||||
|
||||
= render partial: '/dossiers/infos_entreprise'
|
||||
|
||||
|
@ -27,6 +24,9 @@
|
|||
%li{role: "presentation"}
|
||||
%a{href: "#invites", 'aria-controls' => "invites", role: "tab", 'data-toggle' => "tab"}
|
||||
Invités
|
||||
%li{role: "presentation"}
|
||||
%a{href: "#followers", 'aria-controls' => "followers", role: "tab", 'data-toggle' => "tab"}
|
||||
Abonnés
|
||||
|
||||
%div{class: "tab-content"}
|
||||
%div{role: "tabpanel", class: "tab-pane fade in active", id:"commentaires"}
|
||||
|
@ -37,6 +37,8 @@
|
|||
= render partial: '/dossiers/commentaires_files'
|
||||
%div{role: "tabpanel", class: "tab-pane fade", id:"invites"}
|
||||
= render partial: '/dossiers/invites'
|
||||
%div{role: "tabpanel", class: "tab-pane fade", id:"followers"}
|
||||
= render partial: 'followers'
|
||||
|
||||
%br
|
||||
%br
|
|
@ -2,6 +2,7 @@ require 'spec_helper'
|
|||
|
||||
describe Dossier do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:autorisation_donnees) }
|
||||
it { is_expected.to have_db_column(:nom_projet) }
|
||||
|
@ -75,7 +76,7 @@ describe Dossier do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#retrieve_last_piece_justificative_by_type', vcr: { cassette_name: 'models_dossier_retrieve_last_piece_justificative_by_type' } do
|
||||
describe '#retrieve_last_piece_justificative_by_type', vcr: {cassette_name: 'models_dossier_retrieve_last_piece_justificative_by_type'} do
|
||||
let(:types_de_pj_dossier) { dossier.procedure.types_de_piece_justificative }
|
||||
|
||||
subject { dossier.retrieve_last_piece_justificative_by_type types_de_pj_dossier.first }
|
||||
|
@ -383,18 +384,18 @@ describe Dossier do
|
|||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_admin
|
||||
end
|
||||
|
||||
let!(:dossier1) { create(:dossier, procedure: procedure_admin, state: 'draft') }
|
||||
let!(:dossier2) { create(:dossier, procedure: procedure_admin, state: 'initiated') } #a_traiter
|
||||
let!(:dossier3) { create(:dossier, procedure: procedure_admin, state: 'initiated') } #a_traiter
|
||||
let!(:dossier4) { create(:dossier, procedure: procedure_admin, state: 'replied') } #en_attente
|
||||
let!(:dossier5) { create(:dossier, procedure: procedure_admin, state: 'updated') } #a_traiter
|
||||
let!(:dossier6) { create(:dossier, procedure: procedure_admin_2, state: 'validated') } #en_attente
|
||||
let!(:dossier7) { create(:dossier, procedure: procedure_admin_2, state: 'submitted') } #a_traiter
|
||||
let!(:dossier8) { create(:dossier, procedure: procedure_admin_2, state: 'closed') } #termine
|
||||
let!(:dossier9) { create(:dossier, procedure: procedure_admin, state: 'closed') } #termine
|
||||
let!(:dossier10) { create(:dossier, procedure: procedure_admin, state: 'initiated', archived: true) } #a_traiter #archived
|
||||
let!(:dossier11) { create(:dossier, procedure: procedure_admin, state: 'replied', archived: true) } #en_attente #archived
|
||||
let!(:dossier12) { create(:dossier, procedure: procedure_admin, state: 'closed', archived: true) } #termine #archived
|
||||
let!(:dossier1) { create(:dossier, procedure: procedure_admin, state: 'draft') }
|
||||
let!(:dossier2) { create(:dossier, procedure: procedure_admin, state: 'initiated') } #a_traiter
|
||||
let!(:dossier3) { create(:dossier, procedure: procedure_admin, state: 'initiated') } #a_traiter
|
||||
let!(:dossier4) { create(:dossier, procedure: procedure_admin, state: 'replied') } #en_attente
|
||||
let!(:dossier5) { create(:dossier, procedure: procedure_admin, state: 'updated') } #a_traiter
|
||||
let!(:dossier6) { create(:dossier, procedure: procedure_admin_2, state: 'validated') } #en_attente
|
||||
let!(:dossier7) { create(:dossier, procedure: procedure_admin_2, state: 'submitted') } #a_traiter
|
||||
let!(:dossier8) { create(:dossier, procedure: procedure_admin_2, state: 'closed') } #termine
|
||||
let!(:dossier9) { create(:dossier, procedure: procedure_admin, state: 'closed') } #termine
|
||||
let!(:dossier10) { create(:dossier, procedure: procedure_admin, state: 'initiated', archived: true) } #a_traiter #archived
|
||||
let!(:dossier11) { create(:dossier, procedure: procedure_admin, state: 'replied', archived: true) } #en_attente #archived
|
||||
let!(:dossier12) { create(:dossier, procedure: procedure_admin, state: 'closed', archived: true) } #termine #archived
|
||||
|
||||
describe '#waiting_for_gestionnaire' do
|
||||
subject { gestionnaire.dossiers.waiting_for_gestionnaire }
|
||||
|
@ -498,8 +499,8 @@ describe Dossier do
|
|||
end
|
||||
|
||||
describe '#cerfa_available?' do
|
||||
let(:procedure) { create(:procedure, cerfa_flag: cerfa_flag) }
|
||||
let(:dossier) { create(:dossier, procedure: procedure)}
|
||||
let(:procedure) { create(:procedure, cerfa_flag: cerfa_flag) }
|
||||
let(:dossier) { create(:dossier, procedure: procedure) }
|
||||
|
||||
context 'Procedure accepts CERFA' do
|
||||
let(:cerfa_flag) { true }
|
||||
|
@ -518,7 +519,7 @@ describe Dossier do
|
|||
end
|
||||
|
||||
describe '#as_csv?' do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
|
||||
subject { dossier.as_csv }
|
||||
|
||||
|
@ -563,11 +564,11 @@ describe Dossier do
|
|||
it { expect(dossier.entreprise.rna_information).not_to be_nil }
|
||||
it { expect(dossier.autorisation_donnees).to be_truthy }
|
||||
|
||||
it { expect{subject}.to change(RNAInformation, :count).by(-1) }
|
||||
it { expect{subject}.to change(Exercice, :count).by(-1) }
|
||||
it { expect { subject }.to change(RNAInformation, :count).by(-1) }
|
||||
it { expect { subject }.to change(Exercice, :count).by(-1) }
|
||||
|
||||
it { expect{subject}.to change(Entreprise, :count).by(-1) }
|
||||
it { expect{subject}.to change(Etablissement, :count).by(-1) }
|
||||
it { expect { subject }.to change(Entreprise, :count).by(-1) }
|
||||
it { expect { subject }.to change(Etablissement, :count).by(-1) }
|
||||
|
||||
context 'when method reset! is call' do
|
||||
before do
|
||||
|
@ -586,7 +587,7 @@ describe Dossier do
|
|||
let!(:procedure_2) { create :procedure }
|
||||
|
||||
let(:dossier_1) { Dossier.new(id: 0, procedure: procedure_1) }
|
||||
let(:dossier_2) { Dossier.new(id: 0, procedure: procedure_2) }
|
||||
let(:dossier_2) { Dossier.new(id: 0, procedure: procedure_2) }
|
||||
|
||||
before do
|
||||
create :type_de_champ, libelle: 'type_1_1', order_place: 1, procedure: dossier_1.procedure
|
||||
|
@ -623,4 +624,27 @@ describe Dossier do
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
describe '#total_follow' do
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user) }
|
||||
let(:dossier2) { create(:dossier, :with_entreprise, user: user) }
|
||||
|
||||
subject { dossier.total_follow }
|
||||
|
||||
context 'when no body follow dossier' do
|
||||
it { expect(subject).to eq 0 }
|
||||
end
|
||||
|
||||
context 'when 2 people follow dossier' do
|
||||
before do
|
||||
create :follow, dossier_id: dossier.id, gestionnaire_id: (create :gestionnaire).id
|
||||
create :follow, dossier_id: dossier.id, gestionnaire_id: (create :gestionnaire).id
|
||||
|
||||
create :follow, dossier_id: dossier2.id, gestionnaire_id: (create :gestionnaire).id
|
||||
create :follow, dossier_id: dossier2.id, gestionnaire_id: (create :gestionnaire).id
|
||||
end
|
||||
|
||||
it { expect(subject).to eq 2 }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue