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
|
def commentaires_files
|
||||||
PieceJustificative.where(dossier_id: @dossier.id, type_de_piece_justificative_id: nil)
|
PieceJustificative.where(dossier_id: @dossier.id, type_de_piece_justificative_id: nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def followers
|
||||||
|
Gestionnaire.joins(:follows).where("follows.dossier_id=#{@dossier.id}")
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -198,4 +198,8 @@ class Dossier < ActiveRecord::Base
|
||||||
|
|
||||||
update_attributes(autorisation_donnees: false)
|
update_attributes(autorisation_donnees: false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def total_follow
|
||||||
|
follows.size
|
||||||
|
end
|
||||||
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 'État', 'state'
|
||||||
%th= smart_listing.sortable 'Date de mise à jour', 'updated_at'
|
%th= smart_listing.sortable 'Date de mise à jour', 'updated_at'
|
||||||
- unless @liste == 'termine'
|
- unless @liste == 'termine'
|
||||||
%th Actions
|
%th.center Actions
|
||||||
|
%th.center Abonnés
|
||||||
|
|
||||||
- @dossiers.each do |dossier|
|
- @dossiers.each do |dossier|
|
||||||
- dossier = dossier.decorate
|
- dossier = dossier.decorate
|
||||||
|
@ -17,11 +18,13 @@
|
||||||
%td= dossier.display_state
|
%td= dossier.display_state
|
||||||
%td= dossier.last_update
|
%td= dossier.last_update
|
||||||
- unless @liste == 'termine'
|
- unless @liste == 'termine'
|
||||||
%td
|
%td.center
|
||||||
- if current_gestionnaire.follow?(dossier.id)
|
- 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}")
|
= 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
|
-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}")
|
= 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.paginate
|
||||||
= smart_listing.pagination_per_page_links
|
= smart_listing.pagination_per_page_links
|
||||||
|
|
|
@ -6,10 +6,7 @@
|
||||||
%h3{:class => 'text-success'}
|
%h3{:class => 'text-success'}
|
||||||
= @facade.dossier.display_state
|
= @facade.dossier.display_state
|
||||||
|
|
||||||
- if current_gestionnaire.follow?(@facade.dossier.id)
|
= render partial: 'follow_action'
|
||||||
= 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: '/dossiers/infos_entreprise'
|
= render partial: '/dossiers/infos_entreprise'
|
||||||
|
|
||||||
|
@ -27,6 +24,9 @@
|
||||||
%li{role: "presentation"}
|
%li{role: "presentation"}
|
||||||
%a{href: "#invites", 'aria-controls' => "invites", role: "tab", 'data-toggle' => "tab"}
|
%a{href: "#invites", 'aria-controls' => "invites", role: "tab", 'data-toggle' => "tab"}
|
||||||
Invités
|
Invités
|
||||||
|
%li{role: "presentation"}
|
||||||
|
%a{href: "#followers", 'aria-controls' => "followers", role: "tab", 'data-toggle' => "tab"}
|
||||||
|
Abonnés
|
||||||
|
|
||||||
%div{class: "tab-content"}
|
%div{class: "tab-content"}
|
||||||
%div{role: "tabpanel", class: "tab-pane fade in active", id:"commentaires"}
|
%div{role: "tabpanel", class: "tab-pane fade in active", id:"commentaires"}
|
||||||
|
@ -37,6 +37,8 @@
|
||||||
= render partial: '/dossiers/commentaires_files'
|
= render partial: '/dossiers/commentaires_files'
|
||||||
%div{role: "tabpanel", class: "tab-pane fade", id:"invites"}
|
%div{role: "tabpanel", class: "tab-pane fade", id:"invites"}
|
||||||
= render partial: '/dossiers/invites'
|
= render partial: '/dossiers/invites'
|
||||||
|
%div{role: "tabpanel", class: "tab-pane fade", id:"followers"}
|
||||||
|
= render partial: 'followers'
|
||||||
|
|
||||||
%br
|
%br
|
||||||
%br
|
%br
|
|
@ -2,6 +2,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Dossier do
|
describe Dossier do
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
|
|
||||||
describe 'database columns' do
|
describe 'database columns' do
|
||||||
it { is_expected.to have_db_column(:autorisation_donnees) }
|
it { is_expected.to have_db_column(:autorisation_donnees) }
|
||||||
it { is_expected.to have_db_column(:nom_projet) }
|
it { is_expected.to have_db_column(:nom_projet) }
|
||||||
|
@ -75,7 +76,7 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
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 }
|
let(:types_de_pj_dossier) { dossier.procedure.types_de_piece_justificative }
|
||||||
|
|
||||||
subject { dossier.retrieve_last_piece_justificative_by_type types_de_pj_dossier.first }
|
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
|
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_admin
|
||||||
end
|
end
|
||||||
|
|
||||||
let!(:dossier1) { create(:dossier, procedure: procedure_admin, state: 'draft') }
|
let!(:dossier1) { create(:dossier, procedure: procedure_admin, state: 'draft') }
|
||||||
let!(:dossier2) { create(:dossier, procedure: procedure_admin, state: 'initiated') } #a_traiter
|
let!(:dossier2) { create(:dossier, procedure: procedure_admin, state: 'initiated') } #a_traiter
|
||||||
let!(:dossier3) { 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!(:dossier4) { create(:dossier, procedure: procedure_admin, state: 'replied') } #en_attente
|
||||||
let!(:dossier5) { create(:dossier, procedure: procedure_admin, state: 'updated') } #a_traiter
|
let!(:dossier5) { create(:dossier, procedure: procedure_admin, state: 'updated') } #a_traiter
|
||||||
let!(:dossier6) { create(:dossier, procedure: procedure_admin_2, state: 'validated') } #en_attente
|
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!(:dossier7) { create(:dossier, procedure: procedure_admin_2, state: 'submitted') } #a_traiter
|
||||||
let!(:dossier8) { create(:dossier, procedure: procedure_admin_2, state: 'closed') } #termine
|
let!(:dossier8) { create(:dossier, procedure: procedure_admin_2, state: 'closed') } #termine
|
||||||
let!(:dossier9) { create(:dossier, procedure: procedure_admin, 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!(: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!(: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!(:dossier12) { create(:dossier, procedure: procedure_admin, state: 'closed', archived: true) } #termine #archived
|
||||||
|
|
||||||
describe '#waiting_for_gestionnaire' do
|
describe '#waiting_for_gestionnaire' do
|
||||||
subject { gestionnaire.dossiers.waiting_for_gestionnaire }
|
subject { gestionnaire.dossiers.waiting_for_gestionnaire }
|
||||||
|
@ -498,8 +499,8 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#cerfa_available?' do
|
describe '#cerfa_available?' do
|
||||||
let(:procedure) { create(:procedure, cerfa_flag: cerfa_flag) }
|
let(:procedure) { create(:procedure, cerfa_flag: cerfa_flag) }
|
||||||
let(:dossier) { create(:dossier, procedure: procedure)}
|
let(:dossier) { create(:dossier, procedure: procedure) }
|
||||||
|
|
||||||
context 'Procedure accepts CERFA' do
|
context 'Procedure accepts CERFA' do
|
||||||
let(:cerfa_flag) { true }
|
let(:cerfa_flag) { true }
|
||||||
|
@ -518,7 +519,7 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#as_csv?' do
|
describe '#as_csv?' do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
|
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
|
||||||
subject { dossier.as_csv }
|
subject { dossier.as_csv }
|
||||||
|
|
||||||
|
@ -563,11 +564,11 @@ describe Dossier do
|
||||||
it { expect(dossier.entreprise.rna_information).not_to be_nil }
|
it { expect(dossier.entreprise.rna_information).not_to be_nil }
|
||||||
it { expect(dossier.autorisation_donnees).to be_truthy }
|
it { expect(dossier.autorisation_donnees).to be_truthy }
|
||||||
|
|
||||||
it { expect{subject}.to change(RNAInformation, :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(Exercice, :count).by(-1) }
|
||||||
|
|
||||||
it { expect{subject}.to change(Entreprise, :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(Etablissement, :count).by(-1) }
|
||||||
|
|
||||||
context 'when method reset! is call' do
|
context 'when method reset! is call' do
|
||||||
before do
|
before do
|
||||||
|
@ -586,7 +587,7 @@ describe Dossier do
|
||||||
let!(:procedure_2) { create :procedure }
|
let!(:procedure_2) { create :procedure }
|
||||||
|
|
||||||
let(:dossier_1) { Dossier.new(id: 0, procedure: procedure_1) }
|
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
|
before do
|
||||||
create :type_de_champ, libelle: 'type_1_1', order_place: 1, procedure: dossier_1.procedure
|
create :type_de_champ, libelle: 'type_1_1', order_place: 1, procedure: dossier_1.procedure
|
||||||
|
@ -623,4 +624,27 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue