create route and controller to filter dossier view by procedure

This commit is contained in:
Xavier J 2016-09-06 11:07:26 +02:00
parent 6a6ac7872a
commit d5ad256919
5 changed files with 71 additions and 37 deletions

View file

@ -0,0 +1,34 @@
class Backoffice::Dossiers::ProcedureController < ApplicationController
include SmartListing::Helper::ControllerExtensions
helper SmartListing::Helper
before_action :authenticate_gestionnaire!
def show
smartlisting_dossier (params[:liste] || 'a_traiter')
render 'backoffice/dossiers/index'
rescue ActiveRecord::RecordNotFound
flash[:alert] = "Cette procédure n'existe pas ou vous n'y avez pas accès."
redirect_to backoffice_dossiers_path
end
private
def smartlisting_dossier liste
create_dossiers_list_facade liste
@dossiers = smart_listing_create :dossiers,
@dossiers_list_facade.dossiers_to_display,
partial: "backoffice/dossiers/list",
array: true
end
def create_dossiers_list_facade liste='a_traiter'
@dossiers_list_facade = DossiersListFacades.new current_gestionnaire, liste, retrieve_procedure
end
def retrieve_procedure
current_gestionnaire.procedures.find params[:id]
end
end

View file

@ -1,12 +1,13 @@
class DossiersListFacades
def initialize current_devise_profil, liste
def initialize current_devise_profil, liste, procedure = nil
@current_devise_profil = current_devise_profil
@liste = liste
@procedure = procedure
end
def service
if gestionnaire?
@service ||= DossiersListGestionnaireService.new @current_devise_profil, @liste
@service ||= DossiersListGestionnaireService.new @current_devise_profil, @liste, @procedure
elsif user?
@service ||= DossiersListUserService.new @current_devise_profil, @liste
end

View file

@ -1,7 +1,8 @@
class DossiersListGestionnaireService
def initialize current_devise_profil, liste
def initialize current_devise_profil, liste, procedure = nil
@current_devise_profil = current_devise_profil
@liste = liste
@procedure = procedure
end
def dossiers_to_display
@ -10,35 +11,34 @@ class DossiersListGestionnaireService
'en_attente' => waiting_for_user,
'deposes' => deposes,
'a_instruire' => a_instruire,
'termine' => termine,
'suivi' => suivi}[@liste]
'termine' => termine}[@liste]
end
def nouveaux
@nouveaux ||= @current_devise_profil.dossiers.nouveaux
@nouveaux ||= filter_dossiers.nouveaux
end
def waiting_for_gestionnaire
@waiting_for_gestionnaire ||= @current_devise_profil.dossiers.waiting_for_gestionnaire
@waiting_for_gestionnaire ||= filter_dossiers.waiting_for_gestionnaire
end
def waiting_for_user
@waiting_for_user ||= @current_devise_profil.dossiers.waiting_for_user
@waiting_for_user ||= filter_dossiers.waiting_for_user
end
def deposes
@deposes ||= @current_devise_profil.dossiers.deposes
@deposes ||= filter_dossiers.deposes
end
def a_instruire
@a_instruire ||= @current_devise_profil.dossiers.a_instruire
@a_instruire ||= filter_dossiers.a_instruire
end
def termine
@termine ||= @current_devise_profil.dossiers.termine
@termine ||= filter_dossiers.termine
end
def suivi
@suivi ||= @current_devise_profil.dossiers_follow
def filter_dossiers
@procedure.nil? ? @current_devise_profil.dossiers : @procedure.dossiers
end
end

View file

@ -1,10 +1,10 @@
#backoffice_index
#pref_list_menu
= render partial: 'pref_list'
= render partial: 'onglets'
= render partial: 'backoffice/dossiers/pref_list'
= render partial: 'backoffice/dossiers/onglets'
= smart_listing_render :dossiers
%br
%br
= render partial: 'state_description', locals: {dossiers_list_facade: @dossiers_list_facade}
= render partial: 'backoffice/dossiers/state_description', locals: {dossiers_list_facade: @dossiers_list_facade}

View file

@ -37,6 +37,12 @@ Rails.application.routes.draw do
root 'root#index'
get 'cgu' => 'cgu#index'
get 'demo' => 'demo#index'
get 'users' => 'users#index'
get 'admin' => 'admin#index'
get 'backoffice' => 'backoffice#index'
resources :administrations
namespace :france_connect do
get 'particulier' => 'particulier#login'
@ -47,9 +53,6 @@ Rails.application.routes.draw do
post 'particulier/check_email' => 'particulier#check_email'
end
get 'demo' => 'demo#index'
get 'users' => 'users#index'
namespace :users do
namespace :dossiers do
resources :invites, only: [:index, :show]
@ -85,8 +88,6 @@ Rails.application.routes.draw do
resource :dossiers
end
get 'admin' => 'admin#index'
namespace :admin do
get 'sign_in' => '/administrateurs/sessions#new'
get 'procedures/archived' => 'procedures#archived'
@ -139,25 +140,13 @@ Rails.application.routes.draw do
get 'address_point' => 'search#get_address_point'
end
get 'backoffice' => 'backoffice#index'
namespace :backoffice do
get 'sign_in' => '/gestionnaires/sessions#new'
get 'dossiers/search' => 'dossiers#search'
get 'download_dossiers_tps' => 'dossiers#download_dossiers_tps'
resource :private_formulaire
namespace :preference_list_dossier do
post 'add'
delete 'delete'
get 'reload_smartlisting' => '/backoffice/dossiers#reload_smartlisting'
get 'reload_pref_list'
end
get 'download_dossiers_tps' => 'dossiers#download_dossiers_tps'
resources :dossiers do
post 'valid' => 'dossiers#valid'
post 'receive' => 'dossiers#receive'
@ -170,10 +159,20 @@ Rails.application.routes.draw do
put 'follow' => 'dossiers#follow'
end
resources :commentaires, only: [:create]
end
namespace :dossiers do
resources :procedure, only: [:show]
end
resources :administrations
resources :commentaires, only: [:create]
namespace :preference_list_dossier do
post 'add'
delete 'delete'
get 'reload_smartlisting' => '/backoffice/dossiers#reload_smartlisting'
get 'reload_pref_list'
end
end
namespace :api do
namespace :v1 do