Creation three tabs for gestionnaire back office
This commit is contained in:
parent
f2fb512cd1
commit
19b76203c4
14 changed files with 248 additions and 61 deletions
|
@ -5,6 +5,21 @@ class Backoffice::DossiersController < ApplicationController
|
||||||
initialize_instance_params params[:id]
|
initialize_instance_params params[:id]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def a_traiter
|
||||||
|
@dossiers_a_traiter = Dossier.a_traiter(current_gestionnaire).decorate
|
||||||
|
total_dossiers_per_state
|
||||||
|
end
|
||||||
|
|
||||||
|
def en_attente
|
||||||
|
@dossiers_en_attente = Dossier.en_attente(current_gestionnaire).decorate
|
||||||
|
total_dossiers_per_state
|
||||||
|
end
|
||||||
|
|
||||||
|
def termine
|
||||||
|
@dossiers_termine = Dossier.termine(current_gestionnaire).decorate
|
||||||
|
total_dossiers_per_state
|
||||||
|
end
|
||||||
|
|
||||||
def valid
|
def valid
|
||||||
initialize_instance_params params[:dossier_id]
|
initialize_instance_params params[:dossier_id]
|
||||||
|
|
||||||
|
@ -25,6 +40,12 @@ class Backoffice::DossiersController < ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def total_dossiers_per_state
|
||||||
|
@dossiers_a_traiter_total = !@dossiers_a_traiter.nil? ? @dossiers_a_traiter.size : Dossier.a_traiter(current_gestionnaire).size
|
||||||
|
@dossiers_en_attente_total = !@dossiers_en_attente.nil? ? @dossiers_en_attente.size : Dossier.en_attente(current_gestionnaire).size
|
||||||
|
@dossiers_termine_total = !@dossiers_termine.nil? ? @dossiers_termine.size : Dossier.termine(current_gestionnaire).size
|
||||||
|
end
|
||||||
|
|
||||||
def initialize_instance_params dossier_id
|
def initialize_instance_params dossier_id
|
||||||
@dossier = Dossier.find(dossier_id)
|
@dossier = Dossier.find(dossier_id)
|
||||||
@entreprise = @dossier.entreprise.decorate
|
@entreprise = @dossier.entreprise.decorate
|
||||||
|
|
|
@ -4,9 +4,7 @@ class BackofficeController < ApplicationController
|
||||||
if !gestionnaire_signed_in?
|
if !gestionnaire_signed_in?
|
||||||
redirect_to(controller: '/gestionnaires/sessions', action: :new)
|
redirect_to(controller: '/gestionnaires/sessions', action: :new)
|
||||||
else
|
else
|
||||||
@dossiers_a_traiter = Dossier.a_traiter(current_gestionnaire).decorate
|
redirect_to(:backoffice_dossiers_a_traiter)
|
||||||
@dossiers_en_attente = Dossier.en_attente(current_gestionnaire).decorate
|
|
||||||
@dossiers_termine = Dossier.termine(current_gestionnaire).decorate
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
18
app/views/backoffice/dossiers/_onglets.html.haml
Normal file
18
app/views/backoffice/dossiers/_onglets.html.haml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
%h1 Gestion des dossiers
|
||||||
|
%br
|
||||||
|
|
||||||
|
%ul.nav.nav-tabs
|
||||||
|
%li{class: "#{'active' unless @dossiers_a_traiter.nil? }"}
|
||||||
|
%a{:href => "#{url_for :backoffice_dossiers_a_traiter}"}
|
||||||
|
%strong.text-danger
|
||||||
|
= "À traiter (#{@dossiers_a_traiter_total})"
|
||||||
|
%li{class: "#{'active' unless @dossiers_en_attente.nil? }"}
|
||||||
|
%a{:href => "#{url_for :backoffice_dossiers_en_attente}"}
|
||||||
|
%strong.text-info
|
||||||
|
="En attente (#{@dossiers_en_attente_total})"
|
||||||
|
%li{class: "#{'active' unless @dossiers_termine.nil? }"}
|
||||||
|
%a{:href => "#{url_for :backoffice_dossiers_termine}"}
|
||||||
|
%strong.text-success
|
||||||
|
= "Terminé (#{@dossiers_termine_total})"
|
||||||
|
|
||||||
|
%br
|
17
app/views/backoffice/dossiers/a_traiter.html.haml
Normal file
17
app/views/backoffice/dossiers/a_traiter.html.haml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#backoffice_a_traiter
|
||||||
|
= render partial: 'onglets'
|
||||||
|
|
||||||
|
-#%h3.text-danger À traiter
|
||||||
|
%table.table
|
||||||
|
%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= dossier.state_fr
|
||||||
|
%td= dossier.last_update
|
17
app/views/backoffice/dossiers/en_attente.html.haml
Normal file
17
app/views/backoffice/dossiers/en_attente.html.haml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#backoffice_en_attente
|
||||||
|
= render partial: 'onglets'
|
||||||
|
|
||||||
|
-#%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
|
17
app/views/backoffice/dossiers/termine.html.haml
Normal file
17
app/views/backoffice/dossiers/termine.html.haml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#backoffice_termine
|
||||||
|
= render partial: 'onglets'
|
||||||
|
|
||||||
|
-#%h3.text-success Terminé
|
||||||
|
%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
|
|
@ -1,49 +0,0 @@
|
||||||
#backoffice
|
|
||||||
%h1 Gestion des dossiers
|
|
||||||
%br
|
|
||||||
%h3.text-danger À traiter
|
|
||||||
%table.table
|
|
||||||
%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= 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 Terminé
|
|
||||||
%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
|
|
|
@ -51,6 +51,10 @@ Rails.application.routes.draw do
|
||||||
namespace :backoffice do
|
namespace :backoffice do
|
||||||
get 'sign_in' => '/gestionnaires/sessions#new'
|
get 'sign_in' => '/gestionnaires/sessions#new'
|
||||||
|
|
||||||
|
get 'dossiers/a_traiter' => 'dossiers#a_traiter'
|
||||||
|
get 'dossiers/en_attente' => 'dossiers#en_attente'
|
||||||
|
get 'dossiers/termine' => 'dossiers#termine'
|
||||||
|
|
||||||
resources :dossiers do
|
resources :dossiers do
|
||||||
post 'valid' => 'dossiers#valid'
|
post 'valid' => 'dossiers#valid'
|
||||||
post 'close' => 'dossiers#close'
|
post 'close' => 'dossiers#close'
|
||||||
|
|
|
@ -4,7 +4,7 @@ describe Backoffice::DossiersController, type: :controller do
|
||||||
let(:dossier) { create(:dossier, :with_entreprise, :with_user) }
|
let(:dossier) { create(:dossier, :with_entreprise, :with_user) }
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
let(:bad_dossier_id) { Dossier.count + 10 }
|
let(:bad_dossier_id) { Dossier.count + 10 }
|
||||||
let(:gestionnaire) { create(:gestionnaire) }
|
let(:gestionnaire) { create(:gestionnaire, administrateur: create(:administrateur)) }
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
context 'gestionnaire is connected' do
|
context 'gestionnaire is connected' do
|
||||||
|
@ -29,6 +29,45 @@ describe Backoffice::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'GET #a_traiter' do
|
||||||
|
context 'when gestionnaire is connected' do
|
||||||
|
before do
|
||||||
|
sign_in gestionnaire
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns http success' do
|
||||||
|
get :a_traiter
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'GET #en_attente' do
|
||||||
|
context 'when gestionnaire is connected' do
|
||||||
|
before do
|
||||||
|
sign_in gestionnaire
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns http success' do
|
||||||
|
get :en_attente
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'GET #termine' do
|
||||||
|
context 'when gestionnaire is connected' do
|
||||||
|
before do
|
||||||
|
sign_in gestionnaire
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns http success' do
|
||||||
|
get :termine
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'POST #valid' do
|
describe 'POST #valid' do
|
||||||
before do
|
before do
|
||||||
dossier.initiated!
|
dossier.initiated!
|
||||||
|
|
22
spec/controllers/backoffice_controller_spec.rb
Normal file
22
spec/controllers/backoffice_controller_spec.rb
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe BackofficeController, type: :controller do
|
||||||
|
describe 'GET #index' do
|
||||||
|
context 'when gestionnaire is not connected'do
|
||||||
|
before do
|
||||||
|
get :index
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(response).to redirect_to :new_gestionnaire_session }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when gestionnaire is connected'do
|
||||||
|
before do
|
||||||
|
sign_in create(:gestionnaire)
|
||||||
|
get :index
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(response).to redirect_to :backoffice_dossiers_a_traiter }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
45
spec/features/backoffice/onglets_link_spec.rb
Normal file
45
spec/features/backoffice/onglets_link_spec.rb
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
feature 'on click on tabs button' do
|
||||||
|
let(:administrateur) { create(:administrateur) }
|
||||||
|
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
login_as gestionnaire, scope: :gestionnaire
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when gestionnaire is logged in' do
|
||||||
|
context 'when he click on tabs a traitee' do
|
||||||
|
before do
|
||||||
|
visit backoffice_dossiers_en_attente_url
|
||||||
|
page.click_on 'À traiter (0)'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'it redirect to backoffice dossier termine' do
|
||||||
|
expect(page).to have_css('#backoffice_a_traiter')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when he click on tabs en attente' do
|
||||||
|
before do
|
||||||
|
visit backoffice_dossiers_termine_url
|
||||||
|
page.click_on 'En attente (0)'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'it redirect to backoffice dossier en attente' do
|
||||||
|
expect(page).to have_css('#backoffice_en_attente')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when he click on tabs termine' do
|
||||||
|
before do
|
||||||
|
visit backoffice_dossiers_a_traiter_url
|
||||||
|
page.click_on 'Terminé (0)'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'it redirect to backoffice dossier termine' do
|
||||||
|
expect(page).to have_css('#backoffice_termine')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
21
spec/views/backoffice/dossiers/a_traiter_html.haml_spec.rb
Normal file
21
spec/views/backoffice/dossiers/a_traiter_html.haml_spec.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'backoffice/dossiers/a_traiter.html.haml', type: :view do
|
||||||
|
let(:administrateur) { create(:administrateur) }
|
||||||
|
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) }
|
||||||
|
|
||||||
|
let!(:procedure) { create(:procedure, administrateur: administrateur) }
|
||||||
|
let!(:decorate_dossier) { create(:dossier, :with_user, state: 'initiated', procedure: procedure).decorate }
|
||||||
|
|
||||||
|
before do
|
||||||
|
assign(:dossiers_a_traiter, Dossier.a_traiter(gestionnaire).decorate)
|
||||||
|
render
|
||||||
|
end
|
||||||
|
|
||||||
|
subject { rendered }
|
||||||
|
it { is_expected.to have_css('#backoffice_a_traiter') }
|
||||||
|
it { is_expected.to have_content(procedure.libelle) }
|
||||||
|
it { is_expected.to have_content(decorate_dossier.nom_projet) }
|
||||||
|
it { is_expected.to have_content(decorate_dossier.state_fr) }
|
||||||
|
it { is_expected.to have_content(decorate_dossier.last_update) }
|
||||||
|
end
|
|
@ -1,23 +1,19 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'backoffice/index.html.haml', type: :view do
|
describe 'backoffice/dossiers/en_attente.html.haml', type: :view do
|
||||||
let(:administrateur) { create(:administrateur) }
|
let(:administrateur) { create(:administrateur) }
|
||||||
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) }
|
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) }
|
||||||
|
|
||||||
let!(:procedure) { create(:procedure, administrateur: administrateur) }
|
let!(:procedure) { create(:procedure, administrateur: administrateur) }
|
||||||
let!(:decorate_dossier) { create(:dossier, :with_user, procedure: procedure).decorate }
|
let!(:decorate_dossier) { create(:dossier, :with_user, procedure: procedure, state: 'replied').decorate }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
assign(:dossiers_a_traiter, Dossier.a_traiter(gestionnaire).decorate)
|
|
||||||
assign(:dossiers_en_attente, Dossier.en_attente(gestionnaire).decorate)
|
assign(:dossiers_en_attente, Dossier.en_attente(gestionnaire).decorate)
|
||||||
assign(:dossiers_termine, Dossier.termine(gestionnaire).decorate)
|
|
||||||
|
|
||||||
decorate_dossier.initiated!
|
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { rendered }
|
subject { rendered }
|
||||||
it { is_expected.to have_css('#backoffice') }
|
it { is_expected.to have_css('#backoffice_en_attente') }
|
||||||
it { is_expected.to have_content(procedure.libelle) }
|
it { is_expected.to have_content(procedure.libelle) }
|
||||||
it { is_expected.to have_content(decorate_dossier.nom_projet) }
|
it { is_expected.to have_content(decorate_dossier.nom_projet) }
|
||||||
it { is_expected.to have_content(decorate_dossier.state_fr) }
|
it { is_expected.to have_content(decorate_dossier.state_fr) }
|
21
spec/views/backoffice/dossiers/termine_html.haml_spec.rb
Normal file
21
spec/views/backoffice/dossiers/termine_html.haml_spec.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'backoffice/dossiers/termine.html.haml', type: :view do
|
||||||
|
let(:administrateur) { create(:administrateur) }
|
||||||
|
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) }
|
||||||
|
|
||||||
|
let!(:procedure) { create(:procedure, administrateur: administrateur) }
|
||||||
|
let!(:decorate_dossier) { create(:dossier, :with_user, procedure: procedure, state: 'closed').decorate }
|
||||||
|
|
||||||
|
before do
|
||||||
|
assign(:dossiers_termine, Dossier.termine(gestionnaire).decorate)
|
||||||
|
render
|
||||||
|
end
|
||||||
|
|
||||||
|
subject { rendered }
|
||||||
|
it { is_expected.to have_css('#backoffice_termine') }
|
||||||
|
it { is_expected.to have_content(procedure.libelle) }
|
||||||
|
it { is_expected.to have_content(decorate_dossier.nom_projet) }
|
||||||
|
it { is_expected.to have_content(decorate_dossier.state_fr) }
|
||||||
|
it { is_expected.to have_content(decorate_dossier.last_update) }
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue