NewDesign: procedure show add dossier table

This commit is contained in:
Simon Lehericey 2017-07-11 15:40:09 +02:00 committed by Mathieu Magnin
parent b48af51ee9
commit ad1a11ab52
4 changed files with 152 additions and 0 deletions

View file

@ -72,4 +72,71 @@
}
}
}
.dossiers-table {
margin: (2 * $default-padding) auto;
width: 100%;
tr {
border-bottom: 1px solid $border-grey;
&:last-child {
border-bottom: none;
}
&:hover {
background-color: $light-grey;
}
&:first-child {
&:hover {
background: #FFFFFF;
}
}
}
th {
font-weight: bold;
padding: (1.5 * $default-padding) 2px;
text-align: left;
}
td {
vertical-align: middle;
}
.number-col {
width: 130px;
a::before {
content: "";
background-image: image-url("icons/folder.svg");
display: inline-block;
width: 24px;
height: 24px;
margin: 0 $default-spacer;
}
}
.big-link {
color: $black;
display: flex;
align-items: center;
padding: (1.5 * $default-padding) 2px;
}
.status-col {
width: 200px;
}
.follow-col {
width: 200px;
}
h2 {
font-size: 20px;
font-weight: bold;
text-align: center;
margin: 60px 0;
}
}

View file

@ -33,6 +33,21 @@ module NewGestionnaire
@all_state_dossiers = procedure.dossiers.all_state
@archived_dossiers = procedure.dossiers.archived
@statut = params[:statut].present? ? params[:statut] : 'a-suivre'
@dossiers = case @statut
when 'a-suivre'
@a_suivre_dossiers
when 'suivis'
@followed_dossiers
when 'traites'
@termines_dossiers
when 'tous'
@all_state_dossiers
when 'archives'
@archived_dossiers
end
end
private

View file

@ -31,3 +31,20 @@
= link_to(procedure_path(@procedure, statut: 'archives')) do
%span.dossiers-count= @archived_dossiers.count
= t('pluralize.archived', count: @archived_dossiers.count)
.container
- if @dossiers.present?
%table.dossiers-table
%tr
%th.number-col Nº dossier
%th Demandeur
%th.status-col Statut
%th.follow-col
- @dossiers.each do |dossier|
%tr
%td.number-col= link_to(dossier.id, backoffice_dossier_path(dossier), class: 'big-link')
%td= link_to(dossier.user.email, backoffice_dossier_path(dossier), class: 'big-link')
%td.status-col
%td.follow-col
- else
%h2 Aucun dossier

View file

@ -183,6 +183,59 @@ describe NewGestionnaire::ProceduresController, type: :controller do
it { expect(assigns(:all_state_dossiers)).to be_empty }
it { expect(assigns(:archived_dossiers)).to match([archived_dossier]) }
end
describe 'statut' do
let!(:a_suivre__dossier) { create(:dossier, procedure: procedure, state: 'received') }
let!(:new_followed_dossier) { create(:dossier, procedure: procedure, state: 'received') }
let!(:termine_dossier) { create(:dossier, procedure: procedure, state: 'closed') }
let!(:archived_dossier) { create(:dossier, procedure: procedure, state: 'received', archived: true) }
before do
gestionnaire.followed_dossiers << new_followed_dossier
get :show, params: { procedure_id: procedure.id, statut: statut }
end
context 'when statut is empty' do
let(:statut) { nil }
it { expect(assigns(:dossiers)).to match([a_suivre__dossier]) }
it { expect(assigns(:statut)).to eq('a-suivre') }
end
context 'when statut is a-suivre' do
let(:statut) { 'a-suivre' }
it { expect(assigns(:statut)).to eq('a-suivre') }
it { expect(assigns(:dossiers)).to match([a_suivre__dossier]) }
end
context 'when statut is suivis' do
let(:statut) { 'suivis' }
it { expect(assigns(:statut)).to eq('suivis') }
it { expect(assigns(:dossiers)).to match([new_followed_dossier]) }
end
context 'when statut is traites' do
let(:statut) { 'traites' }
it { expect(assigns(:statut)).to eq('traites') }
it { expect(assigns(:dossiers)).to match([termine_dossier]) }
end
context 'when statut is tous' do
let(:statut) { 'tous' }
it { expect(assigns(:statut)).to eq('tous') }
it { expect(assigns(:dossiers)).to match([a_suivre__dossier, new_followed_dossier, termine_dossier]) }
end
context 'when statut is archives' do
let(:statut) { 'archives' }
it { expect(assigns(:statut)).to eq('archives') }
it { expect(assigns(:dossiers)).to match([archived_dossier]) }
end
end
end
end
end