Merge pull request #29 from sgmap/list_dossiers_archived
List dossiers archived
This commit is contained in:
commit
63a7b91e60
14 changed files with 151 additions and 83 deletions
|
@ -151,7 +151,7 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
|
|||
end
|
||||
|
||||
def archive
|
||||
facade = create_dossier_facade params[:dossier_id]
|
||||
facade = create_dossier_facade params[:id]
|
||||
unless facade.dossier.archived
|
||||
facade.dossier.update(archived: true)
|
||||
flash.notice = 'Dossier archivé'
|
||||
|
@ -159,6 +159,16 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
|
|||
redirect_to backoffice_dossiers_path
|
||||
end
|
||||
|
||||
|
||||
def unarchive
|
||||
@dossier = Dossier.find(params[:id])
|
||||
if @dossier.archived
|
||||
@dossier.update(archived: false)
|
||||
flash.notice = 'Dossier désarchivé'
|
||||
end
|
||||
redirect_to backoffice_dossier_path(@dossier)
|
||||
end
|
||||
|
||||
def reopen
|
||||
create_dossier_facade params[:dossier_id]
|
||||
|
||||
|
|
|
@ -29,36 +29,31 @@ class Backoffice::DossiersListController < ApplicationController
|
|||
|
||||
def smartlisting_dossier dossiers_list=nil, liste='all_state'
|
||||
dossiers_list_facade liste
|
||||
service = dossiers_list_facade.service
|
||||
|
||||
new_dossiers_list = dossiers_list_facade.service.nouveaux
|
||||
follow_dossiers_list = dossiers_list_facade.service.suivi
|
||||
all_state_dossiers_list = dossiers_list_facade.service.all_state
|
||||
|
||||
if param_page.nil?
|
||||
params[:dossiers_smart_listing] = {page: dossiers_list_facade.service.default_page}
|
||||
end
|
||||
|
||||
smart_listing_create :new_dossiers,
|
||||
new_dossiers_list,
|
||||
partial: "backoffice/dossiers/list",
|
||||
array: true,
|
||||
default_sort: dossiers_list_facade.service.default_sort
|
||||
default_smart_listing_create :new_dossiers, service.nouveaux
|
||||
default_smart_listing_create :follow_dossiers, service.suivi
|
||||
default_smart_listing_create :all_state_dossiers, service.all_state
|
||||
default_smart_listing_create :archived_dossiers, service.archive
|
||||
|
||||
smart_listing_create :follow_dossiers,
|
||||
follow_dossiers_list,
|
||||
partial: "backoffice/dossiers/list",
|
||||
array: true,
|
||||
default_sort: dossiers_list_facade.service.default_sort
|
||||
|
||||
smart_listing_create :all_state_dossiers,
|
||||
all_state_dossiers_list,
|
||||
partial: "backoffice/dossiers/list",
|
||||
array: true,
|
||||
default_sort: dossiers_list_facade.service.default_sort
|
||||
@archived_dossiers = service.archive
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def default_smart_listing_create name, collection
|
||||
smart_listing_create name,
|
||||
collection,
|
||||
partial: 'backoffice/dossiers/list',
|
||||
array: true,
|
||||
default_sort: dossiers_list_facade.service.default_sort
|
||||
end
|
||||
|
||||
def param_smart_listing
|
||||
params[:dossiers_smart_listing]
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ class DossierFacades
|
|||
|
||||
#TODO rechercher en fonction de la personne/email
|
||||
def initialize(dossier_id, email, champ_id = nil)
|
||||
@dossier = Dossier.where(archived: false).find(dossier_id)
|
||||
@dossier = Dossier.find(dossier_id)
|
||||
@champ_id = champ_id
|
||||
end
|
||||
|
||||
|
|
|
@ -199,6 +199,8 @@ class Dossier < ActiveRecord::Base
|
|||
where(state: TERMINE, archived: false).order("updated_at #{order}")
|
||||
end
|
||||
|
||||
scope :archived, -> { where(archived: true) }
|
||||
|
||||
def cerfa_available?
|
||||
procedure.cerfa_flag? && cerfa.size != 0
|
||||
end
|
||||
|
|
|
@ -11,6 +11,7 @@ class DossiersListGestionnaireService
|
|||
'a_traiter' => ouvert,
|
||||
'a_instruire' => a_instruire,
|
||||
'termine' => termine,
|
||||
'archive' => archive,
|
||||
'all_state' => all_state}[@liste]
|
||||
|
||||
end
|
||||
|
@ -39,6 +40,10 @@ class DossiersListGestionnaireService
|
|||
@a_instruire ||= filter_dossiers.a_instruire
|
||||
end
|
||||
|
||||
def archive
|
||||
@archive ||= filter_dossiers.archived
|
||||
end
|
||||
|
||||
def termine
|
||||
@termine ||= filter_dossiers.termine
|
||||
end
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
%table#dossiers_list.table
|
||||
%thead
|
||||
- if smart_listing.name.to_s == 'follow_dossiers'
|
||||
%th.col-md-1.col-lg-1.col-sm-1.col-xs-1.col-sm-1.col-xs-1.center
|
||||
%th.col-xs-1.center
|
||||
%i.fa.fa-bell
|
||||
%th.col-md-1.col-lg-1.col-sm-1.col-xs-1.col-sm-1.col-xs-1
|
||||
%th.col-xs-1
|
||||
État
|
||||
|
||||
- @facade_data_view.preference_list_dossiers_filter.each do |preference|
|
||||
|
@ -17,14 +17,14 @@
|
|||
%i.filter.fa.fa-filter{style: "color:#{(preference.filter.blank? ? 'grey' : 'orange')}", id: "filter_#{smart_listing.name.to_s}_#{preference.table_attr.sub('.', '_')}"}
|
||||
= render partial: 'backoffice/dossiers/filter_framed', locals:{preference: preference, filter_framed_id: "framed_filter_#{smart_listing.name.to_s}_#{preference.table_attr.sub('.', '_')}"}
|
||||
|
||||
%th.col-md-1.col-lg-1.col-sm-1.col-xs-1.col-sm-1.col-xs-1.center Actions
|
||||
%th.col-md-1.col-lg-1.col-sm-1.col-xs-1.col-sm-1.col-xs-1.center Abonnés
|
||||
%th.col-xs-1.center Actions
|
||||
%th.col-xs-1.center Abonnés
|
||||
|
||||
- unless smart_listing.empty?
|
||||
- smart_listing.collection.each do |dossier|
|
||||
%tr.dossier-row{id: "tr_dossier_#{dossier.id}", 'data-dossier_url' => backoffice_dossier_url(id: dossier.id)}
|
||||
- if smart_listing.name.to_s == 'follow_dossiers'
|
||||
%td.col-md-1.col-lg-1.col-sm-1.col-xs-1.col-sm-1.col-xs-1.center
|
||||
%td.col-xs-1.center
|
||||
- total_notif = dossier.notifications.where(already_read: false).count
|
||||
- if total_notif == 0
|
||||
.badge.progress-bar-default
|
||||
|
@ -32,7 +32,7 @@
|
|||
- else
|
||||
.badge.progress-bar-warning
|
||||
= total_notif
|
||||
%td.col-md-1.col-lg-1.col-sm-1.col-xs-1.col-sm-1.col-xs-1
|
||||
%td.col-xs-1
|
||||
= dossier.decorate.display_state
|
||||
- @facade_data_view.preference_list_dossiers_filter.each_with_index do |preference, index|
|
||||
- unless preference.libelle == 'Statut' || preference.libelle == 'État'
|
||||
|
|
|
@ -3,53 +3,64 @@
|
|||
= render partial: 'backoffice/dossiers/pref_list'
|
||||
|
||||
.default_data_block
|
||||
%div.row.show-block#new_dossiers
|
||||
%div.header
|
||||
%div.col-lg-10.col-md-10.col-sm-10.col-xs-10.title
|
||||
%div.carret-right
|
||||
%div.carret-down
|
||||
.row.show-block#new_dossiers
|
||||
.header
|
||||
.col-xs-10.title
|
||||
.carret-right
|
||||
.carret-down
|
||||
Nouveaux dossiers
|
||||
%div.col-lg-2.col-md-2.col-sm-2.col-xs-2.count
|
||||
=@facade_data_view.nouveaux_total
|
||||
dossiers
|
||||
%div.body
|
||||
.col-xs-2.count
|
||||
= pluralize(@facade_data_view.nouveaux_total, "dossier")
|
||||
.body
|
||||
= smart_listing_render :new_dossiers
|
||||
|
||||
.row.center
|
||||
.col-lg-1.col-md-1.col-sm-1.col-xs-1
|
||||
.col-lg-2.col-md-2.col-sm-2.col-xs-2
|
||||
.col-xs-2.col-xs-offset-1
|
||||
=link_to 'Tous les états', '?liste=all_state', class: 'text-info', style:"text-decoration: #{@facade_data_view.liste == 'all_state'? 'underline' : ''}"
|
||||
.col-lg-2.col-md-2.col-sm-2.col-xs-2
|
||||
.col-xs-2
|
||||
=link_to 'En construction', '?liste=a_traiter', class: 'text-danger', style:"text-decoration: #{@facade_data_view.liste == 'a_traiter'? 'underline' : ''}"
|
||||
.col-lg-2.col-md-2.col-sm-2.col-xs-2
|
||||
.col-xs-2
|
||||
=link_to 'À receptionner', '?liste=deposes', class: 'text-purple', style:"text-decoration: #{@facade_data_view.liste == 'deposes'? 'underline' : ''}"
|
||||
.col-lg-2.col-md-2.col-sm-2.col-xs-2
|
||||
.col-xs-2
|
||||
=link_to 'À instruire', '?liste=a_instruire', class: 'text-warning', style:"text-decoration: #{@facade_data_view.liste == 'a_instruire'? 'underline' : ''}"
|
||||
.col-lg-2.col-md-2.col-sm-2.col-xs-2
|
||||
.col-xs-2
|
||||
=link_to 'Terminés', '?liste=termine', class: 'text-success', style:"text-decoration: #{@facade_data_view.liste == 'termine'? 'underline' : ''}"
|
||||
|
||||
.default_data_block.default_visible
|
||||
%div.row.show-block#follow_dossiers
|
||||
%div.header
|
||||
%div.col-lg-10.col-md-10.col-sm-10.col-xs-10.title
|
||||
%div.carret-right
|
||||
%div.carret-down
|
||||
.row.show-block#follow_dossiers
|
||||
.header
|
||||
.col-xs-10.title
|
||||
.carret-right
|
||||
.carret-down
|
||||
Dossiers suivis
|
||||
%div.col-lg-2.col-md-2.col-sm-2.col-xs-2.count
|
||||
=@facade_data_view.suivi_total
|
||||
dossiers
|
||||
%div.body
|
||||
.col-xs-2.count
|
||||
= pluralize(@facade_data_view.suivi_total, "dossier")
|
||||
.body
|
||||
= smart_listing_render :follow_dossiers
|
||||
|
||||
.default_data_block
|
||||
%div.row.show-block#all_dossiers
|
||||
%div.header
|
||||
%div.col-lg-10.col-md-10.col-sm-10.col-xs-10.title
|
||||
%div.carret-right
|
||||
%div.carret-down
|
||||
.row.show-block#all_dossiers
|
||||
.header
|
||||
.col-xs-10.title
|
||||
.carret-right
|
||||
.carret-down
|
||||
Tous les dossiers
|
||||
%div.col-lg-2.col-md-2.col-sm-2.col-xs-2.count
|
||||
=@facade_data_view.all_state_total
|
||||
dossiers
|
||||
%div.body
|
||||
.col-xs-2.count
|
||||
= pluralize(@facade_data_view.all_state_total, "dossier")
|
||||
.body
|
||||
= smart_listing_render :all_state_dossiers
|
||||
|
||||
|
||||
- if @archived_dossiers
|
||||
.default_data_block
|
||||
.row.show-block#archived_dossiers
|
||||
.header
|
||||
.col-xs-10.title
|
||||
.carret-right
|
||||
.carret-down
|
||||
Dossiers archivés
|
||||
.col-xs-2.count
|
||||
= pluralize(@archived_dossiers.count, "dossier")
|
||||
|
||||
.body
|
||||
= smart_listing_render :archived_dossiers
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
%div#first-block
|
||||
%div.infos
|
||||
#first-block
|
||||
.infos
|
||||
#dossier_id= t('dynamics.dossiers.numéro') + @facade.dossier.id.to_s
|
||||
|
||||
%div#action-block
|
||||
#action-block
|
||||
- if gestionnaire_signed_in?
|
||||
- if !@facade.dossier.read_only? || @facade.dossier.initiated?
|
||||
= link_to 'Accuser réception', backoffice_dossier_receive_path(@facade.dossier), method: :post, class: 'btn btn-danger btn-block'
|
||||
|
@ -19,18 +19,24 @@
|
|||
%i.fa.fa-times
|
||||
= link_to 'Reouvrir', backoffice_dossier_reopen_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block'
|
||||
|
||||
- unless @facade.dossier.archived?
|
||||
= link_to 'Archiver', backoffice_dossier_archive_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block'
|
||||
%hr
|
||||
- if @facade.dossier.archived?
|
||||
%p
|
||||
Archivé
|
||||
= link_to 'Désarchiver', unarchive_backoffice_dossier_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block'
|
||||
|
||||
- else
|
||||
= link_to 'Archiver', archive_backoffice_dossier_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block'
|
||||
|
||||
|
||||
|
||||
%div#menu-block
|
||||
#menu-block
|
||||
|
||||
%div#infos-block
|
||||
%div.split-hr-left
|
||||
%div.dossier-state= @facade.dossier.display_state
|
||||
%div.split-hr-left
|
||||
%div.notifications
|
||||
#infos-block
|
||||
.split-hr-left
|
||||
.dossier-state= @facade.dossier.display_state
|
||||
.split-hr-left
|
||||
.notifications
|
||||
- if @facade.dossier.notifications.empty?
|
||||
Aucune notification pour le moment.
|
||||
- else
|
||||
|
|
|
@ -162,9 +162,11 @@ Rails.application.routes.draw do
|
|||
post 'refuse' => 'dossiers#refuse'
|
||||
post 'without_continuation' => 'dossiers#without_continuation'
|
||||
post 'close' => 'dossiers#close'
|
||||
post 'archive' => 'dossiers#archive'
|
||||
member do
|
||||
post 'archive'
|
||||
post 'unarchive'
|
||||
end
|
||||
post 'reopen' => 'dossiers#reopen'
|
||||
|
||||
put 'follow' => 'dossiers#follow'
|
||||
resources :commentaires, only: [:index]
|
||||
end
|
||||
|
|
|
@ -3,6 +3,8 @@ require 'spec_helper'
|
|||
describe Backoffice::Dossiers::ProcedureController, type: :controller do
|
||||
let(:gestionnaire) { create :gestionnaire }
|
||||
let(:procedure) { create :procedure }
|
||||
let(:archived) { false }
|
||||
let(:dossier) { create :dossier, procedure: procedure, archived: archived, state: 'initiated'}
|
||||
|
||||
before do
|
||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
||||
|
@ -28,6 +30,24 @@ describe Backoffice::Dossiers::ProcedureController, type: :controller do
|
|||
it { is_expected.to redirect_to backoffice_dossiers_path }
|
||||
it { expect(flash[:alert]).to be_present}
|
||||
end
|
||||
|
||||
context 'when procedure contains a dossier' do
|
||||
render_views
|
||||
|
||||
before do
|
||||
dossier
|
||||
subject
|
||||
end
|
||||
|
||||
it { expect(response.body).to have_content('Tous les dossiers 1 dossier') }
|
||||
|
||||
context 'archived' do
|
||||
let(:archived) { true }
|
||||
|
||||
it { expect(response.body).to have_content('Tous les dossiers 0 dossiers') }
|
||||
it { expect(response.body).to have_content('Dossiers archivés 1 dossier') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #filter' do
|
||||
|
|
|
@ -104,12 +104,6 @@ describe Backoffice::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context ' when dossier is archived' do
|
||||
let(:dossier_id) { dossier_archived }
|
||||
|
||||
it { expect(subject).to redirect_to('/backoffice') }
|
||||
end
|
||||
|
||||
context 'when dossier id does not exist' do
|
||||
let(:dossier_id) { bad_dossier_id }
|
||||
|
||||
|
@ -384,7 +378,7 @@ describe Backoffice::DossiersController, type: :controller do
|
|||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
subject { post :archive, params: {dossier_id: dossier_id} }
|
||||
subject { post :archive, params: {id: dossier_id} }
|
||||
|
||||
it 'change state to archived' do
|
||||
subject
|
||||
|
|
|
@ -77,7 +77,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
|
|||
|
||||
subject { rendered }
|
||||
|
||||
it { is_expected.to have_content('Nouveaux dossiers 1 dossiers') }
|
||||
it { is_expected.to have_content('Nouveaux dossiers 1 dossier') }
|
||||
it { is_expected.to have_content('Dossiers suivis 0 dossiers') }
|
||||
it { is_expected.to have_content('Tous les dossiers 7 dossiers') }
|
||||
|
||||
|
|
|
@ -2,8 +2,9 @@ require 'spec_helper'
|
|||
|
||||
describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml', type: :view do
|
||||
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, state: state) }
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, state: state, archived: archived) }
|
||||
let(:state) { 'draft' }
|
||||
let(:archived) { false }
|
||||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
|
||||
before do
|
||||
|
@ -127,6 +128,28 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
|
|||
expect(rendered).not_to have_css('form[data-toggle="tooltip"][title="Refuser"]')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier is not archived' do
|
||||
let(:archived) { false }
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_link('Archiver') }
|
||||
end
|
||||
|
||||
context 'when dossier is archived' do
|
||||
let(:archived) { true }
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content('Archivé') }
|
||||
it { expect(rendered).to have_link('Désarchiver') }
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in a new issue