NewDesign: procedure show only header

This commit is contained in:
Simon Lehericey 2017-07-11 16:09:03 +02:00 committed by Mathieu Magnin
parent 0528b83fcc
commit b48af51ee9
7 changed files with 231 additions and 13 deletions

View file

@ -0,0 +1,75 @@
@import "colors";
@import "common";
@import "constants";
#procedure-show {
.header {
background-color: $light-grey;
padding-top: $default-padding;
.container {
display: flex;
}
.procedure-logo {
margin-right: $default-padding;
}
h1 {
color: $black;
font-size: 22px;
margin-bottom: 2 * $default-padding;
}
.dossiers-categories {
li {
display: inline-block;
height: 56px;
width: 130px;
line-height: 17px;
position: relative;
text-align: center;
font-size: 14px;
a {
color: $black;
}
&::before,
&:last-child::after {
content: "";
position: absolute;
height: 36px;
width: 1px;
background-color: $border-grey;
margin-right: $default-padding;
}
&::before {
left: 0px;
}
&:last-child::after {
right: 0px;
top: 0px;
margin-right: 0px;
}
&.active {
border-bottom: 2px solid $blue;
a {
color: $blue;
}
}
.dossiers-count {
position: relative;
display: block;
font-size: 16px;
font-weight: bold;
}
}
}
}
}

View file

@ -15,6 +15,26 @@ module NewGestionnaire
@followed_dossiers_count_per_procedure = current_gestionnaire.followed_dossiers.where(procedure: @procedures).group(:procedure_id).count @followed_dossiers_count_per_procedure = current_gestionnaire.followed_dossiers.where(procedure: @procedures).group(:procedure_id).count
end end
def show
@procedure = procedure
@a_suivre_dossiers = procedure
.dossiers
.without_followers
.en_cours
@followed_dossiers = current_gestionnaire
.followed_dossiers
.where(procedure: @procedure)
.en_cours
@termines_dossiers = procedure.dossiers.termine
@all_state_dossiers = procedure.dossiers.all_state
@archived_dossiers = procedure.dossiers.archived
end
private private
def procedure def procedure

View file

@ -17,6 +17,7 @@ class Dossier < ActiveRecord::Base
WAITING_FOR_USER = %w(replied) WAITING_FOR_USER = %w(replied)
EN_CONSTRUCTION = %w(initiated updated replied) EN_CONSTRUCTION = %w(initiated updated replied)
EN_INSTRUCTION = %w(received) EN_INSTRUCTION = %w(received)
EN_CONSTRUCTION_OU_INSTRUCTION = EN_CONSTRUCTION + EN_INSTRUCTION
A_INSTRUIRE = %w(received) A_INSTRUIRE = %w(received)
TERMINE = %w(closed refused without_continuation) TERMINE = %w(closed refused without_continuation)
@ -51,6 +52,7 @@ class Dossier < ActiveRecord::Base
scope :state_waiting_for_user, -> { where(state: WAITING_FOR_USER) } scope :state_waiting_for_user, -> { where(state: WAITING_FOR_USER) }
scope :state_en_construction, -> { where(state: EN_CONSTRUCTION) } scope :state_en_construction, -> { where(state: EN_CONSTRUCTION) }
scope :state_en_instruction, -> { where(state: EN_INSTRUCTION) } scope :state_en_instruction, -> { where(state: EN_INSTRUCTION) }
scope :state_en_construction_ou_instruction, -> { where(state: EN_CONSTRUCTION_OU_INSTRUCTION) }
scope :state_a_instruire, -> { where(state: A_INSTRUIRE) } scope :state_a_instruire, -> { where(state: A_INSTRUIRE) }
scope :state_termine, -> { where(state: TERMINE) } scope :state_termine, -> { where(state: TERMINE) }
@ -67,6 +69,8 @@ class Dossier < ActiveRecord::Base
scope :a_instruire, -> { not_archived.state_a_instruire.order_by_updated_at(:asc) } scope :a_instruire, -> { not_archived.state_a_instruire.order_by_updated_at(:asc) }
scope :termine, -> { not_archived.state_termine.order_by_updated_at(:asc) } scope :termine, -> { not_archived.state_termine.order_by_updated_at(:asc) }
scope :downloadable, -> { state_not_brouillon.order_by_updated_at(:asc) } scope :downloadable, -> { state_not_brouillon.order_by_updated_at(:asc) }
scope :en_cours, -> { not_archived.state_en_construction_ou_instruction.order_by_updated_at(:asc) }
scope :without_followers, -> { includes(:follows).where(follows: { id: nil }) }
accepts_nested_attributes_for :individual accepts_nested_attributes_for :individual

View file

@ -0,0 +1,33 @@
#procedure-show
.header
.container
- if @procedure.logo.present?
= image_tag @procedure.logo, height: 40, class: 'procedure-logo'
.right
%h1= @procedure.libelle
%ul.dossiers-categories
%li{ class: (@statut == 'a-suivre') ? 'active' : nil }>
= link_to(procedure_path(@procedure, statut: 'a-suivre')) do
%span.dossiers-count= @a_suivre_dossiers.count
à suivre
%li{ class: (@statut == 'suivis') ? 'active' : nil }>
= link_to(procedure_path(@procedure, statut: 'suivis')) do
%span.dossiers-count= @followed_dossiers.count
= t('pluralize.followed', count: @followed_dossiers.count)
%li{ class: (@statut == 'traites') ? 'active' : nil }>
= link_to(procedure_path(@procedure, statut: 'traites')) do
%span.dossiers-count= @termines_dossiers.count
= t('pluralize.processed', count: @termines_dossiers.count)
%li{ class: (@statut == 'tous') ? 'active' : nil }>
= link_to(procedure_path(@procedure, statut: 'tous')) do
%span.dossiers-count= @all_state_dossiers.count
tous les dossiers
%li{ class: (@statut == 'archives') ? 'active' : nil }>
= link_to(procedure_path(@procedure, statut: 'archives')) do
%span.dossiers-count= @archived_dossiers.count
= t('pluralize.archived', count: @archived_dossiers.count)

View file

@ -285,3 +285,20 @@ fr:
x_seconds: x_seconds:
one: 1 seconde one: 1 seconde
other: "%{count} secondes" other: "%{count} secondes"
pluralize:
processed:
zero: traité
one: traité
other: traités
new:
zero: nouveau
one: nouveau
other: nouveaux
followed:
zero: suivi
one: suivi
other: suivis
archived:
zero: archivé
one: archivé
other: archivés

View file

@ -238,12 +238,14 @@ Rails.application.routes.draw do
end end
scope module: 'new_gestionnaire' do scope module: 'new_gestionnaire' do
resources :procedures, only: [:index] do resources :procedures, only: [:index, :show], param: :procedure_id do
member do
resources :dossiers, only: [] do resources :dossiers, only: [] do
get 'attestation' get 'attestation'
end end
end end
end end
end
apipie apipie
end end

View file

@ -118,4 +118,71 @@ describe NewGestionnaire::ProceduresController, type: :controller do
end end
end end
end end
describe "#show" do
let(:gestionnaire) { create(:gestionnaire) }
let!(:procedure) { create(:procedure, gestionnaires: [gestionnaire]) }
context "when logged in" do
before do
sign_in(gestionnaire)
get :show, params: { procedure_id: procedure.id }
end
it { expect(response).to have_http_status(:ok) }
it { expect(assigns(:procedure)).to eq(procedure) }
context 'with a new draft dossier' do
let!(:draft_dossier) { create(:dossier, procedure: procedure, state: 'draft') }
it { expect(assigns(:a_suivre_dossiers)).to be_empty }
it { expect(assigns(:followed_dossiers)).to be_empty }
it { expect(assigns(:termines_dossiers)).to be_empty }
it { expect(assigns(:all_state_dossiers)).to be_empty }
it { expect(assigns(:archived_dossiers)).to be_empty }
end
context 'with a new dossier without follower' do
let!(:new_unfollow_dossier) { create(:dossier, procedure: procedure, state: 'received') }
it { expect(assigns(:a_suivre_dossiers)).to match([new_unfollow_dossier]) }
it { expect(assigns(:followed_dossiers)).to be_empty }
it { expect(assigns(:termines_dossiers)).to be_empty }
it { expect(assigns(:all_state_dossiers)).to match([new_unfollow_dossier]) }
it { expect(assigns(:archived_dossiers)).to be_empty }
end
context 'with a new dossier with a follower' do
let!(:new_followed_dossier) { create(:dossier, procedure: procedure, state: 'received') }
before { gestionnaire.followed_dossiers << new_followed_dossier }
it { expect(assigns(:a_suivre_dossiers)).to be_empty }
it { expect(assigns(:followed_dossiers)).to match([new_followed_dossier]) }
it { expect(assigns(:termines_dossiers)).to be_empty }
it { expect(assigns(:all_state_dossiers)).to match([new_followed_dossier]) }
it { expect(assigns(:archived_dossiers)).to be_empty }
end
context 'with a termine dossier with a follower' do
let!(:termine_dossier) { create(:dossier, procedure: procedure, state: 'closed') }
it { expect(assigns(:a_suivre_dossiers)).to be_empty }
it { expect(assigns(:followed_dossiers)).to be_empty }
it { expect(assigns(:termines_dossiers)).to match([termine_dossier]) }
it { expect(assigns(:all_state_dossiers)).to match([termine_dossier]) }
it { expect(assigns(:archived_dossiers)).to be_empty }
end
context 'with an archived dossier' do
let!(:archived_dossier) { create(:dossier, procedure: procedure, state: 'received', archived: true) }
it { expect(assigns(:a_suivre_dossiers)).to be_empty }
it { expect(assigns(:followed_dossiers)).to be_empty }
it { expect(assigns(:termines_dossiers)).to be_empty }
it { expect(assigns(:all_state_dossiers)).to be_empty }
it { expect(assigns(:archived_dossiers)).to match([archived_dossier]) }
end
end
end
end end