Add tabs on view list file for users
This commit is contained in:
parent
f449be5c4e
commit
da49c633dc
22 changed files with 242 additions and 85 deletions
|
@ -6,20 +6,20 @@ class Backoffice::DossiersController < ApplicationController
|
|||
end
|
||||
|
||||
def a_traiter
|
||||
@dossiers_a_traiter = Dossier.a_traiter(current_gestionnaire)
|
||||
@dossiers_a_traiter = current_gestionnaire.dossiers.waiting_for_gestionnaire()
|
||||
@dossiers_a_traiter = @dossiers_a_traiter.paginate(:page => params[:page], :per_page => 12).decorate
|
||||
|
||||
total_dossiers_per_state
|
||||
end
|
||||
|
||||
def en_attente
|
||||
@dossiers_en_attente = Dossier.en_attente(current_gestionnaire)
|
||||
@dossiers_en_attente = current_gestionnaire.dossiers.waiting_for_user()
|
||||
@dossiers_en_attente = @dossiers_en_attente.paginate(:page => params[:page], :per_page => 12).decorate
|
||||
total_dossiers_per_state
|
||||
end
|
||||
|
||||
def termine
|
||||
@dossiers_termine = Dossier.termine(current_gestionnaire)
|
||||
@dossiers_termine = current_gestionnaire.dossiers.termine()
|
||||
@dossiers_termine = @dossiers_termine.paginate(:page => params[:page], :per_page => 12).decorate
|
||||
total_dossiers_per_state
|
||||
end
|
||||
|
@ -61,9 +61,9 @@ class Backoffice::DossiersController < ApplicationController
|
|||
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
|
||||
@dossiers_a_traiter_total = !@dossiers_a_traiter.nil? ? @dossiers_a_traiter.size : current_gestionnaire.dossiers.waiting_for_gestionnaire().size
|
||||
@dossiers_en_attente_total = !@dossiers_en_attente.nil? ? @dossiers_en_attente.size : current_gestionnaire.dossiers.waiting_for_user().size
|
||||
@dossiers_termine_total = !@dossiers_termine.nil? ? @dossiers_termine.size : current_gestionnaire.dossiers.termine().size
|
||||
end
|
||||
|
||||
def initialize_instance_params dossier_id
|
||||
|
|
|
@ -1,16 +1,6 @@
|
|||
class Users::DossiersController < UsersController
|
||||
before_action :authenticate_user!
|
||||
|
||||
def index
|
||||
@dossiers = current_user.dossiers.where.not(state: :draft).where(archived: false).order(updated_at: 'DESC')
|
||||
|
||||
if params[:page].nil?
|
||||
params[:page] = 1
|
||||
end
|
||||
|
||||
@dossiers = @dossiers.paginate(:page => params[:page], :per_page => 12).decorate
|
||||
end
|
||||
|
||||
def show
|
||||
@dossier = current_user_dossier params[:id]
|
||||
|
||||
|
@ -90,6 +80,36 @@ class Users::DossiersController < UsersController
|
|||
redirect_to users_dossiers_path
|
||||
end
|
||||
|
||||
def a_traiter
|
||||
@dossiers_a_traiter = current_user.dossiers.waiting_for_user
|
||||
@dossiers = @dossiers_a_traiter
|
||||
|
||||
params[:page] = 1 if params[:page].nil?
|
||||
|
||||
@dossiers = @dossiers.paginate(:page => params[:page], :per_page => 12).decorate
|
||||
total_dossiers_per_state
|
||||
end
|
||||
|
||||
def en_attente
|
||||
@dossiers_en_attente = current_user.dossiers.waiting_for_gestionnaire
|
||||
@dossiers = @dossiers_en_attente
|
||||
|
||||
params[:page] = 1 if params[:page].nil?
|
||||
|
||||
@dossiers = @dossiers.paginate(:page => params[:page], :per_page => 12).decorate
|
||||
total_dossiers_per_state
|
||||
end
|
||||
|
||||
def termine
|
||||
@dossiers_termine = current_user.dossiers.termine
|
||||
@dossiers = @dossiers_termine
|
||||
|
||||
params[:page] = 1 if params[:page].nil?
|
||||
|
||||
@dossiers = @dossiers.paginate(:page => params[:page], :per_page => 12).decorate
|
||||
total_dossiers_per_state
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_params
|
||||
|
@ -111,4 +131,10 @@ class Users::DossiersController < UsersController
|
|||
def siren
|
||||
siret[0..8]
|
||||
end
|
||||
|
||||
def total_dossiers_per_state
|
||||
@dossiers_a_traiter_total = !@dossiers_a_traiter.nil? ? @dossiers_a_traiter.size : current_user.dossiers.waiting_for_user().size
|
||||
@dossiers_en_attente_total = !@dossiers_en_attente.nil? ? @dossiers_en_attente.size : current_user.dossiers.waiting_for_gestionnaire().size
|
||||
@dossiers_termine_total = !@dossiers_termine.nil? ? @dossiers_termine.size : current_user.dossiers.termine().size
|
||||
end
|
||||
end
|
||||
|
|
|
@ -34,8 +34,8 @@ class DossierDecorator < Draper::Decorator
|
|||
end
|
||||
|
||||
def state_color_class
|
||||
return 'text-danger' if a_traiter?
|
||||
return 'text-info' if en_attente?
|
||||
return 'text-danger' if waiting_for_gestionnaire?
|
||||
return 'text-info' if waiting_for_user?
|
||||
return 'text-success' if termine?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,8 +31,8 @@ class Dossier < ActiveRecord::Base
|
|||
validates :description, presence: true, allow_blank: false, allow_nil: true
|
||||
validates :user, presence: true
|
||||
|
||||
A_TRAITER = %w(initiated updated submitted)
|
||||
EN_ATTENTE = %w(replied validated)
|
||||
WAITING_FOR_GESTIONNAIRE = %w(initiated updated submitted)
|
||||
WAITING_FOR_USER = %w(replied validated)
|
||||
TERMINE = %w(closed)
|
||||
|
||||
def retrieve_piece_justificative_by_type(type)
|
||||
|
@ -121,28 +121,28 @@ class Dossier < ActiveRecord::Base
|
|||
state
|
||||
end
|
||||
|
||||
def a_traiter?
|
||||
A_TRAITER.include?(state)
|
||||
def waiting_for_gestionnaire?
|
||||
WAITING_FOR_GESTIONNAIRE.include?(state)
|
||||
end
|
||||
|
||||
def en_attente?
|
||||
EN_ATTENTE.include?(state)
|
||||
def waiting_for_user?
|
||||
WAITING_FOR_USER.include?(state)
|
||||
end
|
||||
|
||||
def termine?
|
||||
TERMINE.include?(state)
|
||||
end
|
||||
|
||||
def self.a_traiter current_gestionnaire
|
||||
current_gestionnaire.dossiers.where(state: A_TRAITER, archived: false).order('updated_at ASC')
|
||||
def self.waiting_for_gestionnaire
|
||||
where(state: WAITING_FOR_GESTIONNAIRE, archived: false).order('updated_at ASC')
|
||||
end
|
||||
|
||||
def self.en_attente current_gestionnaire
|
||||
current_gestionnaire.dossiers.where(state: EN_ATTENTE, archived: false).order('updated_at ASC')
|
||||
def self.waiting_for_user
|
||||
where(state: WAITING_FOR_USER, archived: false).order('updated_at ASC')
|
||||
end
|
||||
|
||||
def self.termine current_gestionnaire
|
||||
current_gestionnaire.dossiers.where(state: TERMINE, archived: false).order('updated_at ASC')
|
||||
def self.termine
|
||||
where(state: TERMINE, archived: false).order('updated_at ASC')
|
||||
end
|
||||
|
||||
def self.search current_gestionnaire, terms
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
= @dossier.user.email
|
||||
%td.col-md-2.col-lg-2
|
||||
= @dossier.etablissement.siret
|
||||
%td.col-md-1.col-lg-1
|
||||
%td.col-md-1.col-lg-1{class: @dossier.state_color_class}
|
||||
= @dossier.state_fr
|
||||
%br
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
%head
|
||||
%meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
|
||||
%title TPS - Téléprocédures simplifiées
|
||||
%meta{'http-equiv' => "X-UA-Compatible", :content => "IE=edge"}
|
||||
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
|
||||
= javascript_include_tag 'application', 'data-turbolinks-track' => true
|
||||
= csrf_meta_tags
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
%h1#users_dossiers_index Vos dossiers
|
||||
%br
|
||||
%br
|
||||
%table.table
|
||||
%thead
|
||||
%th Procédure
|
24
app/views/users/dossiers/_onglets.html.haml
Normal file
24
app/views/users/dossiers/_onglets.html.haml
Normal file
|
@ -0,0 +1,24 @@
|
|||
%h1 Mes dossiers
|
||||
%br
|
||||
|
||||
#onglets
|
||||
%ul.nav.nav-tabs
|
||||
%li{class: "#{'active' unless @dossiers_a_traiter.nil? }"}
|
||||
%a{:href => "#{url_for :users_dossiers_a_traiter}"}
|
||||
%h5.text-danger
|
||||
= "À traiter "
|
||||
.badge.progress-bar-danger
|
||||
= @dossiers_a_traiter_total
|
||||
%li{class: "#{'active' unless @dossiers_en_attente.nil? }"}
|
||||
%a{:href => "#{url_for :users_dossiers_en_attente}"}
|
||||
%h5.text-info
|
||||
="En attente "
|
||||
.badge.progress-bar-info
|
||||
= @dossiers_en_attente_total
|
||||
%li{class: "#{'active' unless @dossiers_termine.nil? }"}
|
||||
%a{:href => "#{url_for :users_dossiers_termine}"}
|
||||
%h5.text-success
|
||||
= "Terminé"
|
||||
.badge.progress-bar-success
|
||||
= @dossiers_termine_total
|
||||
%br
|
4
app/views/users/dossiers/a_traiter.html.haml
Normal file
4
app/views/users/dossiers/a_traiter.html.haml
Normal file
|
@ -0,0 +1,4 @@
|
|||
#users_a_traiter
|
||||
= render partial: 'onglets'
|
||||
|
||||
= render partial: 'list'
|
4
app/views/users/dossiers/en_attente.html.haml
Normal file
4
app/views/users/dossiers/en_attente.html.haml
Normal file
|
@ -0,0 +1,4 @@
|
|||
#users_en_attente
|
||||
= render partial: 'onglets'
|
||||
|
||||
= render partial: 'list'
|
4
app/views/users/dossiers/termine.html.haml
Normal file
4
app/views/users/dossiers/termine.html.haml
Normal file
|
@ -0,0 +1,4 @@
|
|||
#users_termine
|
||||
= render partial: 'onglets'
|
||||
|
||||
= render partial: 'list'
|
|
@ -24,7 +24,12 @@ Rails.application.routes.draw do
|
|||
get 'siret' => 'siret#index'
|
||||
get 'procedure/:procedure_id' => 'procedure#index'
|
||||
|
||||
get 'dossiers/a_traiter' => 'dossiers#a_traiter'
|
||||
get 'dossiers/en_attente' => 'dossiers#en_attente'
|
||||
get 'dossiers/termine' => 'dossiers#termine'
|
||||
|
||||
resources :dossiers do
|
||||
|
||||
get '/description' => 'description#show'
|
||||
get '/description/error' => 'description#error'
|
||||
post 'description' => 'description#create'
|
||||
|
|
|
@ -3,23 +3,6 @@ require 'spec_helper'
|
|||
describe Users::DossiersController, type: :controller do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
describe 'GET #index' do
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, :with_procedure, user: user) }
|
||||
subject { get :index }
|
||||
|
||||
context 'when user is not logged in' do
|
||||
it { is_expected.to redirect_to('/users/sign_in') }
|
||||
end
|
||||
|
||||
context 'when user is logged in' do
|
||||
before do
|
||||
sign_in create(:user)
|
||||
end
|
||||
it { is_expected.to render_template('users/dossiers/index') }
|
||||
it { is_expected.to have_http_status(:success) }
|
||||
end
|
||||
end
|
||||
|
||||
let(:use_api_carto) { false }
|
||||
let(:procedure) { create(:procedure, use_api_carto: use_api_carto) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
|
||||
|
@ -210,4 +193,43 @@ describe Users::DossiersController, type: :controller do
|
|||
it { expect(flash[:alert]).to have_content 'Dossier inéxistant' }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #a_traiter' do
|
||||
context 'when user is connected' do
|
||||
before do
|
||||
sign_in user
|
||||
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 user is connected' do
|
||||
before do
|
||||
sign_in user
|
||||
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 user is connected' do
|
||||
before do
|
||||
sign_in user
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
get :termine
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -402,20 +402,20 @@ describe Dossier do
|
|||
let!(:dossier11) { create(:dossier, :with_user, procedure: procedure_admin, state: 'replied', archived: true) } #en_attente #archived
|
||||
let!(:dossier12) { create(:dossier, :with_user, procedure: procedure_admin, state: 'closed', archived: true) } #termine #archived
|
||||
|
||||
describe '#a_traiter' do
|
||||
subject { described_class.a_traiter gestionnaire }
|
||||
describe '#waiting_for_gestionnaire' do
|
||||
subject { gestionnaire.dossiers.waiting_for_gestionnaire }
|
||||
|
||||
it { expect(subject.size).to eq(3) }
|
||||
end
|
||||
|
||||
describe '#en_attente' do
|
||||
subject { described_class.en_attente gestionnaire }
|
||||
describe '#waiting_for_user' do
|
||||
subject { gestionnaire.dossiers.waiting_for_user }
|
||||
|
||||
it { expect(subject.size).to eq(1) }
|
||||
end
|
||||
|
||||
describe '#termine' do
|
||||
subject { described_class.termine gestionnaire }
|
||||
subject { gestionnaire.dossiers.termine }
|
||||
|
||||
it { expect(subject.size).to eq(1) }
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ describe 'admin/procedures/show.html.haml', type: :view do
|
|||
context 'when procedure is archived' do
|
||||
let(:procedure) { create(:procedure, archived: true) }
|
||||
|
||||
it { expect(rendered).to have_content('Activer') }
|
||||
it { expect(rendered).to have_content('Réactiver') }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -8,7 +8,7 @@ describe 'backoffice/dossiers/a_traiter.html.haml', type: :view do
|
|||
let!(:decorate_dossier) { create(:dossier, :with_user, state: 'initiated', procedure: procedure).decorate }
|
||||
|
||||
before do
|
||||
assign(:dossiers_a_traiter, Dossier.a_traiter(gestionnaire).paginate(:page => 1, :per_page => 12).decorate)
|
||||
assign(:dossiers_a_traiter, gestionnaire.dossiers.waiting_for_gestionnaire.paginate(:page => 1, :per_page => 12).decorate)
|
||||
render
|
||||
end
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ describe 'backoffice/dossiers/en_attente.html.haml', type: :view do
|
|||
let!(:decorate_dossier) { create(:dossier, :with_user, procedure: procedure, state: 'replied').decorate }
|
||||
|
||||
before do
|
||||
assign(:dossiers_en_attente, Dossier.en_attente(gestionnaire).paginate(:page => 1, :per_page => 12).decorate)
|
||||
assign(:dossiers_en_attente, gestionnaire.dossiers.waiting_for_user.paginate(:page => 1, :per_page => 12).decorate)
|
||||
render
|
||||
end
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ describe 'backoffice/dossiers/termine.html.haml', type: :view do
|
|||
let!(:decorate_dossier) { create(:dossier, :with_user, procedure: procedure, state: 'closed').decorate }
|
||||
|
||||
before do
|
||||
assign(:dossiers_termine, Dossier.termine(gestionnaire).paginate(:page => 1, :per_page => 12).decorate)
|
||||
assign(:dossiers_termine, gestionnaire.dossiers.termine.paginate(:page => 1, :per_page => 12).decorate)
|
||||
render
|
||||
end
|
||||
|
||||
|
|
31
spec/views/users/dossiers/a_traiter_html.haml_spec.rb
Normal file
31
spec/views/users/dossiers/a_traiter_html.haml_spec.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/dossiers/a_traiter.html.haml', type: :view do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
let!(:decorate_dossier) { create(:dossier, :with_procedure, user: user, state: 'replied').decorate }
|
||||
let!(:decorate_dossier_2) { create(:dossier, :with_procedure, user: user, state: 'initiated', nom_projet: 'projet de test').decorate }
|
||||
|
||||
let(:dossiers_list) { user.dossiers.waiting_for_user.paginate(:page => 1, :per_page => 12).decorate }
|
||||
|
||||
before do
|
||||
assign(:dossiers, dossiers_list)
|
||||
assign(:dossiers_a_traiter, dossiers_list)
|
||||
render
|
||||
end
|
||||
|
||||
subject { rendered }
|
||||
|
||||
it { is_expected.to have_css('#users_a_traiter') }
|
||||
|
||||
describe 'dossier replied is present' do
|
||||
it { is_expected.to have_content(decorate_dossier.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
|
||||
|
||||
describe 'dossier initiated is not present' do
|
||||
it { is_expected.not_to have_content(decorate_dossier_2.nom_projet) }
|
||||
end
|
||||
end
|
31
spec/views/users/dossiers/en_attente_html.haml_spec.rb
Normal file
31
spec/views/users/dossiers/en_attente_html.haml_spec.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/dossiers/en_attente.html.haml', type: :view do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
let!(:decorate_dossier) { create(:dossier, :with_procedure, user: user, state: 'initiated', nom_projet: 'projet de test').decorate }
|
||||
let!(:decorate_dossier_2) { create(:dossier, :with_procedure, user: user, state: 'replied').decorate }
|
||||
|
||||
let(:dossiers_list) { user.dossiers.waiting_for_gestionnaire.paginate(:page => 1, :per_page => 12).decorate }
|
||||
|
||||
before do
|
||||
assign(:dossiers, dossiers_list)
|
||||
assign(:dossiers_en_attente, dossiers_list)
|
||||
render
|
||||
end
|
||||
|
||||
subject { rendered }
|
||||
|
||||
it { is_expected.to have_css('#users_en_attente') }
|
||||
|
||||
describe 'dossier initiated is present' do
|
||||
it { is_expected.to have_content(decorate_dossier.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
|
||||
|
||||
describe 'dossier replied is not present' do
|
||||
it { is_expected.not_to have_content(decorate_dossier_2.nom_projet) }
|
||||
end
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/dossiers/index.html.haml', type: :view do
|
||||
|
||||
describe 'list dossiers' do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
let!(:dossier1) { create(:dossier, :with_procedure, user: user, state: 'initiated') }
|
||||
let!(:dossier2) { create(:dossier, :with_procedure, user: user, nom_projet: 'projet de test', state: 'draft') }
|
||||
let!(:dossier3) { create(:dossier, :with_procedure, user: user, nom_projet: 'projet de test 2', state: 'initiated', archived: true) }
|
||||
|
||||
let(:dossiers) { user.dossiers.where.not(state: :draft).where(archived: false).order(updated_at: 'DESC') }
|
||||
|
||||
before do
|
||||
assign(:dossiers, dossiers.paginate(:page => params[:page], :per_page => 12).decorate)
|
||||
render
|
||||
end
|
||||
|
||||
subject { rendered }
|
||||
|
||||
it { expect(subject).to have_content(dossier1.nom_projet) }
|
||||
it { expect(subject).not_to have_content(dossier2.nom_projet) }
|
||||
it { expect(subject).not_to have_content(dossier3.nom_projet) }
|
||||
end
|
||||
end
|
33
spec/views/users/dossiers/termine_html.haml_spec.rb
Normal file
33
spec/views/users/dossiers/termine_html.haml_spec.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/dossiers/termine.html.haml', type: :view do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
let!(:decorate_dossier) { create(:dossier, :with_procedure, user: user, state: 'initiated', nom_projet: 'projet de test').decorate }
|
||||
let!(:decorate_dossier_2) { create(:dossier, :with_procedure, user: user, state: 'replied', nom_projet: 'projet terminé').decorate }
|
||||
let!(:dossier_termine) { create(:dossier, :with_procedure, user: user, state: 'closed').decorate }
|
||||
|
||||
let(:dossiers_list) { user.dossiers.termine.paginate(:page => 1, :per_page => 12).decorate }
|
||||
|
||||
before do
|
||||
assign(:dossiers, dossiers_list)
|
||||
assign(:dossiers_en_attente, dossiers_list)
|
||||
render
|
||||
end
|
||||
|
||||
subject { rendered }
|
||||
|
||||
it { is_expected.to have_css('#users_termine') }
|
||||
|
||||
describe 'dossier termine is present' do
|
||||
it { is_expected.to have_content(dossier_termine.procedure.libelle) }
|
||||
it { is_expected.to have_content(dossier_termine.nom_projet) }
|
||||
it { is_expected.to have_content(dossier_termine.state_fr) }
|
||||
it { is_expected.to have_content(dossier_termine.last_update) }
|
||||
end
|
||||
|
||||
describe 'dossier replied and initiated are not present' do
|
||||
it { is_expected.not_to have_content(decorate_dossier.nom_projet) }
|
||||
it { is_expected.not_to have_content(decorate_dossier_2.nom_projet) }
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue