Merge branch 'staging'
This commit is contained in:
commit
b66cecc1d5
73 changed files with 1299 additions and 240 deletions
27
app/assets/javascripts/dossiers_list_filter.js
Normal file
27
app/assets/javascripts/dossiers_list_filter.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
$(document).on('page:load', filters_init);
|
||||
$(document).ready(filters_init);
|
||||
|
||||
|
||||
function filters_init() {
|
||||
$(".filter").on('click', function (event) {
|
||||
filter_framed_show(event);
|
||||
filter_framed_close_all_excepted(framed_id(event));
|
||||
});
|
||||
}
|
||||
|
||||
function filter_framed_close_all_excepted(id) {
|
||||
$(".filter_framed:not("+id+")").hide();
|
||||
|
||||
$(id).toggle();
|
||||
}
|
||||
|
||||
function framed_id(event) {
|
||||
return "#framed_" + event.target.id
|
||||
}
|
||||
|
||||
function filter_framed_show(event) {
|
||||
dom_object = $(framed_id(event));
|
||||
|
||||
dom_object.css('top', (event.pageY + 7) + 'px');
|
||||
dom_object.css('left', (event.pageX + 7) + 'px');
|
||||
}
|
|
@ -4,6 +4,7 @@ $(document).ready(button_edit_procedure_init);
|
|||
function button_edit_procedure_init(){
|
||||
buttons_api_carto();
|
||||
button_cerfa();
|
||||
button_individual();
|
||||
}
|
||||
|
||||
function buttons_api_carto () {
|
||||
|
@ -24,4 +25,14 @@ function button_cerfa () {
|
|||
|
||||
if ($('#procedure_cerfa_flag').is(':checked'))
|
||||
$("#procedure_lien_demarche").show();
|
||||
}
|
||||
|
||||
function button_individual () {
|
||||
|
||||
$("#procedure_for_individual").on('change', function() {
|
||||
$("#individual_with_siret").toggle()
|
||||
});
|
||||
|
||||
if ($('#procedure_for_individual').is(':checked'))
|
||||
$("#individual_with_siret").show();
|
||||
}
|
|
@ -4,4 +4,8 @@
|
|||
|
||||
#procedure_lien_demarche{
|
||||
display: none;
|
||||
}
|
||||
|
||||
#individual_with_siret {
|
||||
display: none;
|
||||
}
|
|
@ -27,9 +27,10 @@ class Admin::AccompagnateursController < AdminController
|
|||
procedure = Procedure.find(params[:procedure_id])
|
||||
to = params[:to]
|
||||
|
||||
accompagnateur_service = AccompagnateurService.new gestionnaire, procedure, to
|
||||
|
||||
AccompagnateurService.change_assignement! gestionnaire, procedure, to
|
||||
AccompagnateurService.build_default_column gestionnaire, procedure, to
|
||||
accompagnateur_service.change_assignement!
|
||||
accompagnateur_service.build_default_column
|
||||
|
||||
flash.notice = "Assignement effectué"
|
||||
redirect_to admin_procedure_accompagnateurs_path, procedure_id: params[:procedure_id]
|
||||
|
|
|
@ -187,7 +187,7 @@ class Admin::ProceduresController < AdminController
|
|||
private
|
||||
|
||||
def create_procedure_params
|
||||
params.require(:procedure).permit(:libelle, :description, :organisation, :direction, :lien_demarche, :lien_site_web, :lien_notice, :euro_flag, :logo, :cerfa_flag, :for_individual, module_api_carto_attributes: [:id, :use_api_carto, :quartiers_prioritaires, :cadastre]).merge(administrateur_id: current_administrateur.id)
|
||||
params.require(:procedure).permit(:libelle, :description, :organisation, :direction, :lien_demarche, :lien_site_web, :lien_notice, :euro_flag, :logo, :cerfa_flag, :for_individual, :individual_with_siret, module_api_carto_attributes: [:id, :use_api_carto, :quartiers_prioritaires, :cadastre]).merge(administrateur_id: current_administrateur.id)
|
||||
end
|
||||
|
||||
def create_module_api_carto_params
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
class Backoffice::Dossiers::ProcedureController < ApplicationController
|
||||
include SmartListing::Helper::ControllerExtensions
|
||||
helper SmartListing::Helper
|
||||
class Backoffice::Dossiers::ProcedureController < Backoffice::DossiersListController
|
||||
|
||||
before_action :authenticate_gestionnaire!
|
||||
def index
|
||||
super
|
||||
|
||||
def show
|
||||
cookies[:liste] = params[:liste] || cookies[:liste] || 'a_traiter'
|
||||
smartlisting_dossier cookies[:liste]
|
||||
dossiers_list_facade.service.filter_procedure! params[:id]
|
||||
|
||||
render 'backoffice/dossiers/index'
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
|
@ -14,21 +11,14 @@ class Backoffice::Dossiers::ProcedureController < ApplicationController
|
|||
redirect_to backoffice_dossiers_path
|
||||
end
|
||||
|
||||
def filter
|
||||
super
|
||||
|
||||
redirect_to backoffice_dossiers_procedure_path(id: params[:id], liste: param_liste)
|
||||
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
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
class Backoffice::DossiersController < ApplicationController
|
||||
include SmartListing::Helper::ControllerExtensions
|
||||
helper SmartListing::Helper
|
||||
|
||||
before_action :authenticate_gestionnaire!
|
||||
class Backoffice::DossiersController < Backoffice::DossiersListController
|
||||
|
||||
def index
|
||||
cookies[:liste] = params[:liste] || cookies[:liste] || 'a_traiter'
|
||||
smartlisting_dossier (cookies[:liste])
|
||||
super
|
||||
|
||||
dossiers_list_facade.service.filter_procedure_reset!
|
||||
end
|
||||
|
||||
def show
|
||||
|
@ -14,6 +11,12 @@ class Backoffice::DossiersController < ApplicationController
|
|||
@champs = @facade.champs_private unless @facade.nil?
|
||||
end
|
||||
|
||||
def filter
|
||||
super
|
||||
|
||||
redirect_to backoffice_dossiers_path(liste: param_liste)
|
||||
end
|
||||
|
||||
def download_dossiers_tps
|
||||
dossiers = current_gestionnaire.dossiers.where.not(state: :draft)
|
||||
|
||||
|
@ -24,18 +27,12 @@ class Backoffice::DossiersController < ApplicationController
|
|||
|
||||
def search
|
||||
@search_terms = params[:q]
|
||||
@dossiers_search, @dossier = Dossier.search(current_gestionnaire, @search_terms)
|
||||
@dossier = Dossier.search(current_gestionnaire, @search_terms)
|
||||
|
||||
create_dossiers_list_facade
|
||||
|
||||
unless @dossiers_search.empty?
|
||||
@dossiers_search = @dossiers_search.paginate(:page => params[:page]).decorate
|
||||
end
|
||||
|
||||
@dossier = @dossier.decorate unless @dossier.nil?
|
||||
smartlisting_dossier @dossier, 'search'
|
||||
|
||||
rescue RuntimeError
|
||||
@dossiers_search = []
|
||||
smartlisting_dossier [], 'search'
|
||||
end
|
||||
|
||||
def valid
|
||||
|
@ -106,29 +103,17 @@ class Backoffice::DossiersController < ApplicationController
|
|||
begin
|
||||
@liste = URI(request.referer).query.split('=').second
|
||||
rescue NoMethodError
|
||||
@liste = 'a_traiter'
|
||||
@liste = cookies[:liste] || 'a_traiter'
|
||||
end
|
||||
|
||||
smartlisting_dossier @liste
|
||||
dossiers_list_facade @liste
|
||||
smartlisting_dossier
|
||||
|
||||
render 'backoffice/dossiers/index', formats: :js
|
||||
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 create_dossier_facade dossier_id
|
||||
@facade = DossierFacades.new dossier_id, current_gestionnaire.email
|
||||
|
||||
|
@ -137,7 +122,6 @@ class Backoffice::DossiersController < ApplicationController
|
|||
redirect_to url_for(controller: '/backoffice')
|
||||
end
|
||||
|
||||
|
||||
def retrieve_procedure
|
||||
return if params[:procedure_id].blank?
|
||||
current_gestionnaire.procedures.find params[:procedure_id]
|
||||
|
|
70
app/controllers/backoffice/dossiers_list_controller.rb
Normal file
70
app/controllers/backoffice/dossiers_list_controller.rb
Normal file
|
@ -0,0 +1,70 @@
|
|||
class Backoffice::DossiersListController < ApplicationController
|
||||
include SmartListing::Helper::ControllerExtensions
|
||||
helper SmartListing::Helper
|
||||
|
||||
before_action :authenticate_gestionnaire!
|
||||
|
||||
def index
|
||||
cookies[:liste] = param_liste
|
||||
|
||||
unless DossiersListGestionnaireService.dossiers_liste_libelle.include?(param_liste)
|
||||
cookies[:liste] = 'a_traiter'
|
||||
return redirect_to backoffice_dossiers_path
|
||||
end
|
||||
|
||||
dossiers_list_facade param_liste
|
||||
dossiers_list_facade.service.change_sort! param_sort unless param_smart_listing.nil?
|
||||
dossiers_list_facade.service.change_page! param_page
|
||||
|
||||
smartlisting_dossier
|
||||
end
|
||||
|
||||
def filter
|
||||
dossiers_list_facade param_liste
|
||||
dossiers_list_facade.service.add_filter param_filter
|
||||
end
|
||||
|
||||
def dossiers_list_facade liste='a_traiter'
|
||||
@dossiers_list_facade ||= DossiersListFacades.new current_gestionnaire, liste, retrieve_procedure
|
||||
end
|
||||
|
||||
def smartlisting_dossier dossiers_list=nil, liste='a_traiter'
|
||||
dossiers_list_facade liste
|
||||
dossiers_list = dossiers_list_facade.dossiers_to_display if dossiers_list.nil?
|
||||
|
||||
if param_page.nil?
|
||||
params[:dossiers_smart_listing] = {page: dossiers_list_facade.service.default_page}
|
||||
end
|
||||
|
||||
@dossiers = smart_listing_create :dossiers,
|
||||
dossiers_list,
|
||||
partial: "backoffice/dossiers/list",
|
||||
array: true,
|
||||
default_sort: dossiers_list_facade.service.default_sort
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
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
|
||||
|
||||
def param_sort
|
||||
params[:dossiers_smart_listing][:sort] unless param_smart_listing.nil?
|
||||
end
|
||||
|
||||
def param_filter
|
||||
params[:filter_input]
|
||||
end
|
||||
|
||||
def param_liste
|
||||
@liste ||= params[:liste] || cookies[:liste] || 'a_traiter'
|
||||
end
|
||||
end
|
|
@ -8,7 +8,7 @@ class Backoffice::PreferenceListDossierController < ApplicationController
|
|||
def add
|
||||
PreferenceListDossier.create(
|
||||
libelle: params[:libelle],
|
||||
table: params[:table],
|
||||
table: (params[:table].empty? ? nil : params[:table]),
|
||||
attr: params[:attr],
|
||||
attr_decorate: params[:attr_decorate],
|
||||
bootstrap_lg: params[:bootstrap_lg],
|
||||
|
|
|
@ -25,6 +25,9 @@ class Users::DescriptionController < UsersController
|
|||
@procedure = @dossier.procedure
|
||||
@champs = @dossier.ordered_champs
|
||||
|
||||
mandatory = true
|
||||
mandatory = !(params[:submit].keys.first == 'brouillon') unless params[:submit].nil?
|
||||
|
||||
unless @dossier.update_attributes(create_params)
|
||||
@dossier = @dossier.decorate
|
||||
|
||||
|
@ -43,10 +46,10 @@ class Users::DescriptionController < UsersController
|
|||
end
|
||||
|
||||
unless params[:champs].nil?
|
||||
champs_service_errors = ChampsService.save_formulaire @dossier.champs, params
|
||||
champs_service_errors = ChampsService.save_formulaire @dossier.champs, params, mandatory
|
||||
|
||||
unless champs_service_errors.empty?
|
||||
flash.now.alert = (champs_service_errors.inject('') {|acc, error| acc+= error[:message]+'<br>' }).html_safe
|
||||
flash.now.alert = (champs_service_errors.inject('') { |acc, error| acc+= error[:message]+'<br>' }).html_safe
|
||||
return render 'show'
|
||||
end
|
||||
end
|
||||
|
@ -56,12 +59,18 @@ class Users::DescriptionController < UsersController
|
|||
return render 'show'
|
||||
end
|
||||
|
||||
if @dossier.draft?
|
||||
@dossier.initiated!
|
||||
end
|
||||
|
||||
flash.notice = 'Félicitation, votre demande a bien été enregistrée.'
|
||||
redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: @dossier.id)
|
||||
if mandatory
|
||||
if @dossier.draft?
|
||||
@dossier.initiated!
|
||||
end
|
||||
|
||||
flash.notice = 'Félicitation, votre demande a bien été enregistrée.'
|
||||
redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: @dossier.id)
|
||||
else
|
||||
flash.notice = 'Votre brouillon a bien été sauvegardé.'
|
||||
redirect_to url_for(controller: :dossiers, action: :index, liste: :brouillon)
|
||||
end
|
||||
end
|
||||
|
||||
def pieces_justificatives
|
||||
|
@ -92,4 +101,5 @@ class Users::DescriptionController < UsersController
|
|||
def create_params
|
||||
params.permit()
|
||||
end
|
||||
|
||||
end
|
||||
|
|
13
app/controllers/users/dossiers/add_siret_controller.rb
Normal file
13
app/controllers/users/dossiers/add_siret_controller.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
class Users::Dossiers::AddSiretController < ApplicationController
|
||||
def show
|
||||
@facade = DossierFacades.new params[:dossier_id], current_user.email
|
||||
|
||||
raise ActiveRecord::RecordNotFound unless @facade.procedure.individual_with_siret?
|
||||
|
||||
@siret = current_user.siret unless current_user.siret.nil?
|
||||
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
flash.alert = t('errors.messages.dossier_not_found')
|
||||
redirect_to url_for users_dossiers_path
|
||||
end
|
||||
end
|
|
@ -10,10 +10,14 @@ class Users::DossiersController < UsersController
|
|||
end
|
||||
|
||||
def index
|
||||
liste = params[:liste] || cookies[:liste] || 'a_traiter'
|
||||
cookies[:liste] = liste
|
||||
cookies[:liste] = param_liste
|
||||
|
||||
@dossiers_list_facade = DossiersListFacades.new current_user, liste
|
||||
@dossiers_list_facade = DossiersListFacades.new current_user, param_liste
|
||||
|
||||
unless DossiersListUserService.dossiers_liste_libelle.include?(param_liste)
|
||||
cookies[:liste] = 'a_traiter'
|
||||
return redirect_to users_dossiers_path
|
||||
end
|
||||
|
||||
@dossiers = smart_listing_create :dossiers,
|
||||
@dossiers_list_facade.dossiers_to_display,
|
||||
|
@ -48,6 +52,15 @@ class Users::DossiersController < UsersController
|
|||
@facade = facade
|
||||
@siret = current_user.siret unless current_user.siret.nil?
|
||||
|
||||
if @facade.procedure.for_individual? && current_user.loged_in_with_france_connect?
|
||||
individual = @facade.dossier.individual
|
||||
|
||||
individual.update_column :gender, @facade.dossier.france_connect_information.gender
|
||||
individual.update_column :nom, @facade.dossier.france_connect_information.family_name
|
||||
individual.update_column :prenom, @facade.dossier.france_connect_information.given_name
|
||||
individual.update_column :birthdate, @facade.dossier.france_connect_information.birthdate.strftime("%d/%m/%Y")
|
||||
end
|
||||
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
flash.alert = t('errors.messages.dossier_not_found')
|
||||
redirect_to url_for users_dossiers_path
|
||||
|
@ -65,8 +78,12 @@ class Users::DossiersController < UsersController
|
|||
end
|
||||
|
||||
@facade = facade params[:dossier_id]
|
||||
render '/dossiers/new_siret', formats: 'js'
|
||||
|
||||
if @facade.procedure.individual_with_siret?
|
||||
render '/dossiers/add_siret', formats: 'js'
|
||||
else
|
||||
render '/dossiers/new_siret', formats: 'js'
|
||||
end
|
||||
rescue RestClient::ResourceNotFound, RestClient::BadRequest
|
||||
errors_valid_siret
|
||||
|
||||
|
@ -80,7 +97,11 @@ class Users::DossiersController < UsersController
|
|||
|
||||
@facade = facade params[:dossier_id]
|
||||
|
||||
render '/dossiers/new_siret', formats: :js
|
||||
if @facade.procedure.individual_with_siret?
|
||||
render '/dossiers/add_siret', formats: 'js'
|
||||
else
|
||||
render '/dossiers/new_siret', formats: 'js'
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
|
@ -124,7 +145,7 @@ class Users::DossiersController < UsersController
|
|||
end
|
||||
|
||||
def update_params
|
||||
params.require(:dossier).permit(:id, :autorisation_donnees, individual_attributes: [:nom, :prenom, :birthdate])
|
||||
params.require(:dossier).permit(:id, :autorisation_donnees, individual_attributes: [:gender, :nom, :prenom, :birthdate])
|
||||
end
|
||||
|
||||
def checked_autorisation_donnees?
|
||||
|
@ -152,4 +173,8 @@ class Users::DossiersController < UsersController
|
|||
def facade id = params[:id]
|
||||
DossierFacades.new id, current_user.email
|
||||
end
|
||||
|
||||
def param_liste
|
||||
@liste ||= params[:liste] || cookies[:liste] || 'a_traiter'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ class DossierFacades
|
|||
end
|
||||
|
||||
def entreprise
|
||||
@dossier.entreprise.decorate unless @dossier.entreprise.nil?
|
||||
@dossier.entreprise.decorate unless @dossier.entreprise.nil? || @dossier.entreprise.siren.blank?
|
||||
end
|
||||
|
||||
def etablissement
|
||||
|
@ -23,7 +23,7 @@ class DossierFacades
|
|||
end
|
||||
|
||||
def pieces_justificatives
|
||||
@dossier.pieces_justificatives
|
||||
@dossier.ordered_pieces_justificatives
|
||||
end
|
||||
|
||||
def commentaires
|
||||
|
|
|
@ -35,6 +35,10 @@ class DossiersListFacades
|
|||
@list_table_columns ||= @current_devise_profil.preference_list_dossiers.where(procedure: @procedure).order(:id)
|
||||
end
|
||||
|
||||
def brouillon_class
|
||||
(@liste == 'brouillon' ? 'active' : '')
|
||||
end
|
||||
|
||||
def nouveaux_class
|
||||
(@liste == 'nouveaux' ? 'active' : '')
|
||||
end
|
||||
|
@ -75,6 +79,14 @@ class DossiersListFacades
|
|||
(@liste == 'invite' ? 'active' : '')
|
||||
end
|
||||
|
||||
def search_class
|
||||
(@liste == 'search' ? 'active' : '')
|
||||
end
|
||||
|
||||
def brouillon_total
|
||||
service.brouillon.count
|
||||
end
|
||||
|
||||
def nouveaux_total
|
||||
service.nouveaux.count
|
||||
end
|
||||
|
@ -116,7 +128,11 @@ class DossiersListFacades
|
|||
def invite_total
|
||||
service.invite.count
|
||||
end
|
||||
|
||||
|
||||
def brouillon_url
|
||||
base_url 'brouillon'
|
||||
end
|
||||
|
||||
def nouveaux_url
|
||||
base_url 'nouveaux'
|
||||
end
|
||||
|
@ -141,6 +157,10 @@ class DossiersListFacades
|
|||
base_url 'termine'
|
||||
end
|
||||
|
||||
def filter_url
|
||||
@procedure.nil? ? backoffice_dossiers_filter_path(liste: liste) : backoffice_dossiers_procedure_filter_path(id: @procedure.id, liste: liste)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def gestionnaire?
|
||||
|
|
|
@ -3,7 +3,7 @@ class Dossier < ActiveRecord::Base
|
|||
enum state: {draft: 'draft',
|
||||
initiated: 'initiated',
|
||||
replied: 'replied', #action utilisateur demandé
|
||||
updated: 'updated',#etude par l'administration en cours
|
||||
updated: 'updated', #etude par l'administration en cours
|
||||
validated: 'validated',
|
||||
submitted: 'submitted',
|
||||
received: 'received',
|
||||
|
@ -43,6 +43,7 @@ class Dossier < ActiveRecord::Base
|
|||
|
||||
validates :user, presence: true
|
||||
|
||||
BROUILLON = %w(draft)
|
||||
NOUVEAUX = %w(initiated)
|
||||
WAITING_FOR_GESTIONNAIRE = %w(updated)
|
||||
WAITING_FOR_USER = %w(replied validated)
|
||||
|
@ -73,8 +74,6 @@ class Dossier < ActiveRecord::Base
|
|||
|
||||
def build_default_individual
|
||||
Individual.new(dossier_id: id).save(validate: false)
|
||||
Entreprise.new(dossier_id: id).save(validate: false)
|
||||
Etablissement.new(dossier_id: id, entreprise_id: entreprise.id).save(validate: false)
|
||||
end
|
||||
|
||||
def ordered_champs
|
||||
|
@ -85,6 +84,10 @@ class Dossier < ActiveRecord::Base
|
|||
champs_private.joins(', types_de_champ').where("champs.type_de_champ_id = types_de_champ.id AND types_de_champ.procedure_id = #{procedure.id}").order('order_place')
|
||||
end
|
||||
|
||||
def ordered_pieces_justificatives
|
||||
champs.joins(', types_de_piece_justificative').where("pieces_justificatives.type_de_piece_justificative_id = types_de_piece_justificative.id AND types_de_piece_justificative.procedure_id = #{procedure.id}").order('order_place ASC')
|
||||
end
|
||||
|
||||
def ordered_commentaires
|
||||
commentaires.order(created_at: :desc)
|
||||
end
|
||||
|
@ -166,6 +169,10 @@ class Dossier < ActiveRecord::Base
|
|||
state
|
||||
end
|
||||
|
||||
def brouillon?
|
||||
BROUILLON.include?(state)
|
||||
end
|
||||
|
||||
def nouveaux?
|
||||
NOUVEAUX.include?(state)
|
||||
end
|
||||
|
@ -202,6 +209,10 @@ class Dossier < ActiveRecord::Base
|
|||
TERMINE.include?(state)
|
||||
end
|
||||
|
||||
def self.brouillon order = 'ASC'
|
||||
where(state: BROUILLON, archived: false).order("updated_at #{order}")
|
||||
end
|
||||
|
||||
def self.nouveaux order = 'ASC'
|
||||
where(state: NOUVEAUX, archived: false).order("updated_at #{order}")
|
||||
end
|
||||
|
@ -239,7 +250,7 @@ class Dossier < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.search current_gestionnaire, terms
|
||||
return [], nil if terms.blank?
|
||||
return [] if terms.blank?
|
||||
|
||||
dossiers = Dossier.arel_table
|
||||
users = User.arel_table
|
||||
|
@ -257,24 +268,16 @@ class Dossier < ActiveRecord::Base
|
|||
composed_scope = composed_scope.where(
|
||||
users[:email].matches(query_string).or\
|
||||
etablissements[:siret].matches(query_string_start_with).or\
|
||||
entreprises[:raison_sociale].matches(query_string))
|
||||
entreprises[:raison_sociale].matches(query_string).or\
|
||||
dossiers[:id].eq(word_is_an_integer word))
|
||||
end
|
||||
|
||||
#TODO refactor
|
||||
composed_scope = composed_scope.where(
|
||||
dossiers[:id].eq_any(current_gestionnaire.dossiers.ids).and\
|
||||
dossiers[:state].does_not_match('draft').and\
|
||||
dossiers[:archived].eq(false))
|
||||
|
||||
begin
|
||||
if Float(terms) && terms.to_i <= 2147483647 && current_gestionnaire.dossiers.ids.include?(terms.to_i)
|
||||
dossier = Dossier.where("state != 'draft'").find(terms.to_i)
|
||||
end
|
||||
rescue ArgumentError, ActiveRecord::RecordNotFound
|
||||
dossier = nil
|
||||
end
|
||||
|
||||
return composed_scope, dossier
|
||||
composed_scope
|
||||
end
|
||||
|
||||
def cerfa_available?
|
||||
|
@ -283,13 +286,19 @@ class Dossier < ActiveRecord::Base
|
|||
|
||||
def as_csv(options={})
|
||||
dossier_attr = DossierSerializer.new(self).attributes
|
||||
etablissement_attr = EtablissementCsvSerializer.new(self.etablissement).attributes.map {|k, v| ["etablissement.#{k}", v] }.to_h
|
||||
entreprise_attr = EntrepriseSerializer.new(self.entreprise).attributes.map {|k, v| ["entreprise.#{k}", v] }.to_h
|
||||
dossier_attr.merge(etablissement_attr).merge(entreprise_attr)
|
||||
|
||||
unless entreprise.nil?
|
||||
etablissement_attr = EtablissementCsvSerializer.new(self.etablissement).attributes.map { |k, v| ["etablissement.#{k}", v] }.to_h
|
||||
entreprise_attr = EntrepriseSerializer.new(self.entreprise).attributes.map { |k, v| ["entreprise.#{k}", v] }.to_h
|
||||
dossier_attr = dossier_attr.merge(etablissement_attr).merge(entreprise_attr)
|
||||
end
|
||||
|
||||
dossier_attr
|
||||
end
|
||||
|
||||
def reset!
|
||||
entreprise.destroy unless entreprise.nil?
|
||||
etablissement.destroy
|
||||
entreprise.destroy
|
||||
|
||||
update_attributes(autorisation_donnees: false)
|
||||
end
|
||||
|
@ -308,7 +317,7 @@ class Dossier < ActiveRecord::Base
|
|||
next_step! 'user', 'submit'
|
||||
NotificationMailer.dossier_submitted(self).deliver_now!
|
||||
end
|
||||
|
||||
|
||||
def read_only?
|
||||
validated? || received? || submitted? || closed? || refused? || without_continuation?
|
||||
end
|
||||
|
@ -320,4 +329,12 @@ class Dossier < ActiveRecord::Base
|
|||
def invite_by_user? email
|
||||
(invites_user.pluck :email).include? email
|
||||
end
|
||||
|
||||
def self.word_is_an_integer word
|
||||
return 0 if Float(word) > 2147483647
|
||||
|
||||
Float(word)
|
||||
rescue ArgumentError
|
||||
0
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,6 +4,7 @@ class Entreprise < ActiveRecord::Base
|
|||
has_one :rna_information, dependent: :destroy
|
||||
|
||||
validates_presence_of :siren
|
||||
validates_uniqueness_of :dossier_id
|
||||
|
||||
before_save :default_values
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ class Etablissement < ActiveRecord::Base
|
|||
|
||||
has_many :exercices, dependent: :destroy
|
||||
|
||||
validates_uniqueness_of :dossier_id
|
||||
|
||||
def geo_adresse
|
||||
[numero_voie, type_voie, nom_voie, complement_adresse, code_postal, localite].join(' ')
|
||||
end
|
||||
|
|
|
@ -4,6 +4,8 @@ class Gestionnaire < ActiveRecord::Base
|
|||
|
||||
has_and_belongs_to_many :administrateurs
|
||||
|
||||
has_one :preference_smart_listing_page, dependent: :destroy
|
||||
|
||||
has_many :assign_to, dependent: :destroy
|
||||
has_many :procedures, through: :assign_to
|
||||
has_many :dossiers, through: :procedures
|
||||
|
@ -11,6 +13,7 @@ class Gestionnaire < ActiveRecord::Base
|
|||
has_many :preference_list_dossiers
|
||||
|
||||
after_create :build_default_preferences_list_dossier
|
||||
after_create :build_default_preferences_smart_listing_page
|
||||
|
||||
def dossiers_follow
|
||||
dossiers.joins(:follows).where("follows.gestionnaire_id = #{id}")
|
||||
|
@ -33,9 +36,9 @@ class Gestionnaire < ActiveRecord::Base
|
|||
Follow.where(gestionnaire_id: id, dossier_id: dossier_id).any?
|
||||
end
|
||||
|
||||
def build_default_preferences_list_dossier
|
||||
def build_default_preferences_list_dossier procedure_id=nil
|
||||
|
||||
PreferenceListDossier.available_columns_for.each do |table|
|
||||
PreferenceListDossier.available_columns_for(procedure_id).each do |table|
|
||||
table.second.each do |column|
|
||||
|
||||
if valid_couple_table_attr? table.first, column.first
|
||||
|
@ -47,6 +50,7 @@ class Gestionnaire < ActiveRecord::Base
|
|||
bootstrap_lg: column.second[:bootstrap_lg],
|
||||
order: nil,
|
||||
filter: nil,
|
||||
procedure_id: procedure_id,
|
||||
gestionnaire: self
|
||||
)
|
||||
end
|
||||
|
@ -54,6 +58,10 @@ class Gestionnaire < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def build_default_preferences_smart_listing_page
|
||||
PreferenceSmartListingPage.create(page: 1, procedure: nil, gestionnaire: self, liste: 'a_traiter')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_couple_table_attr? table, column
|
||||
|
|
|
@ -7,6 +7,11 @@ class PreferenceListDossier < ActiveRecord::Base
|
|||
table + '.' + attr
|
||||
end
|
||||
|
||||
def table_with_s_attr
|
||||
return 'dossiers.'+self.attr if table.nil? || table.empty?
|
||||
table + 's' + '.' + attr
|
||||
end
|
||||
|
||||
def self.available_columns_for procedure_id = nil
|
||||
columns = {
|
||||
dossier: columns_dossier,
|
||||
|
|
11
app/models/preference_smart_listing_page.rb
Normal file
11
app/models/preference_smart_listing_page.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
class PreferenceSmartListingPage < ActiveRecord::Base
|
||||
belongs_to :gestionnaire
|
||||
belongs_to :procedure
|
||||
|
||||
validates :page, presence: true, allow_blank: false, allow_nil: false
|
||||
validates :liste, presence: true, allow_blank: false, allow_nil: false
|
||||
validates :procedure, presence: true, allow_blank: true, allow_nil: true
|
||||
validates :gestionnaire, presence: true, allow_blank: false, allow_nil: false
|
||||
|
||||
validates_uniqueness_of :gestionnaire_id
|
||||
end
|
|
@ -89,7 +89,7 @@ class Procedure < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def clone
|
||||
procedure = self.deep_clone(include: [:types_de_piece_justificative, :types_de_champ, :types_de_champ_private, :module_api_carto, :mail_templates])
|
||||
procedure = self.deep_clone(include: [:types_de_piece_justificative, :types_de_champ, :types_de_champ_private, :module_api_carto, :mail_templates, types_de_champ: [:drop_down_list]])
|
||||
procedure.archived = false
|
||||
procedure.published = false
|
||||
procedure.logo_secure_token = nil
|
||||
|
|
|
@ -24,13 +24,19 @@ class TypeDeChamp < ActiveRecord::Base
|
|||
|
||||
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||
validates :type_champ, presence: true, allow_blank: false, allow_nil: false
|
||||
# validates :order_place, presence: true, allow_blank: false, allow_nil: false
|
||||
|
||||
before_validation :change_header_section_mandatory
|
||||
|
||||
def self.type_de_champs_list_fr
|
||||
type_champs.map { |champ| [ I18n.t("activerecord.attributes.type_de_champ.type_champs.#{champ.last}"), champ.first ] }
|
||||
type_champs.map { |champ| [I18n.t("activerecord.attributes.type_de_champ.type_champs.#{champ.last}"), champ.first] }
|
||||
end
|
||||
|
||||
def field_for_list?
|
||||
!(type_champ == 'textarea' || type_champ == 'header_section')
|
||||
end
|
||||
|
||||
def change_header_section_mandatory
|
||||
self.mandatory = false if self.type_champ == 'header_section'
|
||||
true
|
||||
end
|
||||
end
|
|
@ -2,23 +2,24 @@ class AccompagnateurService
|
|||
ASSIGN = 'assign'
|
||||
NOT_ASSIGN = 'not_assign'
|
||||
|
||||
def self.change_assignement! accompagnateur, procedure, to
|
||||
if to == ASSIGN
|
||||
AssignTo.create(gestionnaire: accompagnateur, procedure: procedure)
|
||||
elsif to == NOT_ASSIGN
|
||||
AssignTo.delete_all(gestionnaire: accompagnateur, procedure: procedure)
|
||||
def initialize accompagnateur, procedure, to
|
||||
@accompagnateur = accompagnateur
|
||||
@procedure = procedure
|
||||
@to = to
|
||||
end
|
||||
|
||||
def change_assignement!
|
||||
if @to == ASSIGN
|
||||
AssignTo.create(gestionnaire: @accompagnateur, procedure: @procedure)
|
||||
elsif @to == NOT_ASSIGN
|
||||
AssignTo.delete_all(gestionnaire: @accompagnateur, procedure: @procedure)
|
||||
end
|
||||
end
|
||||
|
||||
def self.build_default_column accompagnateur, procedure, to
|
||||
return unless to == ASSIGN
|
||||
return unless PreferenceListDossier.where(gestionnaire: accompagnateur, procedure: procedure).empty?
|
||||
def build_default_column
|
||||
return unless @to == ASSIGN
|
||||
return unless PreferenceListDossier.where(gestionnaire: @accompagnateur, procedure: @procedure).empty?
|
||||
|
||||
accompagnateur.preference_list_dossiers.each do |pref|
|
||||
clone = pref.dup
|
||||
|
||||
clone.procedure = procedure
|
||||
clone.save
|
||||
end
|
||||
@accompagnateur.build_default_preferences_list_dossier @procedure.id
|
||||
end
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
class ChampsService
|
||||
def self.save_formulaire champs, params
|
||||
def self.save_formulaire champs, params, check_mandatory=true
|
||||
errors = Array.new
|
||||
|
||||
champs.each do |champ|
|
||||
|
@ -13,8 +13,10 @@ class ChampsService
|
|||
params[:time_minute]["'#{champ.id}'"]
|
||||
end
|
||||
|
||||
if champ.mandatory? && (champ.value.nil? || champ.value.blank?)
|
||||
errors.push({message: "Le champ #{champ.libelle} doit être rempli."})
|
||||
if check_mandatory
|
||||
if champ.mandatory? && (champ.value.nil? || champ.value.blank?)
|
||||
errors.push({message: "Le champ #{champ.libelle} doit être rempli."})
|
||||
end
|
||||
end
|
||||
|
||||
champ.save
|
||||
|
|
|
@ -14,6 +14,10 @@ class DossiersListGestionnaireService
|
|||
'termine' => termine}[@liste]
|
||||
end
|
||||
|
||||
def self.dossiers_liste_libelle
|
||||
['nouveaux', 'a_traiter', 'en_attente', 'deposes', 'a_instruire', 'termine']
|
||||
end
|
||||
|
||||
def nouveaux
|
||||
@nouveaux ||= filter_dossiers.nouveaux
|
||||
end
|
||||
|
@ -39,6 +43,128 @@ class DossiersListGestionnaireService
|
|||
end
|
||||
|
||||
def filter_dossiers
|
||||
@filter_dossiers ||= @procedure.nil? ? @current_devise_profil.dossiers : @procedure.dossiers
|
||||
@filter_dossiers ||= @procedure.nil? ? @current_devise_profil.dossiers.joins(joins_filter).where(where_filter) : @procedure.dossiers.joins(joins_filter).where(where_filter)
|
||||
end
|
||||
|
||||
def filter_procedure_reset!
|
||||
filter_procedure! nil
|
||||
end
|
||||
|
||||
def filter_procedure! procedure_id
|
||||
@current_devise_profil.update_column :procedure_filter, procedure_id
|
||||
end
|
||||
|
||||
def default_sort
|
||||
sort_preference = @current_devise_profil.preference_list_dossiers
|
||||
.where(procedure: @procedure)
|
||||
.where.not(order: nil).first
|
||||
|
||||
return {'nil' => 'nil'} if sort_preference.nil?
|
||||
|
||||
{
|
||||
[sort_preference.table, sort_preference.attr]
|
||||
.reject(&:nil?)
|
||||
.join('.') => sort_preference.order
|
||||
}
|
||||
end
|
||||
|
||||
def default_page
|
||||
pref = current_preference_smart_listing_page
|
||||
return pref.page if pref.procedure == @procedure && pref.liste == @liste
|
||||
|
||||
1
|
||||
end
|
||||
|
||||
def change_page! new_page
|
||||
pref = current_preference_smart_listing_page
|
||||
|
||||
unless pref.liste == @liste && pref.procedure == @procedure
|
||||
pref.liste = @liste
|
||||
pref.procedure = @procedure
|
||||
|
||||
if new_page.nil?
|
||||
pref.page = 1
|
||||
pref.save
|
||||
end
|
||||
end
|
||||
|
||||
unless new_page.nil?
|
||||
pref.page = new_page
|
||||
pref.save
|
||||
end
|
||||
end
|
||||
|
||||
def change_sort! new_sort
|
||||
return if new_sort.blank?
|
||||
|
||||
raw_table_attr = new_sort.keys.first.split('.')
|
||||
order = new_sort.values.first
|
||||
|
||||
table = (raw_table_attr.size == 2 ? raw_table_attr.first : nil)
|
||||
attr = (raw_table_attr.size == 2 ? raw_table_attr.second : raw_table_attr.first)
|
||||
|
||||
reset_sort!
|
||||
|
||||
@current_devise_profil.preference_list_dossiers
|
||||
.find_by(table: table, attr: attr, procedure: @procedure)
|
||||
.update order: order
|
||||
end
|
||||
|
||||
def reset_sort!
|
||||
@current_devise_profil.preference_list_dossiers
|
||||
.where(procedure: @procedure)
|
||||
.where.not(order: nil)
|
||||
.update_all order: nil
|
||||
end
|
||||
|
||||
def joins_filter
|
||||
filter_preference_list.inject([]) do |acc, preference|
|
||||
acc.push(preference.table.to_sym) unless preference.table.blank?
|
||||
acc
|
||||
end
|
||||
end
|
||||
|
||||
def where_filter
|
||||
filter_preference_list.inject('') do |acc, preference|
|
||||
unless preference.filter.blank?
|
||||
filter = preference.filter.gsub('*', '%')
|
||||
filter = "%"+filter+"%" unless filter.include? '%'
|
||||
|
||||
acc += (acc.to_s.empty? ? ''.to_s : " AND ") +
|
||||
"CAST(" +
|
||||
preference.table_with_s_attr +
|
||||
" as TEXT)" +
|
||||
" LIKE " +
|
||||
"'" +
|
||||
filter +
|
||||
"'"
|
||||
end
|
||||
acc
|
||||
end
|
||||
end
|
||||
|
||||
def add_filter new_filter
|
||||
raw_table_attr = new_filter.keys.first.split('.')
|
||||
filter = new_filter.values.first
|
||||
|
||||
table = (raw_table_attr.size == 2 ? raw_table_attr.first : nil)
|
||||
attr = (raw_table_attr.size == 2 ? raw_table_attr.second : raw_table_attr.first)
|
||||
|
||||
@current_devise_profil.preference_list_dossiers
|
||||
.find_by(table: table, attr: attr, procedure: @procedure)
|
||||
.update filter: filter
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def filter_preference_list
|
||||
@filter_preference ||= @current_devise_profil.preference_list_dossiers
|
||||
.where(procedure: @procedure)
|
||||
.where.not(filter: nil)
|
||||
.order(:id)
|
||||
end
|
||||
|
||||
def current_preference_smart_listing_page
|
||||
@current_devise_profil.preference_smart_listing_page
|
||||
end
|
||||
end
|
|
@ -5,7 +5,8 @@ class DossiersListUserService
|
|||
end
|
||||
|
||||
def dossiers_to_display
|
||||
{'nouveaux' => nouveaux,
|
||||
{'brouillon' => brouillon,
|
||||
'nouveaux' => nouveaux,
|
||||
'a_traiter' => waiting_for_user,
|
||||
'en_attente' => waiting_for_gestionnaire,
|
||||
'valides' => valides,
|
||||
|
@ -14,6 +15,14 @@ class DossiersListUserService
|
|||
'invite' => invite}[@liste]
|
||||
end
|
||||
|
||||
def self.dossiers_liste_libelle
|
||||
['brouillon', 'nouveaux', 'a_traiter', 'en_attente', 'valides', 'en_instruction', 'termine', 'invite']
|
||||
end
|
||||
|
||||
def brouillon
|
||||
@brouillon ||= @current_devise_profil.dossiers.brouillon
|
||||
end
|
||||
|
||||
def nouveaux
|
||||
@nouveaux ||= @current_devise_profil.dossiers.nouveaux
|
||||
end
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
%h4 Drapeau européen
|
||||
%label
|
||||
=f.check_box :euro_flag
|
||||
Afficher le drapeau européen
|
||||
Afficher le drapeau européen
|
||||
|
||||
%br
|
||||
|
||||
|
@ -60,9 +60,16 @@
|
|||
.row
|
||||
.col-md-6.col-lg-6
|
||||
%h4 Particuliers
|
||||
%label
|
||||
=f.check_box :for_individual
|
||||
Cette procédure s'adresse à un public qui
|
||||
%b
|
||||
ne possède pas de numéro SIRET,
|
||||
qui doivent donc s'identifier en tant que personne physique.
|
||||
%div
|
||||
%label
|
||||
=f.check_box :for_individual
|
||||
Cette procédure s'adresse à un public qui
|
||||
%b
|
||||
ne possède pas (ou pas encore) de numéro SIRET,
|
||||
qui doivent donc s'identifier en tant que personne physique.
|
||||
|
||||
%ul#individual_with_siret{style:'margin-top: 8px'}
|
||||
%li
|
||||
%label
|
||||
=f.check_box :individual_with_siret
|
||||
Donner la possibilité de renseigner un SIRET au cours de la construction du dossier.
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
= text_field_tag :email_admin, '', {class: 'form-control',
|
||||
type: 'email',
|
||||
placeholder: 'Email administrateur cible',
|
||||
maxlength: 30,
|
||||
style: 'width: 300px; margin-left:auto; margin-right:auto'}
|
||||
%div#not_found_admin.center.text-danger{style:'display:none; margin-top: 10px'}
|
||||
Cet administrateur n'existe pas.
|
||||
|
|
8
app/views/backoffice/dossiers/_filter_framed.html.haml
Normal file
8
app/views/backoffice/dossiers/_filter_framed.html.haml
Normal file
|
@ -0,0 +1,8 @@
|
|||
%div.filter_framed.panel.panel-primary{id: "#{filter_framed_id}", style:'width: 300px; height: 100px; position: absolute; top: 0; left: 0; display: none'}
|
||||
.panel-heading
|
||||
= preference.libelle
|
||||
|
||||
=form_tag @dossiers_list_facade.filter_url, {class: 'panel-body form-inline', method: :post} do
|
||||
%input.form-control.filter_input{name: "filter_input[#{preference.table_attr}]", style:'width: 84%', value: "#{preference.filter}"}
|
||||
%button.btn.btn-sm.btn-success
|
||||
%i.fa.fa-check
|
|
@ -1,16 +1,18 @@
|
|||
- unless smart_listing.empty?
|
||||
%table.table
|
||||
%thead
|
||||
- @dossiers_list_facade.preference_list_dossiers_filter.each do |preference|
|
||||
%th{class: "col-md-#{preference.bootstrap_lg} col-lg-#{preference.bootstrap_lg}"}
|
||||
- if preference.table == 'champs'
|
||||
= preference.libelle
|
||||
-else
|
||||
= smart_listing.sortable preference.libelle, preference.table_attr
|
||||
%table.table
|
||||
%thead
|
||||
- @dossiers_list_facade.preference_list_dossiers_filter.each do |preference|
|
||||
%th{class: "col-md-#{preference.bootstrap_lg} col-lg-#{preference.bootstrap_lg}"}
|
||||
- if preference.table == 'champs'
|
||||
= preference.libelle
|
||||
-else
|
||||
= smart_listing.sortable preference.libelle, preference.table_attr
|
||||
%i.filter.fa.fa-filter{style: "cursor: pointer; margin-left:3px; font-size: 1.1em; color:#{(preference.filter.blank? ? 'grey' : 'orange')}", id: "filter_"+preference.table_attr.sub('.', '_')}
|
||||
= render partial: 'backoffice/dossiers/filter_framed', locals:{preference: preference, filter_framed_id: "framed_filter_"+preference.table_attr.sub('.', '_')}
|
||||
|
||||
%th.col-md-1.col-lg-1.center Actions
|
||||
%th.col-md-1.col-lg-1.center Abonnés
|
||||
%th.col-md-1.col-lg-1.center Actions
|
||||
%th.col-md-1.col-lg-1.center Abonnés
|
||||
|
||||
- unless smart_listing.empty?
|
||||
- @dossiers.each do |dossier|
|
||||
%tr
|
||||
- @dossiers_list_facade.preference_list_dossiers_filter.each_with_index do |preference, index|
|
||||
|
@ -38,9 +40,9 @@
|
|||
%td.center{style:"color: #{dossier.total_follow == 0 ? 'red' : ''}"}
|
||||
= dossier.total_follow
|
||||
|
||||
= smart_listing.paginate
|
||||
= smart_listing.pagination_per_page_links
|
||||
= smart_listing.paginate
|
||||
= smart_listing.pagination_per_page_links
|
||||
|
||||
- else
|
||||
- if smart_listing.empty?
|
||||
%h4.center
|
||||
Aucun dossier
|
|
@ -53,7 +53,7 @@
|
|||
=@dossiers_list_facade.termine_total
|
||||
|
||||
%ul.nav.nav-tabs.navbar-right{style:'border-bottom: none;'}
|
||||
%li#search{class: "#{'active' unless @dossiers_search.nil?}"}
|
||||
%li#search{ class: (@dossiers_list_facade.search_class) }
|
||||
%a
|
||||
= form_tag(backoffice_dossiers_search_url, method: :get) do
|
||||
.input-group{style:'width: 300px'}
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
<%= smart_listing_update :dossiers %>
|
||||
|
||||
filters_init();
|
|
@ -1,45 +1,4 @@
|
|||
#backoffice_search
|
||||
= render partial: 'onglets'
|
||||
|
||||
- unless @dossier.nil?
|
||||
%table.table{style:'background-color: rgba(248, 248, 255, 0.8)'}
|
||||
%tr
|
||||
%th{colspan:2}
|
||||
%h4
|
||||
= "Dossier N°#{@dossier.id}"
|
||||
%tr
|
||||
%td.col-md-1.col-lg-1
|
||||
= @dossier.id
|
||||
%td.col-md-4.col-lg-4
|
||||
= @dossier.procedure.libelle
|
||||
%td.col-md-4.col-lg-4
|
||||
= link_to(@dossier.entreprise.raison_sociale, "/backoffice/dossiers/#{@dossier.id}")
|
||||
%td.col-md-2.col-lg-2
|
||||
= @dossier.user.email
|
||||
%td.col-md-1.col-lg-1{class: @dossier.state_color_class}
|
||||
= @dossier.display_state
|
||||
%br
|
||||
|
||||
- if @dossiers_search.empty? && @dossier.nil?
|
||||
%div{style: 'text-align:center'}
|
||||
%h4 Aucun dossier trouvé
|
||||
|
||||
- elsif !@dossiers_search.empty?
|
||||
%table.table
|
||||
%tr
|
||||
%th.col-md-1.col-lg-1 ID dossier
|
||||
%th.col-md-4.col-lg-4 Procédure
|
||||
%th.col-md-4.col-lg-4 Raison Sociale
|
||||
%th.col-md-2.col-lg-2 Email contact
|
||||
%th.col-md-1.col-lg-1 État
|
||||
|
||||
- @dossiers_search.each do |dossier|
|
||||
%tr
|
||||
%td= dossier.id
|
||||
%td= dossier.procedure.libelle
|
||||
%td= link_to(dossier.entreprise.raison_sociale, "/backoffice/dossiers/#{dossier.id}")
|
||||
%td= dossier.user.email
|
||||
%td{class: dossier.state_color_class}= dossier.display_state
|
||||
|
||||
.pagination
|
||||
= will_paginate @dossiers_search, renderer: BootstrapPagination::Rails
|
||||
= smart_listing_render :dossiers
|
|
@ -7,7 +7,7 @@
|
|||
= @facade.dossier.display_state
|
||||
|
||||
= render partial: 'follow_action'
|
||||
- unless @facade.procedure.for_individual?
|
||||
- unless @facade.entreprise.nil?
|
||||
= render partial: '/dossiers/infos_entreprise'
|
||||
|
||||
= render partial: '/dossiers/infos_dossier'
|
||||
|
|
|
@ -54,6 +54,9 @@
|
|||
= render partial: 'users/recapitulatif/modal_upload_pj'
|
||||
|
||||
|
||||
-if @facade.procedure.individual_with_siret
|
||||
%a#add_siret.btn.btn-success{href: users_dossier_add_siret_path(dossier_id: @facade.dossier.id)}
|
||||
= "Renseigner un SIRET"
|
||||
-if @facade.dossier.procedure.module_api_carto.use_api_carto
|
||||
%a#maj_carte.btn.btn-primary{href: "/users/dossiers/#{@facade.dossier.id}/carte"}
|
||||
= 'Modifier la carte'
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
- else
|
||||
= 'Pièce non fournie'
|
||||
|
||||
- @facade.dossier.types_de_piece_justificative.each do |type_de_piece_justificative|
|
||||
- @facade.dossier.types_de_piece_justificative.order('order_place ASC').each do |type_de_piece_justificative|
|
||||
%tr{ id: "piece_justificative_#{type_de_piece_justificative.id}" }
|
||||
%th.col-lg-6
|
||||
= type_de_piece_justificative.libelle
|
||||
|
|
12
app/views/dossiers/add_siret.js.erb
Normal file
12
app/views/dossiers/add_siret.js.erb
Normal file
|
@ -0,0 +1,12 @@
|
|||
<% if flash.empty? %>
|
||||
$('.row.etape.etape_2').hide(300, render_new_siret);
|
||||
$('.row.etape.etape_2').slideDown(400, the_terms);
|
||||
<% else %>
|
||||
error_form_siret('<%= invalid_siret %>');
|
||||
<% end %>
|
||||
|
||||
<% flash.clear %>
|
||||
|
||||
function render_new_siret(){
|
||||
$('.row.etape.etape_2').html("<%= escape_javascript(render partial: '/dossiers/etapes/etape_2/entreprise', locals: { facade: @facade } ) %>");
|
||||
}
|
|
@ -13,6 +13,11 @@
|
|||
= f.hidden_field :id
|
||||
|
||||
= f.fields_for :individual, @facade.individual do |ff|
|
||||
.form-group
|
||||
%label
|
||||
%h4
|
||||
Civilité
|
||||
= ff.select :gender, ['Mr', 'Mme']
|
||||
.form-group
|
||||
%label
|
||||
%h4
|
||||
|
|
|
@ -8,7 +8,6 @@ error_form_siret('<%= invalid_siret %>');
|
|||
|
||||
<% flash.clear %>
|
||||
|
||||
|
||||
function render_new_siret(){
|
||||
$('.row.etape.etape_2').html("<%= escape_javascript(render partial: '/dossiers/etapes/etape2', locals: { facade: @facade } ) %>");
|
||||
}
|
|
@ -6,10 +6,15 @@
|
|||
= image_tag('marianne_small.png', class: 'logo')
|
||||
%a{href: '/'}
|
||||
= image_tag('logo-tps.png', class: 'logo')
|
||||
%a{href: '/', class: 'btn btn-md'}
|
||||
-if gestionnaire_signed_in? || user_signed_in?
|
||||
|
||||
- if gestionnaire_signed_in?
|
||||
%a{href: (current_gestionnaire.procedure_filter.blank? ? '/' : backoffice_dossiers_procedure_path(current_gestionnaire.procedure_filter)), class: 'btn btn-md'}
|
||||
Mes Dossiers
|
||||
-elsif administrateur_signed_in?
|
||||
- elsif user_signed_in?
|
||||
%a{href: '/', class: 'btn btn-md'}
|
||||
Mes Dossiers
|
||||
- elsif administrateur_signed_in?
|
||||
%a{href: '/', class: 'btn btn-md'}
|
||||
Mes Procédures
|
||||
|
||||
#sign_out
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
-else
|
||||
%input{type: 'file', name:'cerfa_pdf', id:'cerfa_pdf', accept: PieceJustificative.accept_format, :max_file_size => 3.megabytes }
|
||||
|
||||
- @dossier.types_de_piece_justificative.each do |type_de_piece_justificative|
|
||||
- @dossier.types_de_piece_justificative.order('order_place ASC').each do |type_de_piece_justificative|
|
||||
%tr
|
||||
%th.col-lg-6
|
||||
= type_de_piece_justificative.libelle
|
||||
|
|
|
@ -56,7 +56,8 @@
|
|||
-if !@dossier.draft?
|
||||
=render partial: '/layouts/modifications_terminees'
|
||||
-else
|
||||
= submit_tag 'Soumettre mon dossier', id: 'suivant', class: %w(btn btn btn-success), style: 'float:right', data: { disable_with: 'Soumettre votre dossier', submit: true}
|
||||
= submit_tag 'Soumettre mon dossier', id: 'suivant', name: 'submit[nouveaux]', class: %w(btn btn btn-success), style: 'float:right', data: { disable_with: 'Soumettre votre dossier', submit: true}
|
||||
= submit_tag 'Enregistrer un brouillon', id: 'brouillon', name: 'submit[brouillon]', class: %w(btn btn-xs btn-default), style: 'float:right; margin-right: 10px; margin-top: 6px', data: {disable_with: 'Enregistrer un brouillon', submit: true}
|
||||
|
||||
%br
|
||||
%br
|
|
@ -1,13 +1,14 @@
|
|||
%select{ name:"champs['#{champ.id}']",
|
||||
id: "champs_#{champ.id}" }
|
||||
- champ.drop_down_list.options.each do |option|
|
||||
- if (option=~ /^--.*--$/).nil?
|
||||
- if champ.value == option
|
||||
%option{selected:''}
|
||||
- unless champ.drop_down_list.blank?
|
||||
- champ.drop_down_list.options.each do |option|
|
||||
- if (option=~ /^--.*--$/).nil?
|
||||
- if champ.value == option
|
||||
%option{selected:''}
|
||||
= option
|
||||
- else
|
||||
%option
|
||||
= option
|
||||
-else
|
||||
%option{disabled:''}
|
||||
= option
|
||||
- else
|
||||
%option
|
||||
= option
|
||||
-else
|
||||
%option{disabled:''}
|
||||
= option
|
||||
|
|
|
@ -16,7 +16,10 @@
|
|||
= dossier.id
|
||||
%td
|
||||
= link_to(dossier.procedure.libelle, users_dossiers_invite_path(id: invite.id)) unless invite.nil?
|
||||
= link_to(dossier.procedure.libelle, users_dossier_recapitulatif_path(dossier)) if invite.nil?
|
||||
- if invite.nil?
|
||||
= link_to(dossier.procedure.libelle, users_dossier_recapitulatif_path(dossier)) unless dossier.brouillon?
|
||||
= link_to(dossier.procedure.libelle, users_dossier_description_path(dossier)) if dossier.brouillon?
|
||||
|
||||
|
||||
%td{id: "dossier_#{dossier.id}_state"}= dossier.display_state
|
||||
%td= dossier.last_update
|
||||
|
|
|
@ -3,6 +3,13 @@
|
|||
%br
|
||||
#onglets
|
||||
%ul.nav.nav-tabs
|
||||
%li{ class: @dossiers_list_facade.brouillon_class }
|
||||
%a{:href => "#{url_for users_dossiers_path(liste: 'brouillon')}", 'data-toggle' => :tooltip, title: 'Les dossiers jamais proposés à la relecture.'}
|
||||
%h5.text-default
|
||||
= "Brouillons"
|
||||
.badge.progress-bar-default
|
||||
= @dossiers_list_facade.brouillon_total
|
||||
|
||||
%li{ class: @dossiers_list_facade.nouveaux_class }
|
||||
%a{:href => "#{url_for users_dossiers_path(liste: 'nouveaux')}", 'data-toggle' => :tooltip, title: 'Les nouveaux dossiers qui n\'ont pas encore été vus par votre accompagnateur.'}
|
||||
%h5.text-info
|
||||
|
|
|
@ -5,7 +5,12 @@
|
|||
.col-md-1.col-lg-1
|
||||
.fa.fa-info-circle.text-info{style:'font-size: 2em; margin-top: 20%'}
|
||||
.col-md-11.col-lg-11
|
||||
-if dossiers_list_facade.liste == 'nouveaux'
|
||||
-if dossiers_list_facade.liste == 'brouillon'
|
||||
Les dossiers présents dans cette liste
|
||||
%b
|
||||
n'ont pas encore été soumis à votre administrations.
|
||||
Ils ne sont visible que par vous.
|
||||
-elsif dossiers_list_facade.liste == 'nouveaux'
|
||||
Les dossiers présents dans cette liste
|
||||
%b
|
||||
n'ont pas encore été ouverts
|
||||
|
|
2
app/views/users/dossiers/add_siret/show.html.haml
Normal file
2
app/views/users/dossiers/add_siret/show.html.haml
Normal file
|
@ -0,0 +1,2 @@
|
|||
.row.etape.etape_2
|
||||
= render partial: 'dossiers/etapes/etape_2/entreprise'
|
|
@ -11,11 +11,10 @@ require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
|
|||
# branch - Branch name to deploy. (needed by mina/git)
|
||||
|
||||
ENV['to'] ||= "staging"
|
||||
ENV['to'] = "staging" unless ["staging", "production"].include?(ENV['to'])
|
||||
ENV['to'] = "staging" unless ["staging", "production", "opensimplif"].include?(ENV['to'])
|
||||
|
||||
raise "missing domain, run with 'rake deploy domain=37.187.154.237'" if ENV['domain'].nil?
|
||||
|
||||
|
||||
print "Deploy to #{ENV['to']} environment branch #{branch}\n"
|
||||
|
||||
# set :domain, '5.135.190.60'
|
||||
|
@ -25,7 +24,6 @@ set :port, 2200
|
|||
|
||||
set :deploy_to, '/var/www/tps_dev'
|
||||
|
||||
|
||||
if ENV["to"] == "staging"
|
||||
if ENV['branch'].nil?
|
||||
set :branch, 'staging'
|
||||
|
@ -44,10 +42,24 @@ elsif ENV["to"] == "production"
|
|||
set :deploy_to, '/var/www/tps'
|
||||
set :user, 'tps' # Username in the server to SSH to.
|
||||
appname = 'tps'
|
||||
elsif ENV["to"] == "opensimplif"
|
||||
if ENV['branch'].nil?
|
||||
set :branch, 'master'
|
||||
else
|
||||
set :branch, ENV['branch']
|
||||
end
|
||||
set :deploy_to, '/var/www/opensimplif'
|
||||
set :user, 'opensimplif' # Username in the server to SSH to.
|
||||
appname = 'opensimplif'
|
||||
end
|
||||
|
||||
|
||||
set :rails_env, ENV["to"]
|
||||
|
||||
if ENV["to"] == "opensimplif"
|
||||
set :rails_env, "production"
|
||||
end
|
||||
|
||||
# For system-wide RVM install.
|
||||
# set :rvm_path, '/usr/local/rvm/bin/rvm'
|
||||
|
||||
|
@ -66,7 +78,7 @@ set :shared_paths, [
|
|||
"config/fog_credentials.yml",
|
||||
'config/initializers/secret_token.rb',
|
||||
'config/initializers/features.yml',
|
||||
"config/environments/#{ENV['to']}.rb",
|
||||
"config/environments/#{rails_env}.rb",
|
||||
"config/initializers/token.rb",
|
||||
"config/initializers/urls.rb",
|
||||
"config/initializers/super_admin.rb",
|
||||
|
@ -74,7 +86,8 @@ set :shared_paths, [
|
|||
"config/initializers/raven.rb",
|
||||
'config/france_connect.yml',
|
||||
'config/initializers/mailjet.rb',
|
||||
'config/initializers/storage_url.rb'
|
||||
'config/initializers/storage_url.rb',
|
||||
'app/views/root/landing.html.haml'
|
||||
]
|
||||
|
||||
|
||||
|
@ -112,6 +125,9 @@ task :setup => :environment do
|
|||
queue! %[mkdir -p "#{deploy_to}/shared/config"]
|
||||
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/config"]
|
||||
|
||||
queue! %[mkdir -p "#{deploy_to}/shared/app"]
|
||||
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/app"]
|
||||
|
||||
queue! %[touch "#{deploy_to}/shared/config/database.yml"]
|
||||
queue %[echo "-----> Be sure to edit 'shared/config/database.yml'."]
|
||||
|
||||
|
|
|
@ -62,6 +62,8 @@ Rails.application.routes.draw do
|
|||
end
|
||||
|
||||
resources :dossiers do
|
||||
get '/add_siret' => 'dossiers/add_siret#show'
|
||||
|
||||
get '/description' => 'description#show'
|
||||
get '/description/error' => 'description#error'
|
||||
post 'description' => 'description#create'
|
||||
|
@ -162,8 +164,12 @@ Rails.application.routes.draw do
|
|||
put 'follow' => 'dossiers#follow'
|
||||
end
|
||||
|
||||
|
||||
namespace :dossiers do
|
||||
resources :procedure, only: [:show]
|
||||
post 'filter'
|
||||
|
||||
get 'procedure/:id' => 'procedure#index', as: 'procedure'
|
||||
post 'procedure/:id/filter' => 'procedure#filter', as: 'procedure_filter'
|
||||
end
|
||||
|
||||
resources :commentaires, only: [:create]
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
class ChangeProcedureFilterAttrInGestionnaire < ActiveRecord::Migration
|
||||
def change
|
||||
remove_column :gestionnaires, :procedure_filter
|
||||
add_column :gestionnaires, :procedure_filter, :integer, default: nil
|
||||
end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
class ChangeEmptytoNilInPreferenceListDossierTable < ActiveRecord::Migration
|
||||
class PreferenceListDossier < ActiveRecord::Base
|
||||
|
||||
end
|
||||
|
||||
def change
|
||||
PreferenceListDossier.where(table: '').update_all table: nil
|
||||
end
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
class FixTypeDeChampHeaderSectionWithMandatoryTrue < ActiveRecord::Migration
|
||||
class TypeDeChamp < ActiveRecord::Base
|
||||
|
||||
end
|
||||
|
||||
def change
|
||||
TypeDeChamp.all.each do |type_de_champ|
|
||||
type_de_champ.update_column(:mandatory, false) if type_de_champ.type_champ == 'header_section'
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddIndividualWithSiretInProcedure < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :procedures, :individual_with_siret, :boolean, default: false
|
||||
end
|
||||
end
|
25
db/migrate/20161005144657_purge_draft_dossier.rb
Normal file
25
db/migrate/20161005144657_purge_draft_dossier.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
class PurgeDraftDossier < ActiveRecord::Migration
|
||||
class Dossier < ActiveRecord::Base
|
||||
BROUILLON = %w(draft)
|
||||
|
||||
def brouillon?
|
||||
BROUILLON.include?(state)
|
||||
end
|
||||
end
|
||||
|
||||
class Commentaire < ActiveRecord::Base
|
||||
belongs_to :dossier
|
||||
end
|
||||
|
||||
class Cerfa < ActiveRecord::Base
|
||||
belongs_to :dossier
|
||||
belongs_to :user
|
||||
end
|
||||
|
||||
def change
|
||||
Cerfa.all.each { |cerfa| cerfa.delete if cerfa.dossier.brouillon? }
|
||||
Commentaire.all.each { |com| com.delete if com.dossier.brouillon? }
|
||||
|
||||
Dossier.where(state: :draft).destroy_all
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddGenderInIndividualTable < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :individuals, :gender, :string
|
||||
end
|
||||
end
|
163
db/migrate/20161007095443_reset_all_preference_list_dossier.rb
Normal file
163
db/migrate/20161007095443_reset_all_preference_list_dossier.rb
Normal file
|
@ -0,0 +1,163 @@
|
|||
class ResetAllPreferenceListDossier < ActiveRecord::Migration
|
||||
class PreferenceListDossier < ActiveRecord::Base
|
||||
belongs_to :gestionnaire
|
||||
belongs_to :procedure
|
||||
|
||||
def self.available_columns_for procedure_id = nil
|
||||
columns = {
|
||||
dossier: columns_dossier,
|
||||
procedure: columns_procedure,
|
||||
entreprise: columns_entreprise,
|
||||
etablissement: columns_etablissement,
|
||||
user: columns_user,
|
||||
france_connect: columns_france_connect
|
||||
}
|
||||
columns
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.columns_dossier
|
||||
table = nil
|
||||
|
||||
{
|
||||
dossier_id: create_column('ID', table, 'id', 'id', 1),
|
||||
created_at: create_column('Créé le', table, 'created_at', 'first_creation', 2),
|
||||
updated_at: create_column('Mise à jour le', table, 'updated_at', 'last_update', 2),
|
||||
state: create_column('Statut', table, 'state', 'display_state', 1)
|
||||
}
|
||||
end
|
||||
|
||||
def self.columns_procedure
|
||||
table = 'procedure'
|
||||
|
||||
{
|
||||
libelle: create_column('Libellé procédure', table, 'libelle', 'libelle', 4),
|
||||
organisation: create_column('Organisation', table, 'organisation', 'organisation', 3),
|
||||
direction: create_column('Direction', table, 'direction', 'direction', 3)
|
||||
}
|
||||
end
|
||||
|
||||
def self.columns_entreprise
|
||||
table = 'entreprise'
|
||||
|
||||
{
|
||||
siren: create_column('SIREN', table, 'siren', 'siren', 2),
|
||||
forme_juridique: create_column('Forme juridique', table, 'forme_juridique', 'forme_juridique', 3),
|
||||
nom_commercial: create_column('Nom commercial', table, 'nom_commercial', 'nom_commercial', 3),
|
||||
raison_sociale: create_column('Raison sociale', table, 'raison_sociale', 'raison_sociale', 3),
|
||||
siret_siege_social: create_column('SIRET siège social', table, 'siret_siege_social', 'siret_siege_social', 2),
|
||||
date_creation: create_column('Date de création', table, 'date_creation', 'date_creation', 2),
|
||||
}
|
||||
end
|
||||
|
||||
def self.columns_etablissement
|
||||
table = 'etablissement'
|
||||
|
||||
{
|
||||
siret: create_column('SIRET', table, 'siret', 'siret', 2),
|
||||
libelle: create_column('Nom établissement', table, 'libelle_naf', 'libelle_naf', 3),
|
||||
code_postal: create_column('Code postal', table, 'code_postal', 'code_postal', 1)
|
||||
}
|
||||
end
|
||||
|
||||
def self.columns_user
|
||||
table = 'user'
|
||||
{
|
||||
email: create_column('Email', table, 'email', 'email', 2)
|
||||
}
|
||||
end
|
||||
|
||||
def self.columns_france_connect
|
||||
table = 'france_connect_information'
|
||||
|
||||
{
|
||||
gender: create_column('Civilité (FC)', table, 'gender', 'gender_fr', 1),
|
||||
given_name: create_column('Prénom (FC)', table, 'given_name', 'given_name', 2),
|
||||
family_name: create_column('Nom (FC)', table, 'family_name', 'family_name', 2)
|
||||
}
|
||||
end
|
||||
|
||||
def self.create_column libelle, table, attr, attr_decorate, bootstrap_lg
|
||||
{
|
||||
libelle: libelle,
|
||||
table: table,
|
||||
attr: attr,
|
||||
attr_decorate: attr_decorate,
|
||||
bootstrap_lg: bootstrap_lg,
|
||||
order: nil,
|
||||
filter: nil
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
class Gestionnaire < ActiveRecord::Base
|
||||
has_many :assign_to, dependent: :destroy
|
||||
has_many :procedures, through: :assign_to
|
||||
|
||||
def build_default_preferences_list_dossier procedure_id=nil
|
||||
|
||||
PreferenceListDossier.available_columns_for(procedure_id).each do |table|
|
||||
table.second.each do |column|
|
||||
|
||||
if valid_couple_table_attr? table.first, column.first
|
||||
PreferenceListDossier.create(
|
||||
libelle: column.second[:libelle],
|
||||
table: column.second[:table],
|
||||
attr: column.second[:attr],
|
||||
attr_decorate: column.second[:attr_decorate],
|
||||
bootstrap_lg: column.second[:bootstrap_lg],
|
||||
order: nil,
|
||||
filter: nil,
|
||||
procedure_id: procedure_id,
|
||||
gestionnaire: self
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_couple_table_attr? table, column
|
||||
couples = [{
|
||||
table: :dossier,
|
||||
column: :dossier_id
|
||||
}, {
|
||||
table: :procedure,
|
||||
column: :libelle
|
||||
}, {
|
||||
table: :etablissement,
|
||||
column: :siret
|
||||
}, {
|
||||
table: :entreprise,
|
||||
column: :raison_sociale
|
||||
}, {
|
||||
table: :dossier,
|
||||
column: :state
|
||||
}]
|
||||
|
||||
couples.include?({table: table, column: column})
|
||||
end
|
||||
end
|
||||
|
||||
class Procedure < ActiveRecord::Base
|
||||
has_many :assign_to, dependent: :destroy
|
||||
has_many :gestionnaires, through: :assign_to
|
||||
|
||||
end
|
||||
|
||||
def change
|
||||
PreferenceListDossier.delete_all
|
||||
|
||||
Procedure.all.each do |procedure|
|
||||
procedure.gestionnaires.each do |gestionnaire|
|
||||
gestionnaire.build_default_preferences_list_dossier procedure.id
|
||||
end
|
||||
end
|
||||
|
||||
Gestionnaire.all.each do |gestionnaire|
|
||||
gestionnaire.build_default_preferences_list_dossier
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
class CreatePreferenceSmartListingPage < ActiveRecord::Migration
|
||||
class Gestionnaire < ActiveRecord::Base
|
||||
has_one :preference_smart_listing_page, dependent: :destroy
|
||||
|
||||
def build_default_preferences_smart_listing_page
|
||||
PreferenceSmartListingPage.create(page: 1, procedure: nil, gestionnaire: self, liste: 'a_traiter')
|
||||
end
|
||||
end
|
||||
|
||||
class PreferenceSmartListingPage < ActiveRecord::Base
|
||||
belongs_to :gestionnaire
|
||||
belongs_to :procedure
|
||||
|
||||
validates :page, presence: true, allow_blank: false, allow_nil: false
|
||||
validates :liste, presence: true, allow_blank: false, allow_nil: false
|
||||
validates :procedure, presence: true, allow_blank: true, allow_nil: true
|
||||
validates :gestionnaire, presence: true, allow_blank: false, allow_nil: false
|
||||
|
||||
validates_uniqueness_of :gestionnaire_id
|
||||
end
|
||||
|
||||
def change
|
||||
create_table :preference_smart_listing_pages do |t|
|
||||
t.string :liste
|
||||
t.integer :page
|
||||
end
|
||||
|
||||
add_belongs_to :preference_smart_listing_pages, :procedure
|
||||
add_belongs_to :preference_smart_listing_pages, :gestionnaire
|
||||
|
||||
Gestionnaire.all.each do |gestionnaire|
|
||||
gestionnaire.build_default_preferences_smart_listing_page if gestionnaire.preference_smart_listing_page.nil?
|
||||
end
|
||||
end
|
||||
end
|
27
db/schema.rb
27
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160913093948) do
|
||||
ActiveRecord::Schema.define(version: 20161011125345) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -207,7 +207,7 @@ ActiveRecord::Schema.define(version: 20160913093948) do
|
|||
t.inet "last_sign_in_ip"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.integer "procedure_filter", default: [], array: true
|
||||
t.integer "procedure_filter"
|
||||
end
|
||||
|
||||
add_index "gestionnaires", ["email"], name: "index_gestionnaires_on_email", unique: true, using: :btree
|
||||
|
@ -218,6 +218,7 @@ ActiveRecord::Schema.define(version: 20160913093948) do
|
|||
t.string "prenom"
|
||||
t.string "birthdate"
|
||||
t.integer "dossier_id"
|
||||
t.string "gender"
|
||||
end
|
||||
|
||||
create_table "invites", force: :cascade do |t|
|
||||
|
@ -268,6 +269,13 @@ ActiveRecord::Schema.define(version: 20160913093948) do
|
|||
t.integer "procedure_id"
|
||||
end
|
||||
|
||||
create_table "preference_smart_listing_pages", force: :cascade do |t|
|
||||
t.string "liste"
|
||||
t.integer "page"
|
||||
t.integer "procedure_id"
|
||||
t.integer "gestionnaire_id"
|
||||
end
|
||||
|
||||
create_table "procedure_paths", force: :cascade do |t|
|
||||
t.string "path", limit: 30
|
||||
t.integer "procedure_id"
|
||||
|
@ -282,19 +290,20 @@ ActiveRecord::Schema.define(version: 20160913093948) do
|
|||
t.string "organisation"
|
||||
t.string "direction"
|
||||
t.string "lien_demarche"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.boolean "test"
|
||||
t.integer "administrateur_id"
|
||||
t.boolean "archived", default: false
|
||||
t.boolean "euro_flag", default: false
|
||||
t.boolean "archived", default: false
|
||||
t.boolean "euro_flag", default: false
|
||||
t.string "logo"
|
||||
t.boolean "cerfa_flag", default: false
|
||||
t.boolean "cerfa_flag", default: false
|
||||
t.string "logo_secure_token"
|
||||
t.boolean "published", default: false, null: false
|
||||
t.boolean "published", default: false, null: false
|
||||
t.string "lien_site_web"
|
||||
t.string "lien_notice"
|
||||
t.boolean "for_individual", default: false
|
||||
t.boolean "for_individual", default: false
|
||||
t.boolean "individual_with_siret", default: false
|
||||
end
|
||||
|
||||
create_table "quartier_prioritaires", force: :cascade do |t|
|
||||
|
|
|
@ -34,7 +34,7 @@ describe Admin::TypesDeChampController, type: :controller do
|
|||
|
||||
describe '#update' do
|
||||
let(:libelle) { 'mon libelle' }
|
||||
let(:type_champ) { 'text' }
|
||||
let(:type_champ) { 'header_section' }
|
||||
let(:description) { 'titi' }
|
||||
let(:order_place) { '' }
|
||||
let(:types_de_champ_id) { '' }
|
||||
|
@ -78,9 +78,23 @@ describe Admin::TypesDeChampController, type: :controller do
|
|||
subject { procedure.types_de_champ.first }
|
||||
|
||||
it { expect(subject.libelle).to eq('mon libelle') }
|
||||
it { expect(subject.type_champ).to eq('text') }
|
||||
it { expect(subject.type_champ).to eq('header_section') }
|
||||
it { expect(subject.description).to eq('titi') }
|
||||
it { expect(subject.mandatory).to be_truthy }
|
||||
end
|
||||
|
||||
context 'when type_champ is header_section and mandatory is true' do
|
||||
let(:type_champ) { 'header_section' }
|
||||
let(:mandatory) { 'on' }
|
||||
|
||||
before do
|
||||
request
|
||||
procedure.reload
|
||||
end
|
||||
|
||||
subject { procedure.types_de_champ.first }
|
||||
|
||||
it { expect(subject.type_champ).to eq type_champ }
|
||||
it { expect(subject.mandatory).to be_falsey }
|
||||
end
|
||||
|
||||
context 'when type_de_champ already exist' do
|
||||
|
@ -88,20 +102,24 @@ describe Admin::TypesDeChampController, type: :controller do
|
|||
let(:type_de_champ) { procedure.types_de_champ.first }
|
||||
let(:types_de_champ_id) { type_de_champ.id }
|
||||
let(:libelle) { 'toto' }
|
||||
let(:type_champ) { 'text' }
|
||||
let(:type_champ) { 'header_section' }
|
||||
let(:description) { 'citrouille' }
|
||||
let(:order_place) { '0' }
|
||||
let(:mandatory) { 'on' }
|
||||
|
||||
before do
|
||||
request
|
||||
procedure.reload
|
||||
end
|
||||
|
||||
subject { procedure.types_de_champ.first }
|
||||
|
||||
it { expect(subject.libelle).to eq('toto') }
|
||||
it { expect(subject.type_champ).to eq('text') }
|
||||
it { expect(subject.type_champ).to eq('header_section') }
|
||||
it { expect(subject.description).to eq('citrouille') }
|
||||
it { expect(subject.order_place).to eq(0) }
|
||||
it { expect(subject.order_place).to be_truthy }
|
||||
it { expect(subject.mandatory).to be_falsey }
|
||||
end
|
||||
end
|
||||
context 'when procedure is not found' do
|
||||
|
|
|
@ -89,6 +89,19 @@ describe Backoffice::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'GET #list_fake' do
|
||||
context 'when gestionnaire is connected' do
|
||||
before do
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
get :index, liste: :list_fake
|
||||
expect(response).to redirect_to(backoffice_dossiers_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #search' do
|
||||
before do
|
||||
sign_in gestionnaire
|
||||
|
|
|
@ -43,9 +43,13 @@ shared_examples 'description_controller_spec' do
|
|||
|
||||
context 'Tous les attributs sont bons' do
|
||||
describe 'Premier enregistrement des données' do
|
||||
let(:submit) { {nouveaux: 'nouveaux'} }
|
||||
|
||||
subject { post :create, dossier_id: dossier_id, submit: submit }
|
||||
|
||||
before do
|
||||
dossier.draft!
|
||||
post :create, dossier_id: dossier_id
|
||||
subject
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
|
@ -56,6 +60,18 @@ shared_examples 'description_controller_spec' do
|
|||
it 'etat du dossier est soumis' do
|
||||
expect(dossier.state).to eq('initiated')
|
||||
end
|
||||
|
||||
context 'when user whould like save just a draft' do
|
||||
let(:submit) { {brouillon: 'brouillon'} }
|
||||
|
||||
it "redirection vers la page recapitulative" do
|
||||
expect(response).to redirect_to("/users/dossiers?liste=brouillon")
|
||||
end
|
||||
|
||||
it 'etat du dossier est soumis' do
|
||||
expect(dossier.state).to eq('draft')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'En train de manipuler un dossier non brouillon' do
|
||||
|
|
25
spec/controllers/users/dossiers/add_siret_controller_spec.rb
Normal file
25
spec/controllers/users/dossiers/add_siret_controller_spec.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Users::Dossiers::AddSiretController, type: :controller do
|
||||
describe '#GET show' do
|
||||
|
||||
let(:dossier) { create :dossier }
|
||||
|
||||
before do
|
||||
sign_in dossier.user
|
||||
end
|
||||
|
||||
subject { get :show, dossier_id: dossier.id }
|
||||
|
||||
context 'when dossier is not attached at a procedure with individual siret attribut' do
|
||||
it { is_expected.to redirect_to users_dossiers_path }
|
||||
end
|
||||
|
||||
context 'when dossier is attached at a procedure with individual siret attribut' do
|
||||
let(:procedure) { create :procedure, individual_with_siret: true }
|
||||
let(:dossier) { create :dossier, procedure: procedure }
|
||||
|
||||
it { expect(subject.status).to eq 200 }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -456,4 +456,18 @@ describe Users::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #list_fake' do
|
||||
context 'when user is connected' do
|
||||
before do
|
||||
sign_in user
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
get :index, liste: :list_fake
|
||||
expect(response).to redirect_to(users_dossiers_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -12,13 +12,13 @@ describe DossiersListFacades do
|
|||
|
||||
create :preference_list_dossier,
|
||||
gestionnaire: gestionnaire,
|
||||
table: '',
|
||||
table: nil,
|
||||
attr: 'state',
|
||||
attr_decorate: 'display_state'
|
||||
|
||||
create :preference_list_dossier,
|
||||
gestionnaire: gestionnaire,
|
||||
table: '',
|
||||
table: nil,
|
||||
attr: 'state',
|
||||
attr_decorate: 'display_state',
|
||||
procedure_id: procedure.id
|
||||
|
|
|
@ -24,7 +24,7 @@ feature 'search file on gestionnaire backoffice' do
|
|||
it { expect(page).to have_css('#backoffice_search') }
|
||||
|
||||
context 'when terms input is empty' do
|
||||
it { expect(page).to have_content('Aucun dossier trouvé') }
|
||||
it { expect(page).to have_content('Aucun dossier') }
|
||||
end
|
||||
|
||||
context 'when terms input is informed' do
|
||||
|
@ -35,7 +35,7 @@ feature 'search file on gestionnaire backoffice' do
|
|||
end
|
||||
|
||||
context 'when terms input does not return result' do
|
||||
it { expect(page).to have_content('Aucun dossier trouvé') }
|
||||
it { expect(page).to have_content('Aucun dossier') }
|
||||
end
|
||||
|
||||
context 'when terms input does return result' do
|
||||
|
@ -45,12 +45,6 @@ feature 'search file on gestionnaire backoffice' do
|
|||
let(:terms) { dossier.entreprise.raison_sociale }
|
||||
|
||||
it { expect(page).to have_content(dossier.entreprise.raison_sociale) }
|
||||
|
||||
context "when terms is a file's id" do
|
||||
let(:terms) { dossier.id }
|
||||
|
||||
it { expect(page).to have_content("Dossier N°#{dossier.id}") }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -559,8 +559,8 @@ describe Dossier do
|
|||
describe '.search' do
|
||||
subject { liste_dossiers }
|
||||
|
||||
let(:liste_dossiers) { described_class.search(gestionnaire_1, terms)[0] }
|
||||
let(:dossier) { described_class.search(gestionnaire_1, terms)[1] }
|
||||
let(:liste_dossiers) { described_class.search(gestionnaire_1, terms) }
|
||||
# let(:dossier) { described_class.search(gestionnaire_1, terms)[1] }
|
||||
|
||||
let(:administrateur_1) { create(:administrateur) }
|
||||
let(:administrateur_2) { create(:administrateur) }
|
||||
|
@ -596,6 +596,7 @@ describe Dossier do
|
|||
let(:terms) { 'brouillon' }
|
||||
|
||||
it { expect(subject.size).to eq(0) }
|
||||
it { expect(subject.class).to eq Dossier::ActiveRecord_Relation }
|
||||
end
|
||||
|
||||
describe 'search on contact email' do
|
||||
|
@ -607,7 +608,7 @@ describe Dossier do
|
|||
describe 'search on ID dossier' do
|
||||
let(:terms) { "#{dossier_2.id}" }
|
||||
|
||||
it { expect(dossier.id).to eq(dossier_2.id) }
|
||||
it { expect(subject.size).to eq(1) }
|
||||
end
|
||||
|
||||
describe 'search on SIRET' do
|
||||
|
@ -688,6 +689,13 @@ describe Dossier do
|
|||
it { expect(subject['entreprise.date_creation']).to eq('Thu, 28 Jan 2016 10:16:29 UTC +00:0') }
|
||||
it { expect(subject['entreprise.nom']).to be_nil }
|
||||
it { expect(subject['entreprise.prenom']).to be_nil }
|
||||
|
||||
context 'when dossier does not have enterprise' do
|
||||
let(:dossier) { create(:dossier, user: user, procedure: procedure) }
|
||||
subject { dossier.as_csv }
|
||||
|
||||
it { expect(subject[:archived]).to be_falsey }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#reset!' do
|
||||
|
|
|
@ -28,6 +28,7 @@ describe Gestionnaire, type: :model do
|
|||
end
|
||||
|
||||
describe 'association' do
|
||||
it { is_expected.to have_one(:preference_smart_listing_page) }
|
||||
it { is_expected.to have_and_belong_to_many(:administrateurs) }
|
||||
it { is_expected.to have_many(:procedures) }
|
||||
it { is_expected.to have_many(:dossiers) }
|
||||
|
@ -161,4 +162,26 @@ describe Gestionnaire, type: :model do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#build_default_preferences_smart_listing_page' do
|
||||
subject { gestionnaire.preference_smart_listing_page }
|
||||
|
||||
context 'when gestionnaire is created' do
|
||||
it 'build page column' do
|
||||
expect(subject.page).to eq 1
|
||||
end
|
||||
|
||||
it 'build liste column' do
|
||||
expect(subject.liste).to eq 'a_traiter'
|
||||
end
|
||||
|
||||
it 'build procedure_id column' do
|
||||
expect(subject.procedure).to eq nil
|
||||
end
|
||||
|
||||
it 'build gestionnaire column' do
|
||||
expect(subject.gestionnaire).to eq gestionnaire
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
10
spec/models/preference_smart_listing_page_spec.rb
Normal file
10
spec/models/preference_smart_listing_page_spec.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe PreferenceSmartListingPage do
|
||||
it { is_expected.to have_db_column(:page) }
|
||||
it { is_expected.to have_db_column(:liste) }
|
||||
it { is_expected.to have_db_column(:procedure_id) }
|
||||
|
||||
it { is_expected.to belong_to(:gestionnaire) }
|
||||
it { is_expected.to belong_to(:procedure) }
|
||||
end
|
|
@ -5,9 +5,11 @@ describe AccompagnateurService do
|
|||
let(:procedure) { create :procedure }
|
||||
let(:accompagnateur) { create :gestionnaire }
|
||||
|
||||
let(:accompagnateur_service) { AccompagnateurService.new accompagnateur, procedure, to}
|
||||
|
||||
describe '#change_assignement!' do
|
||||
|
||||
subject { AccompagnateurService.change_assignement! accompagnateur, procedure, to }
|
||||
subject { accompagnateur_service.change_assignement! }
|
||||
|
||||
context 'when accompagnateur is not assign at the procedure' do
|
||||
let(:to) { AccompagnateurService::ASSIGN }
|
||||
|
@ -33,7 +35,7 @@ describe AccompagnateurService do
|
|||
|
||||
describe '#build_default_column' do
|
||||
|
||||
subject { AccompagnateurService.build_default_column accompagnateur, procedure, to }
|
||||
subject { accompagnateur_service.build_default_column }
|
||||
|
||||
context 'when to is not assign' do
|
||||
let(:to) { AccompagnateurService::NOT_ASSIGN }
|
||||
|
|
276
spec/services/dossiers_list_gestionnaire_service_spec.rb
Normal file
276
spec/services/dossiers_list_gestionnaire_service_spec.rb
Normal file
|
@ -0,0 +1,276 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe DossiersListGestionnaireService do
|
||||
let(:gestionnaire) { create :gestionnaire }
|
||||
let(:preference_smart_listing_page) { gestionnaire.preference_smart_listing_page }
|
||||
let(:liste) { 'a_traiter' }
|
||||
let(:dossier) { create :dossier }
|
||||
let(:accompagnateur_service) { AccompagnateurService.new gestionnaire, procedure, 'assign' }
|
||||
|
||||
describe '#default_sort' do
|
||||
let(:procedure) { dossier.procedure }
|
||||
|
||||
before do
|
||||
accompagnateur_service.change_assignement!
|
||||
accompagnateur_service.build_default_column
|
||||
|
||||
gestionnaire.reload
|
||||
end
|
||||
|
||||
subject { DossiersListGestionnaireService.new(gestionnaire, liste, procedure).default_sort }
|
||||
|
||||
context 'when gestionnaire does not have default sort' do
|
||||
it { is_expected.to eq({'nil' => 'nil'}) }
|
||||
end
|
||||
|
||||
context 'when gestionnaire have default sort' do
|
||||
|
||||
before do
|
||||
preference_attr.update_column(:order, 'asc')
|
||||
end
|
||||
|
||||
context 'when default sort is a dossier attr' do
|
||||
let(:preference_attr) { gestionnaire.preference_list_dossiers.where(procedure: procedure, table: nil, attr: 'id').first }
|
||||
|
||||
it { is_expected.to eq({"#{preference_attr.attr}" => "asc"}) }
|
||||
end
|
||||
|
||||
context 'when default sort is not a dossier attr' do
|
||||
let(:preference_attr) { gestionnaire.preference_list_dossiers.where(procedure: procedure, table: 'entreprise', attr: 'raison_sociale').first }
|
||||
|
||||
it { is_expected.to eq({"#{preference_attr.table}.#{preference_attr.attr}" => "asc"}) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#change_sort!' do
|
||||
let(:table) { 'entreprise' }
|
||||
let(:attr) { 'raison_sociale' }
|
||||
let(:order) { 'desc' }
|
||||
|
||||
let(:select_preference_list_dossier) { gestionnaire.preference_list_dossiers
|
||||
.find_by(table: table, attr: attr, procedure: nil) }
|
||||
|
||||
subject { DossiersListGestionnaireService.new(gestionnaire, liste).change_sort! param_sort }
|
||||
|
||||
describe 'with one or two params in sort' do
|
||||
before do
|
||||
subject
|
||||
|
||||
gestionnaire.reload
|
||||
end
|
||||
|
||||
context 'when sort_params as table and attr' do
|
||||
let(:param_sort) { ({"#{table}.#{attr}" => order}) }
|
||||
|
||||
it { expect(select_preference_list_dossier.order).to eq 'desc' }
|
||||
end
|
||||
|
||||
context 'when sort_params as no table' do
|
||||
let(:param_sort) { ({"#{attr}" => order}) }
|
||||
let(:table) { nil }
|
||||
let(:attr) { 'id' }
|
||||
|
||||
it { expect(select_preference_list_dossier.order).to eq 'desc' }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'when procedure as already a preference order' do
|
||||
let(:param_sort) { ({"#{attr}" => order}) }
|
||||
let(:table) { nil }
|
||||
let(:attr) { 'id' }
|
||||
|
||||
before do
|
||||
gestionnaire.preference_list_dossiers.find_by(procedure: nil, table: 'entreprise', attr: 'raison_sociale').update_column :order, :desc
|
||||
end
|
||||
|
||||
it 'keep one order by procedure id' do
|
||||
expect(gestionnaire.preference_list_dossiers.where(procedure: nil).where.not(order: nil).size).to eq 1
|
||||
subject
|
||||
expect(gestionnaire.preference_list_dossiers.where(procedure: nil).where.not(order: nil).size).to eq 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#add_filter' do
|
||||
let(:table) { 'entreprise' }
|
||||
let(:attr) { 'raison_sociale' }
|
||||
let(:filter_value) { 'plop' }
|
||||
|
||||
let(:select_preference_list_dossier) { gestionnaire.preference_list_dossiers
|
||||
.find_by(table: table, attr: attr, procedure: nil) }
|
||||
|
||||
subject { described_class.new(gestionnaire, liste).add_filter new_filter }
|
||||
|
||||
describe 'with one or two params in filter' do
|
||||
before do
|
||||
subject
|
||||
gestionnaire.reload
|
||||
end
|
||||
|
||||
context 'when sort_params as table and attr' do
|
||||
let(:new_filter) { ({"#{table}.#{attr}" => filter_value}) }
|
||||
|
||||
it { expect(select_preference_list_dossier.filter).to eq filter_value }
|
||||
end
|
||||
|
||||
context 'when sort_params as no table' do
|
||||
let(:new_filter) { ({"#{attr}" => filter_value}) }
|
||||
let(:table) { nil }
|
||||
let(:attr) { 'id' }
|
||||
|
||||
it { expect(select_preference_list_dossier.filter).to eq filter_value }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#where_filter' do
|
||||
before do
|
||||
gestionnaire.preference_list_dossiers
|
||||
.find_by(table: 'entreprise', attr: 'raison_sociale', procedure: nil)
|
||||
.update_column :filter, 'plop'
|
||||
|
||||
gestionnaire.preference_list_dossiers
|
||||
.find_by(table: nil, attr: 'id', procedure: nil)
|
||||
.update_column :filter, '23'
|
||||
end
|
||||
|
||||
subject { DossiersListGestionnaireService.new(gestionnaire, liste, nil).where_filter }
|
||||
|
||||
it { is_expected.to eq "CAST(dossiers.id as TEXT) LIKE '%23%' AND CAST(entreprises.raison_sociale as TEXT) LIKE '%plop%'" }
|
||||
|
||||
context 'when last filter caractere is *' do
|
||||
|
||||
before do
|
||||
gestionnaire.preference_list_dossiers
|
||||
.find_by(table: 'entreprise', attr: 'raison_sociale', procedure: nil)
|
||||
.update_column :filter, 'plop*'
|
||||
end
|
||||
|
||||
it { is_expected.to eq "CAST(dossiers.id as TEXT) LIKE '%23%' AND CAST(entreprises.raison_sociale as TEXT) LIKE 'plop%'" }
|
||||
end
|
||||
|
||||
context 'when first filter caractere is *' do
|
||||
before do
|
||||
gestionnaire.preference_list_dossiers
|
||||
.find_by(table: nil, attr: 'id', procedure: nil)
|
||||
.update_column :filter, '*23'
|
||||
end
|
||||
|
||||
it { is_expected.to eq "CAST(dossiers.id as TEXT) LIKE '%23' AND CAST(entreprises.raison_sociale as TEXT) LIKE '%plop%'" }
|
||||
end
|
||||
|
||||
context 'when * caractere is presente' do
|
||||
before do
|
||||
gestionnaire.preference_list_dossiers
|
||||
.find_by(table: 'entreprise', attr: 'raison_sociale', procedure: nil)
|
||||
.update_column :filter, 'plop*plip'
|
||||
end
|
||||
|
||||
it { is_expected.to eq "CAST(dossiers.id as TEXT) LIKE '%23%' AND CAST(entreprises.raison_sociale as TEXT) LIKE 'plop%plip'" }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#default_page' do
|
||||
let(:page) { 2 }
|
||||
let(:procedure) { nil }
|
||||
|
||||
before do
|
||||
preference_smart_listing_page.update page: page, liste: 'a_traiter'
|
||||
end
|
||||
|
||||
subject { described_class.new(gestionnaire, liste, procedure).default_page }
|
||||
|
||||
context 'when liste and procedure match with the actual preference' do
|
||||
let(:liste) { 'a_traiter' }
|
||||
|
||||
it { is_expected.to eq 2 }
|
||||
end
|
||||
|
||||
context 'when liste and procedure does not match with the actual preference' do
|
||||
let(:liste) { 'en_attente' }
|
||||
|
||||
it { is_expected.to eq 1 }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#change_page!' do
|
||||
let(:procedure) { nil }
|
||||
let(:liste) { 'a_traiter' }
|
||||
|
||||
let(:page) { 2 }
|
||||
let(:new_page) { 1 }
|
||||
|
||||
before do
|
||||
preference_smart_listing_page.update page: page, liste: 'a_traiter', procedure: nil
|
||||
subject
|
||||
preference_smart_listing_page.reload
|
||||
end
|
||||
|
||||
subject { described_class.new(gestionnaire, liste, procedure).change_page! new_page }
|
||||
|
||||
context 'when liste and procedure does not change' do
|
||||
it { expect(preference_smart_listing_page.liste).to eq liste }
|
||||
it { expect(preference_smart_listing_page.procedure).to eq procedure }
|
||||
it { expect(preference_smart_listing_page.page).to eq new_page }
|
||||
|
||||
context 'when new_page is nil' do
|
||||
let(:new_page) { nil }
|
||||
|
||||
it { expect(preference_smart_listing_page.liste).to eq liste }
|
||||
it { expect(preference_smart_listing_page.procedure).to eq procedure }
|
||||
it { expect(preference_smart_listing_page.page).to eq page }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when liste change' do
|
||||
let(:liste) { 'en_attente' }
|
||||
|
||||
it { expect(preference_smart_listing_page.liste).to eq liste }
|
||||
it { expect(preference_smart_listing_page.procedure).to eq procedure }
|
||||
it { expect(preference_smart_listing_page.page).to eq new_page }
|
||||
|
||||
context 'when new_page is nil' do
|
||||
let(:new_page) { nil }
|
||||
|
||||
it { expect(preference_smart_listing_page.liste).to eq liste }
|
||||
it { expect(preference_smart_listing_page.procedure).to eq procedure }
|
||||
it { expect(preference_smart_listing_page.page).to eq 1 }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when procedure change' do
|
||||
let(:procedure) { dossier.procedure }
|
||||
|
||||
it { expect(preference_smart_listing_page.liste).to eq liste }
|
||||
it { expect(preference_smart_listing_page.procedure).to eq procedure }
|
||||
it { expect(preference_smart_listing_page.page).to eq new_page }
|
||||
|
||||
context 'when new_page is nil' do
|
||||
let(:new_page) { nil }
|
||||
|
||||
it { expect(preference_smart_listing_page.liste).to eq liste }
|
||||
it { expect(preference_smart_listing_page.procedure).to eq procedure }
|
||||
it { expect(preference_smart_listing_page.page).to eq 1 }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when procedure and liste change' do
|
||||
let(:liste) { 'en_attente' }
|
||||
let(:procedure) { dossier.procedure }
|
||||
|
||||
it { expect(preference_smart_listing_page.liste).to eq liste }
|
||||
it { expect(preference_smart_listing_page.procedure).to eq procedure }
|
||||
it { expect(preference_smart_listing_page.page).to eq new_page }
|
||||
|
||||
context 'when new_page is nil' do
|
||||
let(:new_page) { nil }
|
||||
|
||||
it { expect(preference_smart_listing_page.liste).to eq liste }
|
||||
it { expect(preference_smart_listing_page.procedure).to eq procedure }
|
||||
it { expect(preference_smart_listing_page.page).to eq 1 }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -60,6 +60,7 @@ end
|
|||
DatabaseCleaner.strategy = :truncation
|
||||
|
||||
SIADETOKEN = :valid_token unless defined? SIADETOKEN
|
||||
BROWSER.value = Browser.new('Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0)')
|
||||
|
||||
include Warden::Test::Helpers
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
|
|||
|
||||
create :preference_list_dossier,
|
||||
gestionnaire: gestionnaire,
|
||||
table: '',
|
||||
table: nil,
|
||||
attr: 'state',
|
||||
attr_decorate: 'display_state'
|
||||
|
||||
|
@ -46,7 +46,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
|
|||
|
||||
create :preference_list_dossier,
|
||||
gestionnaire: gestionnaire,
|
||||
table: '',
|
||||
table: nil,
|
||||
attr: 'last_update',
|
||||
attr_decorate: 'last_update'
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/recapitulatif/show.html.haml', type: :view do
|
||||
let(:dossier) { create(:dossier, :with_entreprise, state: state, procedure: create(:procedure, :with_api_carto, :with_two_type_de_piece_justificative)) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, state: state, procedure: create(:procedure, :with_api_carto, :with_two_type_de_piece_justificative, for_individual: true, individual_with_siret: true)) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:state) { 'draft' }
|
||||
|
||||
|
@ -46,6 +46,12 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
|
|||
end
|
||||
end
|
||||
|
||||
context 'lien carte' do
|
||||
it 'le lien vers le renseignement un SIRET est présent' do
|
||||
expect(rendered).to have_css('#add_siret')
|
||||
end
|
||||
end
|
||||
|
||||
context 'lien carte' do
|
||||
it 'le lien vers carte est présent' do
|
||||
expect(rendered).to have_css('#maj_carte')
|
||||
|
|
Loading…
Reference in a new issue