- Delete routes 'users/dossiers/a_traiter - en_attente - termine' for user
- Add routes 'uses/dossiers/?liste=xxx' to reach at file lists for user
This commit is contained in:
parent
5cebb5b621
commit
3e55d7ba3b
18 changed files with 126 additions and 135 deletions
|
@ -1,34 +1,35 @@
|
||||||
class Backoffice::DossiersController < ApplicationController
|
class Backoffice::DossiersController < ApplicationController
|
||||||
before_action :authenticate_gestionnaire!
|
before_action :authenticate_gestionnaire!
|
||||||
|
|
||||||
|
def index
|
||||||
|
if params[:liste] == 'a_traiter' || params[:liste].nil?
|
||||||
|
@dossiers = current_gestionnaire.dossiers.waiting_for_gestionnaire
|
||||||
|
@dossiers_a_traiter = @dossiers
|
||||||
|
|
||||||
|
@liste = 'a_traiter'
|
||||||
|
|
||||||
|
elsif params[:liste] == 'en_attente'
|
||||||
|
@dossiers = current_gestionnaire.dossiers.waiting_for_user
|
||||||
|
@dossiers_en_attente = @dossiers
|
||||||
|
|
||||||
|
@liste = 'en_attente'
|
||||||
|
|
||||||
|
elsif params[:liste] == 'termine'
|
||||||
|
|
||||||
|
@dossiers = current_gestionnaire.dossiers.termine
|
||||||
|
@dossiers_termine = @dossiers
|
||||||
|
|
||||||
|
@liste = 'termine'
|
||||||
|
end
|
||||||
|
|
||||||
|
@dossiers = @dossiers.paginate(:page => (params[:page] || 1)).decorate
|
||||||
|
total_dossiers_per_state
|
||||||
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
initialize_instance_params params[:id]
|
initialize_instance_params params[:id]
|
||||||
end
|
end
|
||||||
|
|
||||||
def a_traiter
|
|
||||||
@dossiers = current_gestionnaire.dossiers.waiting_for_gestionnaire
|
|
||||||
.paginate(:page => params[:page]).decorate
|
|
||||||
|
|
||||||
@page = 'a_traiter'
|
|
||||||
total_dossiers_per_state
|
|
||||||
end
|
|
||||||
|
|
||||||
def en_attente
|
|
||||||
@dossiers = current_gestionnaire.dossiers.waiting_for_user()
|
|
||||||
.paginate(:page => params[:page]).decorate
|
|
||||||
|
|
||||||
@page = 'en_attente'
|
|
||||||
total_dossiers_per_state
|
|
||||||
end
|
|
||||||
|
|
||||||
def termine
|
|
||||||
@dossiers = current_gestionnaire.dossiers.termine()
|
|
||||||
.paginate(:page => params[:page]).decorate
|
|
||||||
|
|
||||||
@page = 'termine'
|
|
||||||
total_dossiers_per_state
|
|
||||||
end
|
|
||||||
|
|
||||||
def search
|
def search
|
||||||
@search_terms = params[:q]
|
@search_terms = params[:q]
|
||||||
|
|
||||||
|
|
|
@ -4,7 +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
|
||||||
redirect_to(:backoffice_dossiers_a_traiter)
|
redirect_to(:backoffice_dossiers)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -4,7 +4,7 @@ class RootController < ApplicationController
|
||||||
if user_signed_in?
|
if user_signed_in?
|
||||||
redirect_to users_dossiers_path
|
redirect_to users_dossiers_path
|
||||||
elsif gestionnaire_signed_in?
|
elsif gestionnaire_signed_in?
|
||||||
redirect_to backoffice_path
|
redirect_to backoffice_dossiers_path
|
||||||
elsif administrateur_signed_in?
|
elsif administrateur_signed_in?
|
||||||
redirect_to admin_procedures_path
|
redirect_to admin_procedures_path
|
||||||
else
|
else
|
||||||
|
|
|
@ -3,20 +3,20 @@
|
||||||
|
|
||||||
#onglets
|
#onglets
|
||||||
%ul.nav.nav-tabs
|
%ul.nav.nav-tabs
|
||||||
%li{ class: (@dossiers.active_class_a_traiter(@page) unless @dossiers.nil?) }
|
%li{ class: (@dossiers.active_class_a_traiter(@liste) unless @dossiers.nil?) }
|
||||||
%a{:href => "#{url_for :backoffice_dossiers_a_traiter}" }
|
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'a_traiter')}"}
|
||||||
%h5.text-danger
|
%h5.text-danger
|
||||||
= "À traiter "
|
= "À traiter "
|
||||||
.badge.progress-bar-danger
|
.badge.progress-bar-danger
|
||||||
=@dossiers_a_traiter_total
|
=@dossiers_a_traiter_total
|
||||||
%li{ class: (@dossiers.active_class_en_attente(@page) unless @dossiers.nil?) }
|
%li{ class: (@dossiers.active_class_en_attente(@liste) unless @dossiers.nil?) }
|
||||||
%a{:href => "#{url_for :backoffice_dossiers_en_attente}" }
|
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'en_attente')}"}
|
||||||
%h5.text-info
|
%h5.text-info
|
||||||
="En attente "
|
="En attente "
|
||||||
.badge.progress-bar-info
|
.badge.progress-bar-info
|
||||||
=@dossiers_en_attente_total
|
=@dossiers_en_attente_total
|
||||||
%li{ class: (@dossiers.active_class_termine(@page) unless @dossiers.nil?) }
|
%li{ class: (@dossiers.active_class_termine(@liste) unless @dossiers.nil?) }
|
||||||
%a{ :href => "#{url_for :backoffice_dossiers_termine}" }
|
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'termine')}"}
|
||||||
%h5.text-success
|
%h5.text-success
|
||||||
= "Terminé"
|
= "Terminé"
|
||||||
.badge.progress-bar-success
|
.badge.progress-bar-success
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
#backoffice_a_traiter
|
|
||||||
= render partial: 'onglets'
|
|
||||||
|
|
||||||
= render partial: 'list'
|
|
|
@ -1,4 +0,0 @@
|
||||||
#backoffice_en_attente
|
|
||||||
= render partial: 'onglets'
|
|
||||||
|
|
||||||
= render partial: 'list'
|
|
|
@ -1,4 +1,4 @@
|
||||||
#backoffice_termine
|
#backoffice_index
|
||||||
= render partial: 'onglets'
|
= render partial: 'onglets'
|
||||||
|
|
||||||
= render partial: 'list'
|
= render partial: 'list'
|
|
@ -69,9 +69,6 @@ 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'
|
|
||||||
get 'dossiers/search' => 'dossiers#search'
|
get 'dossiers/search' => 'dossiers#search'
|
||||||
|
|
||||||
resources :dossiers do
|
resources :dossiers do
|
||||||
|
|
|
@ -43,7 +43,7 @@ describe Backoffice::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
get :a_traiter
|
get :index, liste: :a_traiter
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -56,7 +56,7 @@ describe Backoffice::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
get :en_attente
|
get :index, liste: :en_attente
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -69,7 +69,7 @@ describe Backoffice::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
get :termine
|
get :index, liste: :termine
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe BackofficeController, type: :controller do
|
||||||
get :index
|
get :index
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(response).to redirect_to :backoffice_dossiers_a_traiter }
|
it { expect(response).to redirect_to :backoffice_dossiers }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -17,7 +17,7 @@ describe RootController, type: :controller do
|
||||||
sign_in create(:gestionnaire)
|
sign_in create(:gestionnaire)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(subject).to redirect_to(backoffice_path) }
|
it { expect(subject).to redirect_to(backoffice_dossiers_path) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when Administrateur is connected' do
|
context 'when Administrateur is connected' do
|
||||||
|
|
|
@ -29,7 +29,7 @@ feature 'when gestionnaire come to /backoffice and is not authenticated' do
|
||||||
page.click_on 'Se connecter'
|
page.click_on 'Se connecter'
|
||||||
end
|
end
|
||||||
scenario 'he is redirected to /backoffice' do
|
scenario 'he is redirected to /backoffice' do
|
||||||
expect(page).to have_css('#backoffice_a_traiter')
|
expect(page).to have_css('#backoffice_index')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -11,34 +11,34 @@ feature 'on click on tabs button' do
|
||||||
context 'when gestionnaire is logged in' do
|
context 'when gestionnaire is logged in' do
|
||||||
context 'when he click on tabs a traitee' do
|
context 'when he click on tabs a traitee' do
|
||||||
before do
|
before do
|
||||||
visit backoffice_dossiers_en_attente_url
|
visit backoffice_dossiers_url(liste: :a_traiter)
|
||||||
page.click_on 'À traiter 0'
|
page.click_on 'À traiter 0'
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'it redirect to backoffice dossier termine' do
|
scenario 'it redirect to backoffice dossier termine' do
|
||||||
expect(page).to have_css('#backoffice_a_traiter')
|
expect(page).to have_css('#backoffice_index')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when he click on tabs en attente' do
|
context 'when he click on tabs en attente' do
|
||||||
before do
|
before do
|
||||||
visit backoffice_dossiers_termine_url
|
visit backoffice_dossiers_url(liste: :en_attente)
|
||||||
page.click_on 'En attente 0'
|
page.click_on 'En attente 0'
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'it redirect to backoffice dossier en attente' do
|
scenario 'it redirect to backoffice dossier en attente' do
|
||||||
expect(page).to have_css('#backoffice_en_attente')
|
expect(page).to have_css('#backoffice_index')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when he click on tabs termine' do
|
context 'when he click on tabs termine' do
|
||||||
before do
|
before do
|
||||||
visit backoffice_dossiers_a_traiter_url
|
visit backoffice_dossiers_url(liste: :termine)
|
||||||
page.click_on 'Terminé 0'
|
page.click_on 'Terminé 0'
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'it redirect to backoffice dossier termine' do
|
scenario 'it redirect to backoffice dossier termine' do
|
||||||
expect(page).to have_css('#backoffice_termine')
|
expect(page).to have_css('#backoffice_index')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ feature 'search file on gestionnaire backoffice' do
|
||||||
let(:terms) { '' }
|
let(:terms) { '' }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
visit backoffice_dossiers_a_traiter_url
|
visit backoffice_dossiers_url
|
||||||
page.find_by_id(:q).set terms
|
page.find_by_id(:q).set terms
|
||||||
page.find_by_id(:search_button).click
|
page.find_by_id(:search_button).click
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
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, gestionnaire.dossiers.waiting_for_gestionnaire.paginate(:page => 1).decorate)
|
|
||||||
assign(:page, 'a_traiter')
|
|
||||||
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) }
|
|
||||||
|
|
||||||
describe 'active tab' do
|
|
||||||
it { is_expected.to have_selector('.active .text-danger') }
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,26 +0,0 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe 'backoffice/dossiers/en_attente.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: 'replied').decorate }
|
|
||||||
|
|
||||||
before do
|
|
||||||
assign(:dossiers, gestionnaire.dossiers.waiting_for_user.paginate(:page => 1).decorate)
|
|
||||||
assign(:page, 'en_attente')
|
|
||||||
render
|
|
||||||
end
|
|
||||||
|
|
||||||
subject { rendered }
|
|
||||||
it { is_expected.to have_css('#backoffice_en_attente') }
|
|
||||||
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) }
|
|
||||||
|
|
||||||
describe 'active tab' do
|
|
||||||
it { is_expected.to have_selector('.active .text-info') }
|
|
||||||
end
|
|
||||||
end
|
|
79
spec/views/backoffice/dossiers/index_html.haml_spec.rb
Normal file
79
spec/views/backoffice/dossiers/index_html.haml_spec.rb
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'backoffice/dossiers/index.html.haml', type: :view do
|
||||||
|
let(:administrateur) { create(:administrateur) }
|
||||||
|
let(:gestionnaire) { create(:gestionnaire, administrateur: administrateur) }
|
||||||
|
|
||||||
|
let!(:procedure) { create(:procedure, administrateur: administrateur) }
|
||||||
|
let!(:decorate_dossier_initiated) { create(:dossier, :with_user, procedure: procedure, nom_projet: 'projet initiated', state: 'initiated').decorate }
|
||||||
|
let!(:decorate_dossier_replied) { create(:dossier, :with_user, procedure: procedure, nom_projet: 'projet replied', state: 'replied').decorate }
|
||||||
|
let!(:decorate_dossier_closed) { create(:dossier, :with_user, procedure: procedure, nom_projet: 'projet closed', state: 'closed').decorate }
|
||||||
|
|
||||||
|
|
||||||
|
describe 'on tab a_traiter' do
|
||||||
|
before do
|
||||||
|
assign(:dossiers, gestionnaire.dossiers.waiting_for_gestionnaire.paginate(:page => 1).decorate)
|
||||||
|
assign(:liste, 'a_traiter')
|
||||||
|
render
|
||||||
|
end
|
||||||
|
|
||||||
|
subject { rendered }
|
||||||
|
it { is_expected.to have_css('#backoffice_index') }
|
||||||
|
it { is_expected.to have_content(procedure.libelle) }
|
||||||
|
it { is_expected.to have_content(decorate_dossier_initiated.nom_projet) }
|
||||||
|
it { is_expected.to have_content(decorate_dossier_initiated.state_fr) }
|
||||||
|
it { is_expected.to have_content(decorate_dossier_initiated.last_update) }
|
||||||
|
|
||||||
|
it { is_expected.not_to have_content(decorate_dossier_replied.nom_projet) }
|
||||||
|
it { is_expected.not_to have_content(decorate_dossier_closed.nom_projet) }
|
||||||
|
|
||||||
|
describe 'active tab' do
|
||||||
|
it { is_expected.to have_selector('.active .text-danger') }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
describe 'on tab en_attente' do
|
||||||
|
before do
|
||||||
|
assign(:dossiers, gestionnaire.dossiers.waiting_for_user.paginate(:page => 1).decorate)
|
||||||
|
assign(:liste, 'en_attente')
|
||||||
|
render
|
||||||
|
end
|
||||||
|
|
||||||
|
subject { rendered }
|
||||||
|
it { is_expected.to have_css('#backoffice_index') }
|
||||||
|
it { is_expected.to have_content(procedure.libelle) }
|
||||||
|
it { is_expected.to have_content(decorate_dossier_replied.nom_projet) }
|
||||||
|
it { is_expected.to have_content(decorate_dossier_replied.state_fr) }
|
||||||
|
it { is_expected.to have_content(decorate_dossier_replied.last_update) }
|
||||||
|
|
||||||
|
it { is_expected.not_to have_content(decorate_dossier_initiated.nom_projet) }
|
||||||
|
it { is_expected.not_to have_content(decorate_dossier_closed.nom_projet) }
|
||||||
|
|
||||||
|
describe 'active tab' do
|
||||||
|
it { is_expected.to have_selector('.active .text-info') }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'on tab termine' do
|
||||||
|
before do
|
||||||
|
assign(:dossiers, gestionnaire.dossiers.termine.paginate(:page => 1).decorate)
|
||||||
|
assign(:liste, 'termine')
|
||||||
|
render
|
||||||
|
end
|
||||||
|
|
||||||
|
subject { rendered }
|
||||||
|
it { is_expected.to have_css('#backoffice_index') }
|
||||||
|
it { is_expected.to have_content(procedure.libelle) }
|
||||||
|
it { is_expected.to have_content(decorate_dossier_closed.nom_projet) }
|
||||||
|
it { is_expected.to have_content(decorate_dossier_closed.state_fr) }
|
||||||
|
it { is_expected.to have_content(decorate_dossier_closed.last_update) }
|
||||||
|
|
||||||
|
it { is_expected.not_to have_content(decorate_dossier_initiated.nom_projet) }
|
||||||
|
it { is_expected.not_to have_content(decorate_dossier_replied.nom_projet) }
|
||||||
|
|
||||||
|
describe 'active tab' do
|
||||||
|
it { is_expected.to have_selector('.active .text-success') }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,26 +0,0 @@
|
||||||
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, gestionnaire.dossiers.termine.paginate(:page => 1).decorate)
|
|
||||||
assign(:page, 'termine')
|
|
||||||
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) }
|
|
||||||
|
|
||||||
describe 'active tab' do
|
|
||||||
it { is_expected.to have_selector('.active .text-success') }
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue