Add suivi tab for gestionnaire

This commit is contained in:
Xavier J 2016-07-19 17:18:41 +02:00
parent 127c9bb138
commit 6796ec26e8
4 changed files with 56 additions and 13 deletions

View file

@ -66,7 +66,8 @@ class Backoffice::DossiersController < ApplicationController
def dossiers_to_display
{'a_traiter' => waiting_for_gestionnaire,
'en_attente' => waiting_for_user,
'termine' => termine}[@liste]
'termine' => termine,
'suivi' => suivi}[@liste]
end
def waiting_for_gestionnaire
@ -84,10 +85,16 @@ class Backoffice::DossiersController < ApplicationController
@termine ||= current_gestionnaire.dossiers_filter.termine
end
def suivi
@suivi_class = (@liste == 'suivi' ? 'active' : '')
@suivi ||= current_gestionnaire.dossiers_follow
end
def total_dossiers_per_state
@dossiers_a_traiter_total = waiting_for_gestionnaire.count
@dossiers_en_attente_total = waiting_for_user.count
@dossiers_termine_total = termine.count
@dossiers_suivi_total = suivi.count
end
def create_dossier_facade dossier_id

View file

@ -5,9 +5,8 @@
%th= smart_listing.sortable 'Raison sociale', 'entreprise.raison_sociale'
%th= smart_listing.sortable 'État', 'state'
%th= smart_listing.sortable 'Date de mise à jour', 'updated_at'
- unless @liste == 'termine'
%th.center Actions
%th.center Abonnés
%th.center Actions
%th.center Abonnés
- @dossiers.each do |dossier|
- dossier = dossier.decorate
@ -17,14 +16,13 @@
= link_to(dossier.entreprise.raison_sociale, "/backoffice/dossiers/#{dossier.id}")
%td= dossier.display_state
%td= dossier.last_update
- unless @liste == 'termine'
%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
%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

View file

@ -17,6 +17,13 @@
.badge.progress-bar-info
=@dossiers_en_attente_total
%li{ class: (@suivi_class) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'suivi')}"}
%h5.text-warning
="Suivi"
.badge.progress-bar-warning
=@dossiers_suivi_total
%li{ class: (@termine_class) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'termine')}"}
%h5.text-success

View file

@ -75,6 +75,37 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
end
end
describe 'on tab suivi' do
before do
create :follow, dossier_id: decorate_dossier_replied.id, gestionnaire_id: gestionnaire.id
assign(:dossiers, (smart_listing_create :dossiers,
gestionnaire.dossiers_follow,
partial: "backoffice/dossiers/list",
array: true))
assign(:suivi_class, 'active')
assign(:liste, 'suivi')
render
end
subject { rendered }
it { is_expected.to have_css('#backoffice_index') }
it { is_expected.to have_content(procedure.libelle) }
it { is_expected.to have_content(decorate_dossier_replied.entreprise.raison_sociale) }
it { is_expected.to have_content(decorate_dossier_replied.display_state) }
it { is_expected.to have_content(decorate_dossier_replied.last_update) }
it { is_expected.not_to have_content(decorate_dossier_initiated.entreprise.raison_sociale) }
it { is_expected.not_to have_content(decorate_dossier_closed.entreprise.raison_sociale) }
it { is_expected.to have_css("#suivre_dossier_#{gestionnaire.dossiers_follow.first.id}") }
describe 'active tab' do
it { is_expected.to have_selector('.active .text-warning') }
end
end
describe 'on tab termine' do
before do
assign(:dossiers, (smart_listing_create :dossiers,
@ -97,7 +128,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
it { is_expected.not_to have_content(decorate_dossier_initiated.entreprise.raison_sociale) }
it { is_expected.not_to have_content(decorate_dossier_replied.entreprise.raison_sociale) }
it { is_expected.not_to have_css("#suivre_dossier_#{gestionnaire.dossiers.termine.first.id}") }
it { is_expected.to have_css("#suivre_dossier_#{gestionnaire.dossiers.termine.first.id}") }
describe 'active tab' do
it { is_expected.to have_selector('.active .text-success') }