Ajout des tableaux séparés et des états de chaque dossier dans le backoffice
This commit is contained in:
parent
2a2147a7bb
commit
be5a7f2fd2
5 changed files with 159 additions and 81 deletions
|
@ -2,6 +2,8 @@ class BackofficeController < ApplicationController
|
|||
|
||||
def index
|
||||
redirect_to(controller: '/gestionnaires/sessions', action: :new) unless gestionnaire_signed_in?
|
||||
@dossiers = Dossier.all.decorate
|
||||
@dossiers_a_traiter = Dossier.a_traiter.decorate
|
||||
@dossiers_en_attente = Dossier.en_attente.decorate
|
||||
@dossiers_termine = Dossier.termine.decorate
|
||||
end
|
||||
end
|
|
@ -101,6 +101,18 @@ class Dossier < ActiveRecord::Base
|
|||
state
|
||||
end
|
||||
|
||||
def self.a_traiter
|
||||
Dossier.where("state='proposed' OR state='updated' OR state='deposited'").order('updated_at ASC')
|
||||
end
|
||||
|
||||
def self.en_attente
|
||||
Dossier.where("state='reply' OR state='confirmed'").order('updated_at ASC')
|
||||
end
|
||||
|
||||
def self.termine
|
||||
Dossier.where("state='processed'").order('updated_at ASC')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def build_default_cerfa
|
||||
|
|
|
@ -1,16 +1,49 @@
|
|||
#backoffice
|
||||
|
||||
|
||||
%h1 Gestion des dossiers
|
||||
%br
|
||||
%h3.text-danger À traiter
|
||||
%table.table
|
||||
%thead
|
||||
%th Procédure
|
||||
%th Dossier
|
||||
%th etat
|
||||
%th Date de mise à jour
|
||||
- @dossiers.each do |dossier|
|
||||
%thead.row
|
||||
%th.col-md-4.col-lg-4 Procédure
|
||||
%th.col-md-4.col-lg-4 Dossier
|
||||
%th.col-md-2.col-lg-2 État
|
||||
%th.col-md-2.col-lg-2 Date de mise à jour
|
||||
- @dossiers_a_traiter.each do |dossier|
|
||||
%tr
|
||||
%td= dossier.procedure.libelle
|
||||
%td
|
||||
= link_to(dossier.nom_projet, "/backoffice/dossiers/#{dossier.id}")
|
||||
%td Mise à jour
|
||||
%td= dossier.state_fr
|
||||
%td= dossier.last_update
|
||||
|
||||
%br
|
||||
%h3.text-info En attente
|
||||
%table.table
|
||||
%thead
|
||||
%th.col-md-4.col-lg-4 Procédure
|
||||
%th.col-md-4.col-lg-4 Dossier
|
||||
%th.col-md-2.col-lg-2 État
|
||||
%th.col-md-2.col-lg-2 Date de mise à jour
|
||||
- @dossiers_en_attente.each do |dossier|
|
||||
%tr
|
||||
%td= dossier.procedure.libelle
|
||||
%td
|
||||
= link_to(dossier.nom_projet, "/backoffice/dossiers/#{dossier.id}")
|
||||
%td= dossier.state_fr
|
||||
%td= dossier.last_update
|
||||
|
||||
%br
|
||||
%h3.text-success Traité
|
||||
%table.table
|
||||
%thead
|
||||
%th.col-md-4.col-lg-4 Procédure
|
||||
%th.col-md-4.col-lg-4 Dossier
|
||||
%th.col-md-2.col-lg-2 État
|
||||
%th.col-md-2.col-lg-2 Date de mise à jour
|
||||
- @dossiers_termine.each do |dossier|
|
||||
%tr
|
||||
%td= dossier.procedure.libelle
|
||||
%td
|
||||
= link_to(dossier.nom_projet, "/backoffice/dossiers/#{dossier.id}")
|
||||
%td= dossier.state_fr
|
||||
%td= dossier.last_update
|
|
@ -370,5 +370,34 @@ describe Dossier do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'gestionnaire backoffice methods' do
|
||||
let!(:dossier1) { create(:dossier, :with_user, :with_procedure, state: 'draft')}
|
||||
let!(:dossier2) { create(:dossier, :with_user, :with_procedure, state: 'proposed')}
|
||||
let!(:dossier3) { create(:dossier, :with_user, :with_procedure, state: 'proposed')}
|
||||
let!(:dossier4) { create(:dossier, :with_user, :with_procedure, state: 'reply')}
|
||||
let!(:dossier5) { create(:dossier, :with_user, :with_procedure, state: 'updated')}
|
||||
let!(:dossier6) { create(:dossier, :with_user, :with_procedure, state: 'confirmed')}
|
||||
let!(:dossier7) { create(:dossier, :with_user, :with_procedure, state: 'deposited')}
|
||||
let!(:dossier8) { create(:dossier, :with_user, :with_procedure, state: 'processed')}
|
||||
|
||||
describe '#a_traiter' do
|
||||
subject { described_class.a_traiter }
|
||||
|
||||
it { expect(subject.size).to eq(4) }
|
||||
end
|
||||
|
||||
describe '#en_attente' do
|
||||
subject { described_class.en_attente }
|
||||
|
||||
it { expect(subject.size).to eq(2) }
|
||||
end
|
||||
|
||||
describe '#termine' do
|
||||
subject { described_class.termine }
|
||||
|
||||
it { expect(subject.size).to eq(1) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,6 +5,7 @@ describe 'backoffice/index.html.haml', type: :view do
|
|||
let!(:decorated_dossier) { create(:dossier, :with_user, procedure: procedure).decorate }
|
||||
before do
|
||||
assign(:dossiers, [decorated_dossier])
|
||||
decorated_dossier.proposed!
|
||||
render
|
||||
end
|
||||
subject { rendered }
|
||||
|
@ -12,5 +13,6 @@ describe 'backoffice/index.html.haml', type: :view do
|
|||
it { is_expected.to have_content('Demande de subvention') }
|
||||
it { is_expected.to have_content(procedure.libelle) }
|
||||
it { is_expected.to have_content(decorated_dossier.nom_projet) }
|
||||
it { is_expected.to have_content(decorated_dossier.state_fr) }
|
||||
it { is_expected.to have_content(decorated_dossier.last_update) }
|
||||
end
|
Loading…
Reference in a new issue