- add test on active tab for back office
- refactor code back office file list - add decorator for select active tabs
This commit is contained in:
parent
91cf5020fc
commit
a3df5a546d
10 changed files with 68 additions and 69 deletions
|
@ -6,21 +6,26 @@ class Backoffice::DossiersController < ApplicationController
|
|||
end
|
||||
|
||||
def a_traiter
|
||||
@dossiers_a_traiter = current_gestionnaire.dossiers.waiting_for_gestionnaire()
|
||||
@dossiers_a_traiter = @dossiers_a_traiter.paginate(:page => params[:page]).decorate
|
||||
@dossiers = current_gestionnaire.dossiers.waiting_for_gestionnaire
|
||||
.paginate(:page => params[:page]).decorate
|
||||
|
||||
@page = 'a_traiter'
|
||||
total_dossiers_per_state
|
||||
end
|
||||
|
||||
def en_attente
|
||||
@dossiers_en_attente = current_gestionnaire.dossiers.waiting_for_user()
|
||||
@dossiers_en_attente = @dossiers_en_attente.paginate(:page => params[:page]).decorate
|
||||
@dossiers = current_gestionnaire.dossiers.waiting_for_user()
|
||||
.paginate(:page => params[:page]).decorate
|
||||
|
||||
@page = 'en_attente'
|
||||
total_dossiers_per_state
|
||||
end
|
||||
|
||||
def termine
|
||||
@dossiers_termine = current_gestionnaire.dossiers.termine()
|
||||
@dossiers_termine = @dossiers_termine.paginate(:page => params[:page]).decorate
|
||||
@dossiers = current_gestionnaire.dossiers.termine()
|
||||
.paginate(:page => params[:page]).decorate
|
||||
|
||||
@page = 'termine'
|
||||
total_dossiers_per_state
|
||||
end
|
||||
|
||||
|
@ -61,9 +66,9 @@ class Backoffice::DossiersController < ApplicationController
|
|||
private
|
||||
|
||||
def total_dossiers_per_state
|
||||
@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
|
||||
@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,4 +1,15 @@
|
|||
class DossiersDecorator < Draper::CollectionDecorator
|
||||
delegate :current_page, :per_page, :offset, :total_entries, :total_pages
|
||||
|
||||
def active_class_a_traiter page
|
||||
'active' if page == 'a_traiter'
|
||||
end
|
||||
|
||||
def active_class_en_attente page
|
||||
'active' if page == 'en_attente'
|
||||
end
|
||||
|
||||
def active_class_termine page
|
||||
'active' if page == 'termine'
|
||||
end
|
||||
end
|
||||
|
|
16
app/views/backoffice/dossiers/_list.html.haml
Normal file
16
app/views/backoffice/dossiers/_list.html.haml
Normal file
|
@ -0,0 +1,16 @@
|
|||
%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.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
|
||||
|
||||
.pagination
|
||||
= will_paginate @dossiers, renderer: BootstrapPagination::Rails
|
|
@ -3,20 +3,20 @@
|
|||
|
||||
#onglets
|
||||
%ul.nav.nav-tabs
|
||||
%li{class: "#{'active' unless @dossiers_a_traiter.nil? }"}
|
||||
%a{:href => "#{url_for :backoffice_dossiers_a_traiter}"}
|
||||
%li{ class: (@dossiers.active_class_a_traiter(@page) unless @dossiers.nil?) }
|
||||
%a{:href => "#{url_for :backoffice_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 :backoffice_dossiers_en_attente}"}
|
||||
%li{ class: (@dossiers.active_class_en_attente(@page) unless @dossiers.nil?) }
|
||||
%a{:href => "#{url_for :backoffice_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 :backoffice_dossiers_termine}"}
|
||||
%li{ class: (@dossiers.active_class_termine(@page) unless @dossiers.nil?) }
|
||||
%a{ :href => "#{url_for :backoffice_dossiers_termine}" }
|
||||
%h5.text-success
|
||||
= "Terminé"
|
||||
.badge.progress-bar-success
|
||||
|
|
|
@ -1,20 +1,4 @@
|
|||
#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
|
||||
|
||||
.pagination
|
||||
= will_paginate @dossiers_a_traiter, renderer: BootstrapPagination::Rails
|
||||
= render partial: 'list'
|
|
@ -1,20 +1,4 @@
|
|||
#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
|
||||
|
||||
.pagination
|
||||
= will_paginate @dossiers_en_attente, renderer: BootstrapPagination::Rails
|
||||
= render partial: 'list'
|
|
@ -1,20 +1,4 @@
|
|||
#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
|
||||
|
||||
.pagination
|
||||
= will_paginate @dossiers_termine, renderer: BootstrapPagination::Rails
|
||||
= render partial: 'list'
|
|
@ -8,7 +8,8 @@ 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, gestionnaire.dossiers.waiting_for_gestionnaire.paginate(:page => 1).decorate)
|
||||
assign(:dossiers, gestionnaire.dossiers.waiting_for_gestionnaire.paginate(:page => 1).decorate)
|
||||
assign(:page, 'a_traiter')
|
||||
render
|
||||
end
|
||||
|
||||
|
@ -18,4 +19,8 @@ describe 'backoffice/dossiers/a_traiter.html.haml', type: :view do
|
|||
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
|
|
@ -8,7 +8,8 @@ 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, gestionnaire.dossiers.waiting_for_user.paginate(:page => 1).decorate)
|
||||
assign(:dossiers, gestionnaire.dossiers.waiting_for_user.paginate(:page => 1).decorate)
|
||||
assign(:page, 'en_attente')
|
||||
render
|
||||
end
|
||||
|
||||
|
@ -18,4 +19,8 @@ describe 'backoffice/dossiers/en_attente.html.haml', type: :view do
|
|||
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
|
|
@ -8,7 +8,8 @@ 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, gestionnaire.dossiers.termine.paginate(:page => 1).decorate)
|
||||
assign(:dossiers, gestionnaire.dossiers.termine.paginate(:page => 1).decorate)
|
||||
assign(:page, 'termine')
|
||||
render
|
||||
end
|
||||
|
||||
|
@ -18,4 +19,8 @@ describe 'backoffice/dossiers/termine.html.haml', type: :view do
|
|||
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