2016-09-27 17:26:49 +02:00
|
|
|
class Backoffice::DossiersListController < ApplicationController
|
|
|
|
include SmartListing::Helper::ControllerExtensions
|
|
|
|
helper SmartListing::Helper
|
|
|
|
|
|
|
|
before_action :authenticate_gestionnaire!
|
|
|
|
|
|
|
|
def index
|
2016-10-04 19:19:03 +02:00
|
|
|
cookies[:liste] = param_liste
|
2016-09-27 17:26:49 +02:00
|
|
|
|
2016-10-11 18:05:49 +02:00
|
|
|
unless DossiersListGestionnaireService.dossiers_liste_libelle.include?(param_liste)
|
2017-01-05 19:07:01 +01:00
|
|
|
cookies[:liste] = 'all_state'
|
2016-10-07 16:01:32 +02:00
|
|
|
end
|
|
|
|
|
2016-10-04 19:19:03 +02:00
|
|
|
dossiers_list_facade param_liste
|
2016-10-11 17:40:59 +02:00
|
|
|
dossiers_list_facade.service.change_sort! param_sort unless param_smart_listing.nil?
|
|
|
|
dossiers_list_facade.service.change_page! param_page
|
2016-09-27 17:26:49 +02:00
|
|
|
|
|
|
|
smartlisting_dossier
|
|
|
|
end
|
|
|
|
|
2016-10-04 19:19:03 +02:00
|
|
|
def filter
|
|
|
|
dossiers_list_facade param_liste
|
|
|
|
dossiers_list_facade.service.add_filter param_filter
|
|
|
|
end
|
|
|
|
|
2017-01-05 19:07:01 +01:00
|
|
|
def dossiers_list_facade liste='all_state'
|
2016-11-28 16:49:50 +01:00
|
|
|
@facade_data_view ||= DossiersListFacades.new current_gestionnaire, liste, retrieve_procedure
|
2016-09-27 17:26:49 +02:00
|
|
|
end
|
|
|
|
|
2017-01-05 19:07:01 +01:00
|
|
|
def smartlisting_dossier dossiers_list=nil, liste='all_state'
|
2016-10-07 14:58:45 +02:00
|
|
|
dossiers_list_facade liste
|
2016-11-24 19:33:34 +01:00
|
|
|
|
|
|
|
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
|
2016-10-07 14:58:45 +02:00
|
|
|
|
2016-10-11 17:40:59 +02:00
|
|
|
if param_page.nil?
|
|
|
|
params[:dossiers_smart_listing] = {page: dossiers_list_facade.service.default_page}
|
2016-10-11 15:37:16 +02:00
|
|
|
end
|
|
|
|
|
2016-11-24 19:33:34 +01:00
|
|
|
smart_listing_create :new_dossiers,
|
|
|
|
new_dossiers_list,
|
|
|
|
partial: "backoffice/dossiers/list",
|
|
|
|
array: true,
|
|
|
|
default_sort: dossiers_list_facade.service.default_sort
|
|
|
|
|
|
|
|
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
|
2016-09-27 17:26:49 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-10-11 17:40:59 +02:00
|
|
|
def param_smart_listing
|
|
|
|
params[:dossiers_smart_listing]
|
|
|
|
end
|
|
|
|
|
|
|
|
def param_page
|
|
|
|
unless param_smart_listing.nil?
|
|
|
|
return 1 if params[:dossiers_smart_listing][:page].blank?
|
|
|
|
params[:dossiers_smart_listing][:page]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-09-27 17:26:49 +02:00
|
|
|
def param_sort
|
2016-10-11 17:40:59 +02:00
|
|
|
params[:dossiers_smart_listing][:sort] unless param_smart_listing.nil?
|
2016-09-27 17:26:49 +02:00
|
|
|
end
|
2016-10-04 19:19:03 +02:00
|
|
|
|
|
|
|
def param_filter
|
|
|
|
params[:filter_input]
|
|
|
|
end
|
|
|
|
|
|
|
|
def param_liste
|
2017-01-05 19:07:01 +01:00
|
|
|
@liste ||= params[:liste] || cookies[:liste] || 'all_state'
|
2016-10-04 19:19:03 +02:00
|
|
|
end
|
2016-09-27 17:26:49 +02:00
|
|
|
end
|