- 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
|
end
|
||||||
|
|
||||||
def a_traiter
|
def a_traiter
|
||||||
@dossiers_a_traiter = current_gestionnaire.dossiers.waiting_for_gestionnaire()
|
@dossiers = current_gestionnaire.dossiers.waiting_for_gestionnaire
|
||||||
@dossiers_a_traiter = @dossiers_a_traiter.paginate(:page => params[:page]).decorate
|
.paginate(:page => params[:page]).decorate
|
||||||
|
|
||||||
|
@page = 'a_traiter'
|
||||||
total_dossiers_per_state
|
total_dossiers_per_state
|
||||||
end
|
end
|
||||||
|
|
||||||
def en_attente
|
def en_attente
|
||||||
@dossiers_en_attente = current_gestionnaire.dossiers.waiting_for_user()
|
@dossiers = current_gestionnaire.dossiers.waiting_for_user()
|
||||||
@dossiers_en_attente = @dossiers_en_attente.paginate(:page => params[:page]).decorate
|
.paginate(:page => params[:page]).decorate
|
||||||
|
|
||||||
|
@page = 'en_attente'
|
||||||
total_dossiers_per_state
|
total_dossiers_per_state
|
||||||
end
|
end
|
||||||
|
|
||||||
def termine
|
def termine
|
||||||
@dossiers_termine = current_gestionnaire.dossiers.termine()
|
@dossiers = current_gestionnaire.dossiers.termine()
|
||||||
@dossiers_termine = @dossiers_termine.paginate(:page => params[:page]).decorate
|
.paginate(:page => params[:page]).decorate
|
||||||
|
|
||||||
|
@page = 'termine'
|
||||||
total_dossiers_per_state
|
total_dossiers_per_state
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -61,9 +66,9 @@ class Backoffice::DossiersController < ApplicationController
|
||||||
private
|
private
|
||||||
|
|
||||||
def total_dossiers_per_state
|
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_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_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_termine_total = !@dossiers_termine.nil? ? @dossiers_termine.size : current_gestionnaire.dossiers.termine.size
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize_instance_params dossier_id
|
def initialize_instance_params dossier_id
|
||||||
|
|
|
@ -1,4 +1,15 @@
|
||||||
class DossiersDecorator < Draper::CollectionDecorator
|
class DossiersDecorator < Draper::CollectionDecorator
|
||||||
delegate :current_page, :per_page, :offset, :total_entries, :total_pages
|
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
|
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
|
#onglets
|
||||||
%ul.nav.nav-tabs
|
%ul.nav.nav-tabs
|
||||||
%li{class: "#{'active' unless @dossiers_a_traiter.nil? }"}
|
%li{ class: (@dossiers.active_class_a_traiter(@page) unless @dossiers.nil?) }
|
||||||
%a{:href => "#{url_for :backoffice_dossiers_a_traiter}"}
|
%a{:href => "#{url_for :backoffice_dossiers_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: "#{'active' unless @dossiers_en_attente.nil? }"}
|
%li{ class: (@dossiers.active_class_en_attente(@page) unless @dossiers.nil?) }
|
||||||
%a{:href => "#{url_for :backoffice_dossiers_en_attente}"}
|
%a{:href => "#{url_for :backoffice_dossiers_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: "#{'active' unless @dossiers_termine.nil? }"}
|
%li{ class: (@dossiers.active_class_termine(@page) unless @dossiers.nil?) }
|
||||||
%a{:href => "#{url_for :backoffice_dossiers_termine}"}
|
%a{ :href => "#{url_for :backoffice_dossiers_termine}" }
|
||||||
%h5.text-success
|
%h5.text-success
|
||||||
= "Terminé"
|
= "Terminé"
|
||||||
.badge.progress-bar-success
|
.badge.progress-bar-success
|
||||||
|
|
|
@ -1,20 +1,4 @@
|
||||||
#backoffice_a_traiter
|
#backoffice_a_traiter
|
||||||
= render partial: 'onglets'
|
= render partial: 'onglets'
|
||||||
|
|
||||||
-#%h3.text-danger À traiter
|
= render partial: 'list'
|
||||||
%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
|
|
|
@ -1,20 +1,4 @@
|
||||||
#backoffice_en_attente
|
#backoffice_en_attente
|
||||||
= render partial: 'onglets'
|
= render partial: 'onglets'
|
||||||
|
|
||||||
-#%h3.text-info En attente
|
= render partial: 'list'
|
||||||
%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
|
|
|
@ -1,20 +1,4 @@
|
||||||
#backoffice_termine
|
#backoffice_termine
|
||||||
= render partial: 'onglets'
|
= render partial: 'onglets'
|
||||||
|
|
||||||
-#%h3.text-success Terminé
|
= render partial: 'list'
|
||||||
%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
|
|
|
@ -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 }
|
let!(:decorate_dossier) { create(:dossier, :with_user, state: 'initiated', procedure: procedure).decorate }
|
||||||
|
|
||||||
before do
|
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
|
render
|
||||||
end
|
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.nom_projet) }
|
||||||
it { is_expected.to have_content(decorate_dossier.state_fr) }
|
it { is_expected.to have_content(decorate_dossier.state_fr) }
|
||||||
it { is_expected.to have_content(decorate_dossier.last_update) }
|
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
|
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 }
|
let!(:decorate_dossier) { create(:dossier, :with_user, procedure: procedure, state: 'replied').decorate }
|
||||||
|
|
||||||
before do
|
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
|
render
|
||||||
end
|
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.nom_projet) }
|
||||||
it { is_expected.to have_content(decorate_dossier.state_fr) }
|
it { is_expected.to have_content(decorate_dossier.state_fr) }
|
||||||
it { is_expected.to have_content(decorate_dossier.last_update) }
|
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
|
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 }
|
let!(:decorate_dossier) { create(:dossier, :with_user, procedure: procedure, state: 'closed').decorate }
|
||||||
|
|
||||||
before do
|
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
|
render
|
||||||
end
|
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.nom_projet) }
|
||||||
it { is_expected.to have_content(decorate_dossier.state_fr) }
|
it { is_expected.to have_content(decorate_dossier.state_fr) }
|
||||||
it { is_expected.to have_content(decorate_dossier.last_update) }
|
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
|
end
|
Loading…
Reference in a new issue