Delete tab Nouveau A traiter and En cours d'étude for User and replace this only one call En construction

This commit is contained in:
Xavier J 2016-10-19 17:25:24 +02:00
parent fd9eaa5a4d
commit a7166d306f
9 changed files with 110 additions and 87 deletions

View file

@ -20,7 +20,7 @@ class DossiersListFacades
end end
def gestionnaire_procedures_name_and_id_list 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})} @current_devise_profil.procedures.order('libelle ASC').inject([]) { |acc, procedure| acc.push({id: procedure.id, libelle: procedure.libelle}) }
end end
def procedure_id def procedure_id
@ -53,6 +53,10 @@ class DossiersListFacades
(@liste == 'a_traiter' ? 'active' : '') (@liste == 'a_traiter' ? 'active' : '')
end end
def en_construction_class
(@liste == 'a_traiter' ? 'active' : '')
end
def en_attente_class def en_attente_class
(@liste == 'en_attente' ? 'active' : '') (@liste == 'en_attente' ? 'active' : '')
end end
@ -98,13 +102,15 @@ class DossiersListFacades
end end
def a_traiter_total def a_traiter_total
return service.waiting_for_gestionnaire.count if gestionnaire? service.waiting_for_gestionnaire.count
service.waiting_for_user.count if user? end
def en_construction_total
service.en_construction.count
end end
def en_attente_total def en_attente_total
return service.waiting_for_user.count if gestionnaire? service.waiting_for_user.count
service.waiting_for_gestionnaire.count if user?
end end
def valides_total def valides_total
@ -147,6 +153,10 @@ class DossiersListFacades
base_url 'a_traiter' base_url 'a_traiter'
end end
def en_construction_url
base_url 'a_traiter'
end
def en_attente_url def en_attente_url
base_url 'en_attente' base_url 'en_attente'
end end

View file

@ -47,7 +47,7 @@ class Dossier < ActiveRecord::Base
NOUVEAUX = %w(initiated) NOUVEAUX = %w(initiated)
WAITING_FOR_GESTIONNAIRE = %w(updated) WAITING_FOR_GESTIONNAIRE = %w(updated)
WAITING_FOR_USER = %w(replied validated) WAITING_FOR_USER = %w(replied validated)
WAITING_FOR_USER_WITHOUT_VALIDATED = %w(replied) EN_CONSTRUCTION = %w(initiated updated replied)
VALIDES = %w(validated) VALIDES = %w(validated)
DEPOSES = %w(submitted) DEPOSES = %w(submitted)
EN_INSTRUCTION = %w(submitted received) EN_INSTRUCTION = %w(submitted received)
@ -185,8 +185,8 @@ class Dossier < ActiveRecord::Base
WAITING_FOR_USER.include?(state) WAITING_FOR_USER.include?(state)
end end
def waiting_for_user_without_validated? def en_construction?
WAITING_FOR_USER_WITHOUT_VALIDATED.include?(state) EN_CONSTRUCTION.include?(state)
end end
def deposes? def deposes?
@ -225,8 +225,8 @@ class Dossier < ActiveRecord::Base
where(state: WAITING_FOR_USER, archived: false).order("updated_at #{order}") where(state: WAITING_FOR_USER, archived: false).order("updated_at #{order}")
end end
def self.waiting_for_user_without_validated order = 'ASC' def self.en_construction order = 'ASC'
where(state: WAITING_FOR_USER_WITHOUT_VALIDATED, archived: false).order("updated_at #{order}") where(state: EN_CONSTRUCTION, archived: false).order("updated_at #{order}")
end end
def self.valides order = 'ASC' def self.valides order = 'ASC'

View file

@ -121,7 +121,7 @@ class DossiersListGestionnaireService
def joins_filter def joins_filter
filter_preference_list.inject([]) do |acc, preference| filter_preference_list.inject([]) do |acc, preference|
acc.push(preference.table.to_sym) unless preference.table.blank? acc.push(preference.table.to_sym) unless preference.table.blank? || preference.filter.blank?
acc acc
end end
end end

View file

@ -6,9 +6,7 @@ class DossiersListUserService
def dossiers_to_display def dossiers_to_display
{'brouillon' => brouillon, {'brouillon' => brouillon,
'nouveaux' => nouveaux, 'a_traiter' => en_construction,
'a_traiter' => waiting_for_user,
'en_attente' => waiting_for_gestionnaire,
'valides' => valides, 'valides' => valides,
'en_instruction' => en_instruction, 'en_instruction' => en_instruction,
'termine' => termine, 'termine' => termine,
@ -16,23 +14,15 @@ class DossiersListUserService
end end
def self.dossiers_liste_libelle def self.dossiers_liste_libelle
['brouillon', 'nouveaux', 'a_traiter', 'en_attente', 'valides', 'en_instruction', 'termine', 'invite'] ['brouillon', 'a_traiter', 'valides', 'en_instruction', 'termine', 'invite']
end end
def brouillon def brouillon
@brouillon ||= @current_devise_profil.dossiers.brouillon @brouillon ||= @current_devise_profil.dossiers.brouillon
end end
def nouveaux def en_construction
@nouveaux ||= @current_devise_profil.dossiers.nouveaux @en_construction ||= @current_devise_profil.dossiers.en_construction
end
def waiting_for_gestionnaire
@waiting_for_gestionnaire ||= @current_devise_profil.dossiers.waiting_for_gestionnaire
end
def waiting_for_user
@waiting_for_user ||= @current_devise_profil.dossiers.waiting_for_user_without_validated
end end
def invite def invite

View file

@ -8,26 +8,12 @@
.badge.progress-bar-default .badge.progress-bar-default
= @dossiers_list_facade.brouillon_total = @dossiers_list_facade.brouillon_total
%li{ class: @dossiers_list_facade.nouveaux_class } %li{ class: @dossiers_list_facade.en_construction_class }
%a{:href => "#{url_for users_dossiers_path(liste: 'nouveaux')}", 'data-toggle' => :tooltip, title: 'Les nouveaux dossiers qui n\'ont pas encore été vus par votre accompagnateur.'}
%h5.text-info
= "Nouveaux"
.badge.progress-bar-info
= @dossiers_list_facade.nouveaux_total
%li{ class: @dossiers_list_facade.a_traiter_class }
%a{:href => "#{url_for users_dossiers_path(liste: 'a_traiter')}", 'data-toggle' => :tooltip, title: 'Les dossiers qui requièrent une action de votre part.'} %a{:href => "#{url_for users_dossiers_path(liste: 'a_traiter')}", 'data-toggle' => :tooltip, title: 'Les dossiers qui requièrent une action de votre part.'}
%h5.text-danger %h5.text-danger
= "Action requise" = "En construction"
.badge.progress-bar-danger .badge.progress-bar-danger
= @dossiers_list_facade.a_traiter_total = @dossiers_list_facade.en_construction_total
%li{ class: @dossiers_list_facade.en_attente_class }
%a{:href => "#{url_for users_dossiers_path(liste: 'en_attente')}", 'data-toggle' => :tooltip, title: 'Les dossiers en cours de relecture par votre accompagnateur.'}
%h5.text-default
="Etude en cours"
.badge.progress-bar-default
= @dossiers_list_facade.en_attente_total
%li{ class: @dossiers_list_facade.valides_class } %li{ class: @dossiers_list_facade.valides_class }
%a{:href => "#{url_for users_dossiers_path(liste: 'valides')}", 'data-toggle' => :tooltip, title: 'Les dossiers relus par votre accompagnateur pouvant être déposés pour examen.'} %a{:href => "#{url_for users_dossiers_path(liste: 'valides')}", 'data-toggle' => :tooltip, title: 'Les dossiers relus par votre accompagnateur pouvant être déposés pour examen.'}

View file

@ -418,14 +418,40 @@ describe Users::DossiersController, type: :controller do
end end
end end
describe 'GET #en_attente' do describe 'GET #valides' do
context 'when user is connected' do context 'when user is connected' do
before do before do
sign_in user sign_in user
end end
it 'returns http success' do it 'returns http success' do
get :index, liste: :en_attente get :index, liste: :valides
expect(response).to have_http_status(200)
end
end
end
describe 'GET #en_instruction' do
context 'when user is connected' do
before do
sign_in user
end
it 'returns http success' do
get :index, liste: :en_instruction
expect(response).to have_http_status(200)
end
end
end
describe 'GET #brouillon' do
context 'when user is connected' do
before do
sign_in user
end
it 'returns http success' do
get :index, liste: :brouillon
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
end end
end end

View file

@ -22,21 +22,10 @@ feature 'on click on tabs button' do
end end
context 'when user is logged in' do context 'when user is logged in' do
context 'when he click on tabs nouveaux' do context 'when he click on tabs en construction' do
before do
visit users_dossiers_url(liste: :nouveaux)
page.click_on 'Nouveaux 1'
end
scenario 'it redirect to users dossier termine' do
expect(page).to have_css('#users_index')
end
end
context 'when he click on tabs a traite' do
before do before do
visit users_dossiers_url(liste: :a_traiter) visit users_dossiers_url(liste: :a_traiter)
page.click_on 'Action requise 1' page.click_on 'En construction 3'
end end
scenario 'it redirect to users dossier termine' do scenario 'it redirect to users dossier termine' do
@ -44,17 +33,6 @@ feature 'on click on tabs button' do
end end
end end
context 'when he click on tabs en attente' do
before do
visit users_dossiers_url(liste: :en_attente)
page.click_on 'Etude en cours 1'
end
scenario 'it redirect to users dossier en attente' do
expect(page).to have_css('#users_index')
end
end
context 'when he click on tabs a deposes' do context 'when he click on tabs a deposes' do
before do before do
visit users_dossiers_url(liste: :valides) visit users_dossiers_url(liste: :valides)

View file

@ -125,6 +125,43 @@ describe DossiersListGestionnaireService do
end end
end end
describe '#join_filter' do
subject { DossiersListGestionnaireService.new(gestionnaire, liste, nil).joins_filter }
it { is_expected.to eq []}
context 'when a filter is fielded' do
before do
gestionnaire.preference_list_dossiers
.find_by(table: 'entreprise', attr: 'raison_sociale', procedure: nil)
.update_column :filter, 'plop'
end
it { is_expected.to eq [:entreprise] }
end
context 'when a filter is empty' do
before do
gestionnaire.preference_list_dossiers
.find_by(table: 'entreprise', attr: 'raison_sociale', procedure: nil)
.update_column :filter, ''
end
it { is_expected.to eq [] }
end
context 'when a filter is nil' do
before do
gestionnaire.preference_list_dossiers
.find_by(table: 'entreprise', attr: 'raison_sociale', procedure: nil)
.update_column :filter, nil
end
it { is_expected.to eq [] }
end
end
describe '#where_filter' do describe '#where_filter' do
before do before do
gestionnaire.preference_list_dossiers gestionnaire.preference_list_dossiers
@ -181,6 +218,16 @@ describe DossiersListGestionnaireService do
it { is_expected.to eq "CAST(dossiers.id as TEXT) LIKE '%23%' AND CAST(entreprises.raison_sociale as TEXT) LIKE '%MCDONALD''S FRANCE%'" } it { is_expected.to eq "CAST(dossiers.id as TEXT) LIKE '%23%' AND CAST(entreprises.raison_sociale as TEXT) LIKE '%MCDONALD''S FRANCE%'" }
end end
context "when filter is empty " do
before do
gestionnaire.preference_list_dossiers
.find_by(table: 'entreprise', attr: 'raison_sociale', procedure: nil)
.update_column :filter, ""
end
it { is_expected.to eq "CAST(dossiers.id as TEXT) LIKE '%23%'" }
end
context 'when preference list contain a champ' do context 'when preference list contain a champ' do
before do before do
create :preference_list_dossier, create :preference_list_dossier,

View file

@ -46,33 +46,19 @@ describe 'users/dossiers/index.html.haml', type: :view do
end end
end end
describe 'on tab nouveaux' do describe 'on tab en construction' do
let(:total_dossiers) { 1 } let(:total_dossiers) { 3 }
let(:active_class) { '.active .text-info' } let(:active_class) { '.active .text-danger' }
let(:dossiers_to_display) { user.dossiers.nouveaux } let(:dossiers_to_display) { user.dossiers.en_construction }
let(:liste) { 'nouveaux' } let(:liste) { 'a_traiter' }
it_behaves_like 'check_tab_content' do it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_initiated } let(:decorate_dossier_at_check) { decorate_dossier_initiated }
end end
end
describe 'on tab action requise' do
let(:total_dossiers) { 1 }
let(:active_class) { '.active .text-danger' }
let(:dossiers_to_display) { user.dossiers.waiting_for_user_without_validated }
let(:liste) { 'a_traiter' }
it_behaves_like 'check_tab_content' do it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_replied } let(:decorate_dossier_at_check) { decorate_dossier_replied }
end end
end
describe 'on tab etude en cours' do
let(:total_dossiers) { 1 }
let(:active_class) { '.active .text-default' }
let(:dossiers_to_display) { user.dossiers.waiting_for_gestionnaire }
let(:liste) { 'en_attente' }
it_behaves_like 'check_tab_content' do it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_updated } let(:decorate_dossier_at_check) { decorate_dossier_updated }