[Fix #1120] Delete the old accompagnateur UI
This commit is contained in:
parent
1c295eafb6
commit
1368cd4b03
90 changed files with 19 additions and 12044 deletions
|
@ -17,7 +17,6 @@
|
|||
// = require _turbolinks
|
||||
// = require admin_procedures_modal
|
||||
// = require admin_type_de_champ
|
||||
// = require backoffice
|
||||
// = require carte
|
||||
// = require custom_mails
|
||||
// = require default_data_block
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
#backoffice-index,
|
||||
#backoffice-search {
|
||||
margin-left: 2rem;
|
||||
margin-right: 2rem;
|
||||
|
||||
.default-data-block {
|
||||
background-color: #FFFFFF;
|
||||
margin-top: 20px;
|
||||
|
||||
.show-block {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.body {
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.fixed-right {
|
||||
position: fixed;
|
||||
right: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
#onglets {
|
||||
ul {
|
||||
li,
|
||||
li.active {
|
||||
a {
|
||||
margin-top: 12px;
|
||||
height: 45px;
|
||||
|
||||
h5 {
|
||||
margin-top: 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#search {
|
||||
a {
|
||||
margin-top: 0px;
|
||||
height: 57px;
|
||||
}
|
||||
}
|
||||
|
||||
#search:not(.active) {
|
||||
a:hover {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
padding: 11px 16px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
#backoffice-dossier-show,
|
||||
#users-recapitulatif-dossier-show {
|
||||
|
||||
#messages {
|
||||
|
|
|
@ -12,10 +12,6 @@
|
|||
margin-bottom: -70px;
|
||||
}
|
||||
|
||||
#backoffice-dossier-show .nav-tabs {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#left-panel {
|
||||
margin-top: 0;
|
||||
height: auto;
|
||||
|
|
|
@ -30,7 +30,6 @@ class Admin::AccompagnateursController < AdminController
|
|||
accompagnateur_service = AccompagnateurService.new 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]
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
class Backoffice::AvisController < ApplicationController
|
||||
before_action :authenticate_gestionnaire!
|
||||
|
||||
def create
|
||||
avis = Avis.new(create_params.merge(claimant: current_gestionnaire, dossier: dossier, confidentiel: true))
|
||||
|
||||
if avis.save
|
||||
flash[:notice] = "Votre demande d'avis a bien été envoyée à #{avis.email_to_display}"
|
||||
end
|
||||
|
||||
redirect_to backoffice_dossier_path(dossier)
|
||||
end
|
||||
|
||||
def update
|
||||
if avis.update(update_params)
|
||||
NotificationService.new('avis', params[:dossier_id]).notify
|
||||
flash[:notice] = 'Merci, votre avis a été enregistré.'
|
||||
end
|
||||
|
||||
redirect_to backoffice_dossier_path(avis.dossier_id)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def dossier
|
||||
current_gestionnaire.dossiers.find(params[:dossier_id])
|
||||
end
|
||||
|
||||
def avis
|
||||
current_gestionnaire.avis.find(params[:id])
|
||||
end
|
||||
|
||||
def create_params
|
||||
params.require(:avis).permit(:email, :introduction)
|
||||
end
|
||||
|
||||
def update_params
|
||||
params.require(:avis).permit(:answer)
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
class Backoffice::CommentairesController < CommentairesController
|
||||
before_action :authenticate_gestionnaire!
|
||||
|
||||
def is_gestionnaire?
|
||||
true
|
||||
end
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
class Backoffice::Dossiers::ProcedureController < Backoffice::DossiersListController
|
||||
def index
|
||||
super
|
||||
|
||||
dossiers_list_facade.service.filter_procedure! params[:id]
|
||||
|
||||
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
|
||||
|
||||
def filter
|
||||
super
|
||||
|
||||
redirect_to backoffice_dossiers_procedure_path(id: params[:id])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def retrieve_procedure
|
||||
current_gestionnaire.procedures.find params[:id]
|
||||
end
|
||||
end
|
|
@ -1,226 +0,0 @@
|
|||
class Backoffice::DossiersController < Backoffice::DossiersListController
|
||||
include ActionView::Helpers::NumberHelper
|
||||
|
||||
respond_to :html, :xlsx, :ods, :csv
|
||||
|
||||
prepend_before_action :store_current_location, only: :show
|
||||
before_action :ensure_gestionnaire_is_authorized, only: :show
|
||||
|
||||
def index
|
||||
return redirect_to backoffice_invitations_path if current_gestionnaire.avis.any?
|
||||
|
||||
procedure = current_gestionnaire.procedure_filter
|
||||
|
||||
if procedure.nil?
|
||||
procedure_list = dossiers_list_facade.gestionnaire_procedures_name_and_id_list
|
||||
|
||||
if procedure_list.count == 0
|
||||
flash.alert = "Vous n'avez aucune procédure d'affectée."
|
||||
return redirect_to root_path
|
||||
end
|
||||
|
||||
procedure = procedure_list.first[:id]
|
||||
end
|
||||
|
||||
redirect_to backoffice_dossiers_procedure_path(id: procedure)
|
||||
end
|
||||
|
||||
def show
|
||||
dossier_id = params[:id]
|
||||
create_dossier_facade dossier_id
|
||||
|
||||
if @facade.present?
|
||||
@champs_private = @facade.champs_private
|
||||
|
||||
@headers_private = @champs_private.select { |champ| champ.type_champ == 'header_section' }
|
||||
end
|
||||
|
||||
# if the current_gestionnaire does not own the dossier, it is here to give an advice
|
||||
# and it should not remove the notifications
|
||||
if current_gestionnaire.dossiers.find_by(id: dossier_id).present?
|
||||
Notification.where(dossier_id: dossier_id).update_all(already_read: true)
|
||||
end
|
||||
|
||||
@new_avis = Avis.new(introduction: "Bonjour, merci de me donner votre avis sur ce dossier.")
|
||||
end
|
||||
|
||||
def filter
|
||||
super
|
||||
|
||||
redirect_to backoffice_dossiers_path(liste: param_liste)
|
||||
end
|
||||
|
||||
def download_dossiers_tps
|
||||
procedure = current_gestionnaire.procedures.find_by(id: params[:procedure_id])
|
||||
export = procedure.generate_export
|
||||
|
||||
respond_to do |format|
|
||||
format.csv { send_data(SpreadsheetArchitect.to_csv(data: export[:data], headers: export[:headers]), filename: 'dossiers.csv') }
|
||||
format.xlsx { send_data(SpreadsheetArchitect.to_xlsx(data: export[:data], headers: export[:headers]), filename: 'dossiers.xlsx') }
|
||||
format.ods { send_data(SpreadsheetArchitect.to_ods(data: export[:data], headers: export[:headers]), filename: 'dossiers.ods') }
|
||||
end
|
||||
end
|
||||
|
||||
def search
|
||||
@search_terms = params[:q]
|
||||
|
||||
# exact id match?
|
||||
if @search_terms.to_i != 0
|
||||
@dossiers = current_gestionnaire.dossiers.where(id: @search_terms.to_i)
|
||||
end
|
||||
|
||||
@dossiers = Dossier.none if @dossiers.nil?
|
||||
|
||||
# full text search
|
||||
if !@dossiers.any?
|
||||
@dossiers = Search.new(
|
||||
gestionnaire: current_gestionnaire,
|
||||
query: @search_terms,
|
||||
page: params[:page]
|
||||
).results
|
||||
end
|
||||
|
||||
smart_listing_create :search,
|
||||
@dossiers,
|
||||
partial: "backoffice/dossiers/list",
|
||||
array: true,
|
||||
default_sort: dossiers_list_facade.service.default_sort
|
||||
|
||||
rescue RuntimeError
|
||||
smart_listing_create :search,
|
||||
[],
|
||||
partial: "backoffice/dossiers/list",
|
||||
array: true,
|
||||
default_sort: dossiers_list_facade.service.default_sort
|
||||
end
|
||||
|
||||
def receive
|
||||
dossier = Dossier.find(params[:dossier_id])
|
||||
|
||||
dossier.en_instruction!
|
||||
current_gestionnaire.follow(dossier)
|
||||
flash.notice = 'Dossier passé en instruction.'
|
||||
|
||||
redirect_to backoffice_dossier_path(id: dossier.id)
|
||||
end
|
||||
|
||||
def process_dossier
|
||||
create_dossier_facade params[:dossier_id]
|
||||
|
||||
dossier = @facade.dossier
|
||||
|
||||
if params[:dossier] && params[:dossier][:motivation].present?
|
||||
dossier.motivation = params[:dossier][:motivation]
|
||||
end
|
||||
|
||||
case params[:process_action]
|
||||
when "refuse"
|
||||
dossier.refuse!
|
||||
notice = "Dossier considéré comme refusé."
|
||||
template = dossier.procedure.refused_mail_template
|
||||
when "without_continuation"
|
||||
dossier.sans_suite!
|
||||
notice = "Dossier considéré comme sans suite."
|
||||
template = dossier.procedure.without_continuation_mail_template
|
||||
when "close"
|
||||
dossier.accepte!
|
||||
dossier.attestation = dossier.build_attestation
|
||||
notice = "Dossier traité avec succès."
|
||||
template = dossier.procedure.closed_mail_template
|
||||
end
|
||||
|
||||
dossier.save
|
||||
|
||||
# needed to force Carrierwave to provide dossier.attestation.pdf.read
|
||||
# when the Feature.remote_storage is true, otherwise pdf.read is a closed stream.
|
||||
dossier.reload
|
||||
|
||||
attestation_pdf = nil
|
||||
if check_attestation_emailable(dossier)
|
||||
attestation_pdf = dossier.attestation.pdf.read
|
||||
end
|
||||
|
||||
flash.notice = notice
|
||||
|
||||
NotificationMailer.send_notification(dossier, template, attestation_pdf).deliver_now!
|
||||
|
||||
redirect_to backoffice_dossier_path(id: dossier.id)
|
||||
end
|
||||
|
||||
def reload_smartlisting
|
||||
begin
|
||||
@liste = URI(request.referer).query.split('=').second
|
||||
rescue NoMethodError
|
||||
@liste = cookies[:liste] || 'all_state'
|
||||
end
|
||||
|
||||
smartlisting_dossier
|
||||
|
||||
render 'backoffice/dossiers/index', formats: :js
|
||||
end
|
||||
|
||||
def archive
|
||||
facade = create_dossier_facade params[:id]
|
||||
if !facade.dossier.archived
|
||||
facade.dossier.update(archived: true)
|
||||
flash.notice = 'Dossier archivé'
|
||||
end
|
||||
redirect_to backoffice_dossiers_path
|
||||
end
|
||||
|
||||
def unarchive
|
||||
@dossier = Dossier.find(params[:id])
|
||||
if @dossier.archived
|
||||
@dossier.update(archived: false)
|
||||
flash.notice = 'Dossier désarchivé'
|
||||
end
|
||||
redirect_to backoffice_dossier_path(@dossier)
|
||||
end
|
||||
|
||||
def reopen
|
||||
create_dossier_facade params[:dossier_id]
|
||||
|
||||
@facade.dossier.en_construction!
|
||||
flash.notice = 'Dossier repassé en construction.'
|
||||
|
||||
redirect_to backoffice_dossier_path(id: @facade.dossier.id)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_attestation_emailable(dossier)
|
||||
if dossier&.attestation&.emailable? == false
|
||||
human_size = number_to_human_size(dossier.attestation.pdf.size)
|
||||
msg = "the attestation of the dossier #{dossier.id} cannot be mailed because it is too heavy: #{human_size}"
|
||||
capture_message(msg, level: 'error')
|
||||
end
|
||||
|
||||
dossier&.attestation&.emailable?
|
||||
end
|
||||
|
||||
def store_current_location
|
||||
if !gestionnaire_signed_in?
|
||||
store_location_for(:gestionnaire, request.url)
|
||||
end
|
||||
end
|
||||
|
||||
def ensure_gestionnaire_is_authorized
|
||||
if !current_gestionnaire.can_view_dossier?(params[:id])
|
||||
flash.alert = t('errors.messages.dossier_not_found')
|
||||
redirect_to url_for(controller: '/backoffice')
|
||||
end
|
||||
end
|
||||
|
||||
def create_dossier_facade dossier_id
|
||||
@facade = DossierFacades.new dossier_id, current_gestionnaire.email
|
||||
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
flash.alert = t('errors.messages.dossier_not_found')
|
||||
redirect_to url_for(controller: '/backoffice')
|
||||
end
|
||||
|
||||
def retrieve_procedure
|
||||
return if params[:procedure_id].blank?
|
||||
current_gestionnaire.procedures.find params[:procedure_id]
|
||||
end
|
||||
end
|
|
@ -1,78 +0,0 @@
|
|||
class Backoffice::DossiersListController < ApplicationController
|
||||
include SmartListing::Helper::ControllerExtensions
|
||||
helper SmartListing::Helper
|
||||
|
||||
before_action :authenticate_gestionnaire!
|
||||
|
||||
def index
|
||||
cookies[:liste] = param_liste
|
||||
|
||||
if !DossiersListGestionnaireService.dossiers_liste_libelle.include?(param_liste)
|
||||
cookies[:liste] = 'all_state'
|
||||
end
|
||||
|
||||
dossiers_list_facade param_liste
|
||||
dossiers_list_facade.service.change_sort! param_sort if param_smart_listing.present?
|
||||
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='all_state'
|
||||
@facade_data_view ||= DossiersListFacades.new current_gestionnaire, liste, retrieve_procedure
|
||||
end
|
||||
|
||||
def smartlisting_dossier dossiers_list=nil, liste='all_state'
|
||||
dossiers_list_facade liste
|
||||
service = dossiers_list_facade.service
|
||||
|
||||
if param_page.nil?
|
||||
params[:dossiers_smart_listing] = {page: dossiers_list_facade.service.default_page}
|
||||
end
|
||||
|
||||
default_smart_listing_create :new_dossiers, service.nouveaux.without_followers.order_by_updated_at('asc')
|
||||
default_smart_listing_create :follow_dossiers, service.suivi.order_by_updated_at('asc')
|
||||
default_smart_listing_create :all_state_dossiers, service.all_state.order_by_updated_at('asc')
|
||||
default_smart_listing_create :archived_dossiers, service.archive
|
||||
|
||||
@archived_dossiers = service.archive
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def default_smart_listing_create name, collection
|
||||
smart_listing_create name,
|
||||
collection,
|
||||
partial: 'backoffice/dossiers/list',
|
||||
array: true,
|
||||
default_sort: dossiers_list_facade.service.default_sort
|
||||
end
|
||||
|
||||
def param_smart_listing
|
||||
params[:dossiers_smart_listing]
|
||||
end
|
||||
|
||||
def param_page
|
||||
if param_smart_listing.present?
|
||||
return 1 if params[:dossiers_smart_listing][:page].blank?
|
||||
params[:dossiers_smart_listing][:page]
|
||||
end
|
||||
end
|
||||
|
||||
def param_sort
|
||||
params[:dossiers_smart_listing][:sort] if param_smart_listing.present?
|
||||
end
|
||||
|
||||
def param_filter
|
||||
params[:filter_input]
|
||||
end
|
||||
|
||||
def param_liste
|
||||
@liste ||= params[:liste] || cookies[:liste] || 'all_state'
|
||||
end
|
||||
end
|
|
@ -1,50 +0,0 @@
|
|||
class Backoffice::PreferenceListDossierController < Backoffice::DossiersListController
|
||||
include SmartListing::Helper::ControllerExtensions
|
||||
helper SmartListing::Helper
|
||||
|
||||
before_action :authenticate_gestionnaire!
|
||||
before_action :params_procedure_id
|
||||
|
||||
def add
|
||||
PreferenceListDossier.create(
|
||||
libelle: params[:libelle],
|
||||
table: (params[:table].empty? ? nil : params[:table]),
|
||||
attr: params[:attr],
|
||||
attr_decorate: params[:attr_decorate],
|
||||
bootstrap_lg: params[:bootstrap_lg],
|
||||
order: nil,
|
||||
filter: nil,
|
||||
gestionnaire: current_gestionnaire,
|
||||
procedure_id: params_procedure_id
|
||||
)
|
||||
|
||||
render partial: path, formats: :js
|
||||
end
|
||||
|
||||
def reload_pref_list
|
||||
dossiers_list_facade
|
||||
|
||||
render partial: 'backoffice/dossiers/pref_list', id: params_procedure_id
|
||||
end
|
||||
|
||||
def delete
|
||||
PreferenceListDossier.delete(params[:pref_id])
|
||||
|
||||
render partial: path, formats: :js
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def path
|
||||
'backoffice/dossiers/pref_list'
|
||||
end
|
||||
|
||||
def params_procedure_id
|
||||
@procedure_id ||= params[:procedure_id]
|
||||
end
|
||||
|
||||
def retrieve_procedure
|
||||
return if params[:procedure_id].blank?
|
||||
current_gestionnaire.procedures.find params_procedure_id
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
class Backoffice::PrivateFormulairesController < ApplicationController
|
||||
before_action :authenticate_gestionnaire!
|
||||
|
||||
def update
|
||||
dossier = current_gestionnaire.dossiers.find(params[:dossier_id])
|
||||
|
||||
if params[:champs].present?
|
||||
ChampsService.save_champs dossier.champs_private, params
|
||||
champs_service_errors = ChampsService.build_error_messages(dossier.champs_private)
|
||||
|
||||
if champs_service_errors.empty?
|
||||
flash[:notice] = "Formulaire enregistré"
|
||||
else
|
||||
flash[:alert] = champs_service_errors
|
||||
end
|
||||
end
|
||||
|
||||
render 'backoffice/dossiers/formulaire_private', formats: :js
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
class BackofficeController < ApplicationController
|
||||
include SmartListing::Helper::ControllerExtensions
|
||||
helper SmartListing::Helper
|
||||
|
||||
before_action :authenticate_gestionnaire!, only: [:invitations]
|
||||
|
||||
def index
|
||||
if !gestionnaire_signed_in?
|
||||
redirect_to(controller: '/gestionnaires/sessions', action: :new)
|
||||
else
|
||||
redirect_to(:backoffice_dossiers)
|
||||
end
|
||||
end
|
||||
|
||||
def invitations
|
||||
pending_avis = current_gestionnaire.avis.without_answer.includes(dossier: [:procedure]).by_latest
|
||||
@pending_avis = smart_listing_create :pending_avis,
|
||||
pending_avis,
|
||||
partial: 'backoffice/dossiers/list_invitations',
|
||||
array: true
|
||||
|
||||
avis_with_answer = current_gestionnaire.avis.with_answer.includes(dossier: [:procedure]).by_latest
|
||||
@avis_with_answer = smart_listing_create :avis_with_answer,
|
||||
avis_with_answer,
|
||||
partial: 'backoffice/dossiers/list_invitations',
|
||||
array: true
|
||||
end
|
||||
end
|
|
@ -16,13 +16,8 @@ class CommentairesController < ApplicationController
|
|||
@commentaire.champ = @commentaire.dossier.champs.find(params[:champ_id]) if params[:champ_id]
|
||||
|
||||
dossier_id = params['dossier_id']
|
||||
if is_gestionnaire?
|
||||
@commentaire.email = current_gestionnaire.email
|
||||
@commentaire.dossier = current_gestionnaire.dossiers.find_by(id: dossier_id) || current_gestionnaire.avis.find_by!(dossier_id: dossier_id).dossier
|
||||
else
|
||||
@commentaire.email = current_user.email
|
||||
@commentaire.dossier = current_user.dossiers.find_by(id: dossier_id) || current_user.invites.find_by!(dossier_id: dossier_id).dossier
|
||||
end
|
||||
@commentaire.email = current_user.email
|
||||
@commentaire.dossier = current_user.dossiers.find_by(id: dossier_id) || current_user.invites.find_by!(dossier_id: dossier_id).dossier
|
||||
|
||||
@commentaire.file = params["file"]
|
||||
|
||||
|
@ -33,21 +28,11 @@ class CommentairesController < ApplicationController
|
|||
flash.alert = "Veuillez rédiger un message ou ajouter une pièce jointe (maximum 20 Mo)"
|
||||
end
|
||||
|
||||
if is_gestionnaire?
|
||||
current_gestionnaire.follow(@commentaire.dossier)
|
||||
|
||||
redirect_to url_for(controller: 'backoffice/dossiers', action: :show, id: params['dossier_id'])
|
||||
if current_user.email != @commentaire.dossier.user.email
|
||||
invite = Invite.where(dossier: @commentaire.dossier, email: current_user.email).first
|
||||
redirect_to url_for(controller: 'users/dossiers/invites', action: :show, id: invite.id)
|
||||
else
|
||||
if current_user.email != @commentaire.dossier.user.email
|
||||
invite = Invite.where(dossier: @commentaire.dossier, email: current_user.email).first
|
||||
redirect_to url_for(controller: 'users/dossiers/invites', action: :show, id: invite.id)
|
||||
else
|
||||
redirect_to users_dossier_recapitulatif_path(params['dossier_id'])
|
||||
end
|
||||
redirect_to users_dossier_recapitulatif_path(params['dossier_id'])
|
||||
end
|
||||
end
|
||||
|
||||
def is_gestionnaire?
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,11 +24,7 @@ class InvitesController < ApplicationController
|
|||
flash.alert = invite.errors.full_messages
|
||||
end
|
||||
|
||||
if gestionnaire_signed_in?
|
||||
redirect_to url_for(controller: 'backoffice/dossiers', action: :show, id: params['dossier_id'])
|
||||
else
|
||||
redirect_to url_for(controller: 'users/recapitulatif', action: :show, dossier_id: params['dossier_id'])
|
||||
end
|
||||
redirect_to url_for(controller: 'users/recapitulatif', action: :show, dossier_id: params['dossier_id'])
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -2,16 +2,9 @@ class RootController < ApplicationController
|
|||
layout 'new_application'
|
||||
|
||||
def index
|
||||
# TODO delete new_ui when old UI is no longer used
|
||||
if params[:new_ui].present? && gestionnaire_signed_in?
|
||||
return redirect_to procedures_path
|
||||
elsif administrateur_signed_in?
|
||||
if administrateur_signed_in?
|
||||
return redirect_to admin_procedures_path
|
||||
elsif gestionnaire_signed_in?
|
||||
# to be removed when old ui is deleted
|
||||
if params[:old_ui].present?
|
||||
return redirect_to backoffice_path
|
||||
end
|
||||
return redirect_to procedures_path
|
||||
elsif user_signed_in?
|
||||
return redirect_to users_dossiers_path
|
||||
|
|
|
@ -17,9 +17,7 @@ class DossierDecorator < Draper::Decorator
|
|||
end
|
||||
|
||||
def url(gestionnaire_signed_in)
|
||||
if gestionnaire_signed_in
|
||||
backoffice_dossier_path(id)
|
||||
elsif brouillon?
|
||||
if brouillon?
|
||||
users_dossier_description_path(id)
|
||||
else
|
||||
users_dossier_recapitulatif_path(id)
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
class DossiersListFacades
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
attr_accessor :procedure, :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
|
||||
@service ||= DossiersListGestionnaireService.new @current_devise_profil, @liste, @procedure
|
||||
end
|
||||
|
||||
def total_dossier
|
||||
current_devise_profil.dossiers.not_archived.count
|
||||
end
|
||||
|
||||
def total_dossier_follow
|
||||
@current_devise_profil.followed_dossiers.count
|
||||
end
|
||||
|
||||
def gestionnaire_procedures_name_and_id_list
|
||||
@current_devise_profil.procedures.order('libelle ASC').inject([]) { |acc, procedure| acc.push({id: procedure.id, libelle: procedure.libelle, unread_notifications: @current_devise_profil.dossiers_with_notifications_count_for_procedure(procedure)}) }
|
||||
end
|
||||
|
||||
def unread_notifications
|
||||
current_devise_profil.notifications
|
||||
end
|
||||
|
||||
def dossiers_with_unread_notifications
|
||||
(unread_notifications.inject([]) { |acc, notif| acc.push(notif.dossier) }).uniq
|
||||
end
|
||||
|
||||
def procedure_id
|
||||
@procedure.nil? ? nil : @procedure.id
|
||||
end
|
||||
|
||||
def dossiers_to_display
|
||||
service.dossiers_to_display
|
||||
end
|
||||
|
||||
def preference_list_dossiers_filter
|
||||
@list_table_columns ||= @current_devise_profil.preference_list_dossiers.where(procedure: @procedure).order(:id)
|
||||
end
|
||||
|
||||
def active_filter? preference
|
||||
return true if @procedure.nil? || preference.table != 'champs' || (preference.table == 'champs' && preference.filter.present?)
|
||||
|
||||
preference_list_dossiers_filter.where(table: :champs).where.not(filter: '').size == 0
|
||||
end
|
||||
|
||||
def all_state_total
|
||||
service.all_state.count
|
||||
end
|
||||
|
||||
def nouveaux_total
|
||||
service.nouveaux.without_followers.count
|
||||
end
|
||||
|
||||
def suivi_total
|
||||
service.suivi.count
|
||||
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 base_url liste
|
||||
@procedure.nil? ? backoffice_dossiers_path(liste: liste) : backoffice_dossiers_procedure_path(id: @procedure.id, liste: liste)
|
||||
end
|
||||
end
|
|
@ -4,19 +4,13 @@ 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, -> { publiees_ou_archivees }, through: :assign_to
|
||||
has_many :dossiers, -> { state_not_brouillon }, through: :procedures
|
||||
has_many :followed_dossiers, through: :follows, source: :dossier
|
||||
has_many :follows
|
||||
has_many :preference_list_dossiers
|
||||
has_many :avis
|
||||
|
||||
after_create :build_default_preferences_list_dossier
|
||||
after_create :build_default_preferences_smart_listing_page
|
||||
|
||||
include CredentialsSyncableConcern
|
||||
|
||||
def procedure_filter
|
||||
|
@ -52,30 +46,6 @@ class Gestionnaire < ActiveRecord::Base
|
|||
procedures.find_by(id: procedure_id).present?
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
def build_default_preferences_smart_listing_page
|
||||
PreferenceSmartListingPage.create(page: 1, procedure: nil, gestionnaire: self, liste: 'a_traiter')
|
||||
end
|
||||
|
||||
def notifications
|
||||
Notification.where(already_read: false, dossier_id: follows.pluck(:dossier_id)).order("updated_at DESC")
|
||||
end
|
||||
|
|
|
@ -1,133 +0,0 @@
|
|||
class PreferenceListDossier < ActiveRecord::Base
|
||||
belongs_to :gestionnaire
|
||||
belongs_to :procedure
|
||||
|
||||
def table_attr
|
||||
return self.attr if table.nil? || table.empty?
|
||||
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,
|
||||
procedure: columns_procedure,
|
||||
entreprise: columns_entreprise,
|
||||
etablissement: columns_etablissement,
|
||||
user: columns_user,
|
||||
france_connect: columns_france_connect
|
||||
}
|
||||
|
||||
columns = columns.merge({
|
||||
champs: columns_champs_procedure(procedure_id),
|
||||
champs_private: columns_champs_private_procedure(procedure_id)
|
||||
}) if procedure_id.present?
|
||||
|
||||
columns
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.columns_dossier
|
||||
table = nil
|
||||
|
||||
{
|
||||
dossier_id: create_column('Nº', 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('État', 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('Organisme', 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('Libellé NAF', 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.columns_champs_procedure procedure_id
|
||||
table = 'champs'
|
||||
|
||||
if procedure = Procedure.find_by(id: procedure_id)
|
||||
procedure.types_de_champ.inject({}) do |acc, type_de_champ|
|
||||
acc = acc.merge({
|
||||
"type_de_champ_#{type_de_champ.id}" => create_column(type_de_champ.libelle, table, type_de_champ.id, 'value', 2)
|
||||
}) if type_de_champ.field_for_list?
|
||||
acc
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.columns_champs_private_procedure procedure_id
|
||||
table = 'champs_private'
|
||||
|
||||
if procedure = Procedure.find_by(id: procedure_id)
|
||||
procedure.types_de_champ_private.inject({}) do |acc, type_de_champ|
|
||||
acc = acc.merge({
|
||||
"type_de_champ_private_#{type_de_champ.id}" => create_column(type_de_champ.libelle, table, type_de_champ.id, 'value', 2)
|
||||
}) if type_de_champ.field_for_list?
|
||||
acc
|
||||
end
|
||||
end
|
||||
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
|
|
@ -1,11 +0,0 @@
|
|||
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
|
|
@ -14,8 +14,6 @@ class Procedure < ActiveRecord::Base
|
|||
has_many :assign_to, dependent: :destroy
|
||||
has_many :gestionnaires, through: :assign_to
|
||||
|
||||
has_many :preference_list_dossiers
|
||||
|
||||
has_one :initiated_mail, class_name: "Mails::InitiatedMail", dependent: :destroy
|
||||
has_one :received_mail, class_name: "Mails::ReceivedMail", dependent: :destroy
|
||||
has_one :closed_mail, class_name: "Mails::ClosedMail", dependent: :destroy
|
||||
|
|
|
@ -16,11 +16,4 @@ class AccompagnateurService
|
|||
AssignTo.where(gestionnaire: @accompagnateur, procedure: @procedure).delete_all
|
||||
end
|
||||
end
|
||||
|
||||
def build_default_column
|
||||
return if @to != ASSIGN
|
||||
return if PreferenceListDossier.where(gestionnaire: @accompagnateur, procedure: @procedure).present?
|
||||
|
||||
@accompagnateur.build_default_preferences_list_dossier @procedure.id
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,184 +0,0 @@
|
|||
class DossiersListGestionnaireService
|
||||
def initialize current_devise_profil, liste, procedure = nil
|
||||
@current_devise_profil = current_devise_profil
|
||||
@liste = (DossiersListGestionnaireService.dossiers_liste_libelle.include?(liste) ? liste : 'all_state')
|
||||
@procedure = procedure
|
||||
end
|
||||
|
||||
def dossiers_to_display
|
||||
@dossiers_to_display ||=
|
||||
{'nouveaux' => nouveaux,
|
||||
'a_traiter' => nouveaux,
|
||||
'a_instruire' => a_instruire,
|
||||
'termine' => termine,
|
||||
'archive' => archive,
|
||||
'all_state' => all_state}[@liste]
|
||||
end
|
||||
|
||||
def self.dossiers_liste_libelle
|
||||
['nouveaux', 'suivi', 'a_traiter', 'a_instruire', 'termine', 'all_state']
|
||||
end
|
||||
|
||||
def all_state
|
||||
@all_state ||= filter_dossiers.all_state.order_by_updated_at('asc')
|
||||
end
|
||||
|
||||
def suivi
|
||||
@suivi ||= @current_devise_profil.followed_dossiers.merge(dossiers_to_display)
|
||||
end
|
||||
|
||||
def nouveaux
|
||||
@nouveaux ||= filter_dossiers.en_construction.order_by_updated_at('asc')
|
||||
end
|
||||
|
||||
def a_instruire
|
||||
@a_instruire ||= filter_dossiers.en_instruction.order_by_updated_at('asc')
|
||||
end
|
||||
|
||||
def archive
|
||||
@archive ||= filter_dossiers.archived
|
||||
end
|
||||
|
||||
def termine
|
||||
@termine ||= filter_dossiers.termine.order_by_updated_at('asc')
|
||||
end
|
||||
|
||||
def filter_dossiers
|
||||
@filter_dossiers ||= @procedure.nil? ? @current_devise_profil.dossiers.joins(joins_filter).where(where_filter) : @procedure.dossiers.joins(joins_filter).where(where_filter)
|
||||
@filter_dossiers.distinct
|
||||
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
|
||||
|
||||
if pref
|
||||
if pref.liste != @liste || pref.procedure != @procedure
|
||||
pref.liste = @liste
|
||||
pref.procedure = @procedure
|
||||
|
||||
if new_page.nil?
|
||||
pref.page = 1
|
||||
pref.save
|
||||
end
|
||||
end
|
||||
|
||||
if new_page.present?
|
||||
pref.page = new_page
|
||||
pref.save
|
||||
end
|
||||
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!
|
||||
|
||||
preference = @current_devise_profil.preference_list_dossiers
|
||||
.find_by(table: table, attr: attr, procedure: @procedure)
|
||||
|
||||
preference.update order: order if preference.present?
|
||||
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) if preference.table.present? && preference.filter.present?
|
||||
acc
|
||||
end
|
||||
end
|
||||
|
||||
def where_filter
|
||||
filter_preference_list.inject('') do |acc, preference|
|
||||
if preference.filter.present?
|
||||
filter = preference.filter.tr('*', '%').gsub("'", "''")
|
||||
filter = "%" + filter + "%" if !filter.include? '%'
|
||||
|
||||
value = preference.table_with_s_attr
|
||||
|
||||
if preference.table_attr.include?('champs')
|
||||
value = 'champs.value'
|
||||
|
||||
acc += (acc.to_s.empty? ? ''.to_s : " AND ") +
|
||||
'champs.type_de_champ_id = ' + preference.attr
|
||||
end
|
||||
|
||||
acc += (acc.to_s.empty? ? ''.to_s : " AND ") +
|
||||
"CAST(" +
|
||||
value +
|
||||
" 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.strip
|
||||
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
|
|
@ -1 +0,0 @@
|
|||
= render partial: '/users/recapitulatif/commentaires_flux'
|
|
@ -1,10 +0,0 @@
|
|||
.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 @facade_data_view.filter_url, { class: 'panel-body form-inline', method: :post } do
|
||||
%input.form-control.filter_input{ name: "filter_input[#{preference.table_attr}]", style: 'width: 69%;', value: "#{preference.filter}" }
|
||||
%button.btn.btn-sm.btn-success
|
||||
%i.fa.fa-check
|
||||
.btn.btn-sm.btn-danger.erase-filter
|
||||
%i.fa.fa-remove
|
|
@ -1,13 +0,0 @@
|
|||
%h3
|
||||
= t('dynamics.dossiers.followers.title')
|
||||
|
||||
%br
|
||||
.row
|
||||
.col-xs-4
|
||||
- if @facade.followers.size > 0
|
||||
%ul
|
||||
- @facade.followers.each do |follower|
|
||||
%li
|
||||
= follower.email
|
||||
- else
|
||||
Aucune personne ne suit ce dossier
|
|
@ -1,70 +0,0 @@
|
|||
%table#dossiers-list.table
|
||||
%thead
|
||||
- if smart_listing.name.to_s == 'follow_dossiers'
|
||||
%th.col-xs-1.center
|
||||
%i.fa.fa-bell
|
||||
%th.col-xs-1
|
||||
État
|
||||
|
||||
- @facade_data_view.preference_list_dossiers_filter.each do |preference|
|
||||
- if preference.libelle != 'Statut' && preference.libelle != 'État'
|
||||
%th{ class: "col-md-#{preference.bootstrap_lg} col-lg-#{preference.bootstrap_lg}" }
|
||||
- if preference.table.to_s.include? 'champs'
|
||||
= preference.libelle
|
||||
- else
|
||||
= smart_listing.sortable preference.libelle, preference.table_attr
|
||||
- if @facade_data_view.active_filter? preference
|
||||
%i.filter.fa.fa-filter{ style: "color: #{(preference.filter.blank? ? 'grey' : 'orange')}", id: "filter_#{smart_listing.name.to_s}_#{preference.table_attr.sub('.', '_')}" }
|
||||
= render partial: 'backoffice/dossiers/filter_framed', locals: { preference: preference, filter_framed_id: "framed_filter_#{smart_listing.name.to_s}_#{preference.table_attr.sub('.', '_')}" }
|
||||
|
||||
%th.col-xs-1.center Actions
|
||||
%th.col-xs-1.center Abonnés
|
||||
|
||||
- if smart_listing.present?
|
||||
- smart_listing.collection.each do |dossier|
|
||||
%tr.dossier-row{ id: "tr_dossier_#{dossier.id}", 'data-dossier_url' => backoffice_dossier_url(id: dossier.id) }
|
||||
- if smart_listing.name.to_s == 'follow_dossiers'
|
||||
%td.col-xs-1.center
|
||||
- total_notif = dossier.notifications.where(already_read: false).count
|
||||
- if total_notif == 0
|
||||
.badge.progress-bar-default
|
||||
= total_notif
|
||||
- else
|
||||
.badge.progress-bar-warning
|
||||
= total_notif
|
||||
%td.col-xs-1
|
||||
= dossier.decorate.display_state
|
||||
- @facade_data_view.preference_list_dossiers_filter.each_with_index do |preference, index|
|
||||
- if preference.libelle != 'Statut' && preference.libelle != 'État'
|
||||
%td
|
||||
- if preference.table.nil? || preference.table.empty?
|
||||
- value = dossier.decorate.public_send(preference.attr_decorate)
|
||||
- elsif preference.table == 'champs'
|
||||
- value = dossier.champs.find_by_type_de_champ_id(preference.attr).value rescue nil
|
||||
- elsif preference.table == 'champs_private'
|
||||
- value = dossier.champs_private.find_by_type_de_champ_id(preference.attr).value rescue nil
|
||||
- else
|
||||
- begin
|
||||
- value = dossier.public_send(preference.table).decorate.public_send(preference.attr_decorate)
|
||||
- rescue NoMethodError
|
||||
- value = ''
|
||||
|
||||
= value
|
||||
|
||||
%td.center
|
||||
- if current_gestionnaire.follow?(dossier)
|
||||
= link_to('Quitter', unfollow_dossier_path(dossier.procedure, dossier), method: :patch, class: 'btn-sm btn-danger', id: "suivre_dossier_#{dossier.id}")
|
||||
- else
|
||||
= link_to('Suivre', follow_dossier_path(dossier.procedure, dossier), method: :patch, class: 'btn-sm btn-primary', id: "suivre_dossier_#{dossier.id}")
|
||||
%td.center{ style: "color: #{dossier.total_follow == 0 ? 'red' : ''}" }
|
||||
= dossier.total_follow
|
||||
|
||||
= smart_listing.paginate
|
||||
- if smart_listing.name.to_s == 'follow_dossiers' && smart_listing.collection.count > 0
|
||||
= smart_listing.pagination_per_page_links
|
||||
%br
|
||||
|
||||
|
||||
- if smart_listing.empty?
|
||||
%h4.center
|
||||
Aucun dossier
|
|
@ -1,20 +0,0 @@
|
|||
- if smart_listing.collection.any?
|
||||
%table#dossiers-list.table
|
||||
%thead
|
||||
%th
|
||||
Nº
|
||||
%th
|
||||
Procédure
|
||||
%th
|
||||
Invité le
|
||||
%tbody
|
||||
- smart_listing.collection.each do |avis|
|
||||
%tr.dossier-row{ id: "tr_dossier_#{avis.dossier.id}", 'data-dossier_url' => backoffice_dossier_url(id: avis.dossier.id) }
|
||||
%td= avis.dossier.id
|
||||
%td= avis.dossier.procedure.libelle
|
||||
%td= avis.created_at.strftime('%d/%m/%Y %H:%M')
|
||||
= smart_listing.paginate
|
||||
|
||||
- else
|
||||
.center{ colspan: 2 }
|
||||
%em Aucun dossier
|
|
@ -1,46 +0,0 @@
|
|||
%button#pref-list-dossier-close-action.btn.btn-danger.btn-xs.fixed-right
|
||||
%i.fa.fa-close
|
||||
%h3
|
||||
= t('dynamics.backoffice.pref_list.title')
|
||||
|
||||
%p{ style: 'margin-top: 15px; margin-bottom: 20px;' }
|
||||
= t('dynamics.backoffice.pref_list.description')
|
||||
|
||||
%h4.text-primary
|
||||
Actuelles
|
||||
|
||||
%ul
|
||||
- @facade_data_view.preference_list_dossiers_filter.each_with_index do |preference, index|
|
||||
%li
|
||||
= form_tag backoffice_preference_list_dossier_delete_path, method: :delete, remote: true do
|
||||
= hidden_field_tag :pref_id, preference.id
|
||||
= hidden_field_tag :procedure_id, preference.procedure_id
|
||||
= preference.libelle
|
||||
%button.btn.btn-default.btn-xs{ type: :submit, id: "delete_pref_list_#{preference[:table]}_#{preference[:attr]}" }
|
||||
%i.fa.fa-minus
|
||||
|
||||
%h4.text-success{ style: 'margin-top: 15px;' }
|
||||
Disponibles
|
||||
|
||||
%table
|
||||
- PreferenceListDossier.available_columns_for(@facade_data_view.procedure_id).each_with_index do |tables, index|
|
||||
- if index%2 == 0 || tables.first.to_s.include?('champs')
|
||||
%tr
|
||||
|
||||
%td.col-xs-5{ style: 'vertical-align: top;', colspan: (tables.first == :champs ? 2 : 1) }
|
||||
%h5= tables.first.to_s.gsub('_', ' ').capitalize
|
||||
%ul
|
||||
- if tables.second
|
||||
- tables.second.each do |columns|
|
||||
%li
|
||||
= form_tag backoffice_preference_list_dossier_add_path, method: :post, remote: true do
|
||||
= hidden_field_tag :libelle, columns.second[:libelle]
|
||||
= hidden_field_tag :table, columns.second[:table]
|
||||
= hidden_field_tag :attr, columns.second[:attr]
|
||||
= hidden_field_tag :attr_decorate, columns.second[:attr_decorate]
|
||||
= hidden_field_tag :bootstrap_lg, columns.second[:bootstrap_lg]
|
||||
= hidden_field_tag :procedure_id, @facade_data_view.procedure_id
|
||||
|
||||
= columns.second[:libelle]
|
||||
%button.btn.btn-default.btn-xs{ type: :submit, id: "add_pref_list_#{columns.second[:table]}_#{columns.second[:attr]}" }
|
||||
%i.fa.fa-plus
|
|
@ -1,14 +0,0 @@
|
|||
$.ajax({
|
||||
method: 'get',
|
||||
url: '/backoffice/preference_list_dossier/reload_smartlisting?procedure_id=<%= @procedure_id %>',
|
||||
async: true
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
methd: 'get',
|
||||
url: '/backoffice/preference_list_dossier/reload_pref_list?procedure_id=<%= @procedure_id %>',
|
||||
async: true
|
||||
}).done(function (data) {
|
||||
$("#pref-list-menu").html(data);
|
||||
pref_list_dossier_actions();
|
||||
});
|
|
@ -1,4 +0,0 @@
|
|||
<% flash.each do |type, message| %>
|
||||
$("#flash_message").html("<div class=\"alert alert-success move-up\" style=\"display: block:\"> <%= sanitize(message) %></div>").children().fadeOut(5000)
|
||||
<% end %>
|
||||
<% flash.clear %>
|
|
@ -1,64 +0,0 @@
|
|||
#backoffice-index
|
||||
#pref-list-menu
|
||||
= render partial: 'backoffice/dossiers/pref_list'
|
||||
|
||||
.default-data-block
|
||||
.row.show-block#new_dossiers
|
||||
.header
|
||||
.col-xs-10.title
|
||||
.carret-right
|
||||
.carret-down
|
||||
Nouveaux dossiers
|
||||
.col-xs-2.count
|
||||
= pluralize(@facade_data_view.nouveaux_total, "dossier")
|
||||
.body
|
||||
= smart_listing_render :new_dossiers
|
||||
|
||||
.row.center
|
||||
.col-xs-3
|
||||
= link_to 'Tous les états', '?liste=all_state', class: 'text-info', style: "text-decoration: #{@facade_data_view.liste == 'all_state'? 'underline' : ''}"
|
||||
.col-xs-3
|
||||
= link_to 'En construction', '?liste=a_traiter', class: 'text-danger', style: "text-decoration: #{@facade_data_view.liste == 'a_traiter'? 'underline' : ''}"
|
||||
.col-xs-3
|
||||
= link_to 'En instruction', '?liste=a_instruire', class: 'text-warning', style: "text-decoration: #{@facade_data_view.liste == 'a_instruire'? 'underline' : ''}"
|
||||
.col-xs-3
|
||||
= link_to 'Terminés', '?liste=termine', class: 'text-success', style: "text-decoration: #{@facade_data_view.liste == 'termine'? 'underline' : ''}"
|
||||
|
||||
.default-data-block.default_visible
|
||||
.row.show-block#follow_dossiers
|
||||
.header
|
||||
.col-xs-10.title
|
||||
.carret-right
|
||||
.carret-down
|
||||
Dossiers suivis
|
||||
.col-xs-2.count
|
||||
= pluralize(@facade_data_view.suivi_total, "dossier")
|
||||
.body
|
||||
= smart_listing_render :follow_dossiers
|
||||
|
||||
.default-data-block
|
||||
.row.show-block#all_dossiers
|
||||
.header
|
||||
.col-xs-10.title
|
||||
.carret-right
|
||||
.carret-down
|
||||
Tous les dossiers
|
||||
.col-xs-2.count
|
||||
= pluralize(@facade_data_view.all_state_total, "dossier")
|
||||
.body
|
||||
= smart_listing_render :all_state_dossiers
|
||||
|
||||
|
||||
- if @archived_dossiers
|
||||
.default-data-block
|
||||
.row.show-block#archived_dossiers
|
||||
.header
|
||||
.col-xs-10.title
|
||||
.carret-right
|
||||
.carret-down
|
||||
Dossiers archivés
|
||||
.col-xs-2.count
|
||||
= pluralize(@archived_dossiers.count, "dossier")
|
||||
|
||||
.body
|
||||
= smart_listing_render :archived_dossiers
|
|
@ -1,6 +0,0 @@
|
|||
<%= smart_listing_update :new_dossiers, {force: true} %>
|
||||
<%= smart_listing_update :follow_dossiers, {force: true} %>
|
||||
<%= smart_listing_update :all_state_dossiers, {force: true} %>
|
||||
|
||||
filters_init();
|
||||
link_init();
|
|
@ -1,16 +0,0 @@
|
|||
#backoffice-search
|
||||
#pref-list-menu
|
||||
= render partial: 'backoffice/dossiers/pref_list'
|
||||
|
||||
.default-data-block.default_visible
|
||||
.row.show-block#new_dossiers
|
||||
.header
|
||||
.col-lg-10.col-md-10.col-sm-10.col-xs-10.title
|
||||
.carret-right
|
||||
.carret-down
|
||||
Résultat de la recherche
|
||||
.col-lg-2.col-md-2.col-sm-2.col-xs-2.count
|
||||
= @dossiers.count
|
||||
dossiers
|
||||
.body
|
||||
= smart_listing_render :search
|
|
@ -1,4 +0,0 @@
|
|||
<%= smart_listing_update :search %>
|
||||
|
||||
filters_init();
|
||||
link_init();
|
|
@ -1,2 +0,0 @@
|
|||
#backoffice-dossier-show.col-xs-12
|
||||
= render partial: "dossiers/dossier_show"
|
|
@ -1,22 +0,0 @@
|
|||
.col-md-12
|
||||
.default-data-block.default_visible
|
||||
.row.show-block
|
||||
.header
|
||||
.title
|
||||
.carret-right
|
||||
.carret-down
|
||||
= "#{@pending_avis.count} avis à rendre"
|
||||
.body
|
||||
= smart_listing_render :pending_avis
|
||||
|
||||
%br
|
||||
|
||||
.default-data-block
|
||||
.row.show-block
|
||||
.header
|
||||
.title
|
||||
.carret-right
|
||||
.carret-down
|
||||
= "#{@avis_with_answer.count} avis #{"rendu".pluralize(@avis_with_answer.count)}"
|
||||
.body
|
||||
= smart_listing_render :avis_with_answer
|
|
@ -1,4 +0,0 @@
|
|||
<%= smart_listing_update :pending_avis %>
|
||||
<%= smart_listing_update :avis_with_answer %>
|
||||
|
||||
link_init();
|
|
@ -1,56 +0,0 @@
|
|||
- if current_gestionnaire && current_gestionnaire.assigned_on_procedure?(@facade.dossier.procedure_id)
|
||||
|
||||
.default-data-block.default_visible
|
||||
.row.show-block.infos
|
||||
.header
|
||||
.col-xs-12.title
|
||||
.carret-right
|
||||
.carret-down
|
||||
AVIS EXTERNES
|
||||
.body
|
||||
.display-block-on-print
|
||||
- dossier_facade.dossier.avis.by_latest.each do |avis|
|
||||
- if avis.answer
|
||||
.panel.panel-success
|
||||
.panel-heading
|
||||
%strong= avis.email_to_display
|
||||
a donné son avis le
|
||||
= avis.updated_at.localtime.strftime('%d/%m/%Y à %H:%M')
|
||||
.panel-body
|
||||
%strong Vous :
|
||||
= avis.introduction
|
||||
%hr
|
||||
%strong= "#{avis.email_to_display} :"
|
||||
= avis.answer
|
||||
- else
|
||||
.panel.panel-info
|
||||
.panel-heading
|
||||
Avis demandé à
|
||||
%strong= avis.email_to_display
|
||||
le
|
||||
= avis.created_at.localtime.strftime('%d/%m/%Y à %H:%M')
|
||||
.panel-body
|
||||
%strong Vous :
|
||||
= avis.introduction
|
||||
%hr
|
||||
.center
|
||||
%em Avis en attente
|
||||
|
||||
-# FIXME prevent bug when the user is also a gestionnaire on the procedure #375
|
||||
- if @new_avis.present?
|
||||
.hidden-print
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
Demander un avis externe
|
||||
.panel-body
|
||||
.help-block
|
||||
Invitez une personne externe à consulter le dossier et à vous donner un avis sur celui ci.
|
||||
%br
|
||||
Cette personne pourra également contribuer au fil de messagerie, mais ne pourra pas modifier le dossier.
|
||||
|
||||
= simple_form_for @new_avis, url: backoffice_dossier_avis_index_path(dossier_facade.dossier.object.id) do |f|
|
||||
|
||||
= f.input 'email', label: "Email de la personne qui doit donner un avis"
|
||||
= f.input 'introduction', label: "Message"
|
||||
|
||||
= f.submit "Envoyer la demande d'avis", class: 'btn btn-default'
|
|
@ -1,5 +1,3 @@
|
|||
= render partial: 'dossiers/edit_avis', locals: { dossier_facade: @facade }
|
||||
|
||||
= render partial: 'dossiers/attestation', locals: { dossier: @facade.dossier }
|
||||
|
||||
= render partial: 'dossiers/messagerie', locals: { dossier_facade: @facade }
|
||||
|
@ -56,19 +54,3 @@
|
|||
|
||||
= render partial: '/users/carte/map', locals: { dossier: @facade.dossier }
|
||||
= render partial: 'users/carte/init_carto', locals: { dossier: @facade.dossier }
|
||||
|
||||
- if @current_gestionnaire && gestionnaire_signed_in? && current_gestionnaire.assigned_on_procedure?(@facade.dossier.procedure_id) && @champs_private.present?
|
||||
.default-data-block.default_visible
|
||||
.row.show-block#private-fields
|
||||
.header
|
||||
.col-xs-10.title
|
||||
.carret-right
|
||||
.carret-down
|
||||
= "formulaire privé".upcase
|
||||
.col-xs-2.count
|
||||
- private_fields_count = @champs_private.count
|
||||
= (private_fields_count == 1) ? "1 champ" : "#{private_fields_count} champs"
|
||||
.body
|
||||
= render partial: '/dossiers/infos_private_fields'
|
||||
|
||||
= render partial: 'dossiers/avis', locals: { dossier_facade: @facade }
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
.dropdown.pull-right#download-menu
|
||||
%a.dropdown-toggle.button-navbar{ type: :button, 'data-toggle' => 'dropdown', 'aria-haspopup' => true, 'aria-expanded' => false }
|
||||
%i.fa.fa-download
|
||||
Télécharger tous les dossiers
|
||||
%span.caret
|
||||
%ul.dropdown-menu.dropdown-menu-right
|
||||
%li
|
||||
= link_to backoffice_download_dossiers_tps_path(format: :csv, procedure_id: params[:id]), { class: 'btn btn-sm export-link' } do
|
||||
= t('dynamics.backoffice.format_csv')
|
||||
%li
|
||||
= link_to backoffice_download_dossiers_tps_path(format: :xlsx, procedure_id: params[:id]), { class: 'btn btn-sm export-link' } do
|
||||
= t('dynamics.backoffice.format_xlsx')
|
||||
%li
|
||||
= link_to backoffice_download_dossiers_tps_path(format: :ods, procedure_id: params[:id]), { class: 'btn btn-sm export-link' } do
|
||||
= t('dynamics.backoffice.format_ods')
|
|
@ -1,13 +0,0 @@
|
|||
- if current_gestionnaire
|
||||
- avis_for_dossier = current_gestionnaire.avis.for_dossier(dossier_facade.dossier.id).by_latest
|
||||
- if avis_for_dossier.any?
|
||||
.panel.panel-default
|
||||
.panel-body
|
||||
%h4 Votre avis est sollicité sur le dossier :
|
||||
- avis_for_dossier.each do |avis|
|
||||
%hr
|
||||
%p= avis.introduction
|
||||
= simple_form_for avis, url: backoffice_dossier_avis_path(dossier_facade.dossier, avis) do |f|
|
||||
= f.input 'answer', label: "Votre avis"
|
||||
- submit_label = if avis.answer then "Modifier votre avis" else "Enregistrer votre avis" end
|
||||
= f.submit submit_label, class: 'btn btn-default'
|
|
@ -1,6 +0,0 @@
|
|||
.row{ style: 'margin-top: -20px;' }
|
||||
.col-xs-12
|
||||
= form_for @facade.dossier, url: { controller: 'backoffice/private_formulaires', action: :update, dossier_id: @facade.dossier.id }, remote: true do
|
||||
= render partial: '/users/description/champs', locals: { private: true }
|
||||
.row.center
|
||||
= submit_tag :Enregistrer, { class: 'btn-action' }
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
%h2{ style: 'font-size: 20px; font-weight: 300; margin: 25px 0 5px;' }
|
||||
#{procedure_overview.procedure.libelle}
|
||||
= link_to 'voir', backoffice_dossiers_procedure_url(procedure_overview.procedure), style: 'color: #4393F3; font-size: 14px;'
|
||||
= link_to 'voir', procedure_url(procedure_overview.procedure), style: 'color: #4393F3; font-size: 14px;'
|
||||
%table{ cellpadding: '0', cellspacing: '0', style: 'width: 100%; padding-bottom: 20px;' }
|
||||
%tbody
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
|||
- if procedure_overview.old_dossiers_en_construction.count < 6
|
||||
\:
|
||||
- old_dossiers_en_construction = procedure_overview.old_dossiers_en_construction.map do |old_dossier|
|
||||
- link_to "nº #{old_dossier.id}", backoffice_dossier_url(old_dossier), style: 'color: #4393F3;'
|
||||
- link_to "nº #{old_dossier.id}", dossier_url(procedure_overview.procedure, old_dossier), style: 'color: #4393F3;'
|
||||
- end.join(', ')
|
||||
= sanitize(old_dossiers_en_construction, attributes: %w(href style))
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
|||
- if procedure_overview.old_dossiers_en_instruction.count < 6
|
||||
\:
|
||||
- old_dossiers_en_instruction = procedure_overview.old_dossiers_en_instruction.map do |old_dossier|
|
||||
- link_to "nº #{old_dossier.id}", backoffice_dossier_url(old_dossier), style: 'color: #4393F3;'
|
||||
- link_to "nº #{old_dossier.id}", dossier_url(procedure_overview.procedure, old_dossier), style: 'color: #4393F3;'
|
||||
- end.join(', ')
|
||||
= sanitize(old_dossiers_en_instruction, attributes: %w(href style))
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
.col-xs-2
|
||||
%a#title-navbar{ href: root_path(old_ui: 1) }
|
||||
%a#title-navbar{ href: root_path }
|
||||
.row#home
|
||||
.col-lg-6.no-padding
|
||||
= image_tag('marianne_small.png', class: 'logo')
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
.header-inner-content
|
||||
|
||||
.flex.align-center
|
||||
-# TODO delete new_ui when old UI is no longer used
|
||||
= link_to root_path(new_ui: 1), class: "header-logo" do
|
||||
= link_to root_path, class: "header-logo" do
|
||||
%img{ src: image_url("header/logo-tps.svg") }
|
||||
|
||||
- if gestionnaire_signed_in?
|
||||
|
@ -19,8 +18,6 @@
|
|||
- avis_counter = current_gestionnaire.avis.without_answer.count
|
||||
- if avis_counter > 0
|
||||
%span.badge.warning= avis_counter
|
||||
%li
|
||||
= link_to "Ancienne interface", backoffice_dossiers_path, class: 'tab-link'
|
||||
%li
|
||||
.tab-link.contact-link
|
||||
Contact
|
||||
|
|
|
@ -36,10 +36,6 @@
|
|||
.row.no-margin
|
||||
- if RenderPartialService.left_panel_exist? @left_pannel_url
|
||||
.col-xs-2#left-panel
|
||||
- if gestionnaire_signed_in?
|
||||
#search-block
|
||||
= render partial: 'layouts/left_panels/search_area'
|
||||
|
||||
= render partial: @left_pannel_url
|
||||
- main_container_size = 10
|
||||
- else
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
= render partial: 'layouts/left_panels/left_panel_backoffice_dossierscontroller_index'
|
|
@ -1,48 +0,0 @@
|
|||
#first-block
|
||||
.dossiers-en-cours
|
||||
.count= current_gestionnaire.followed_dossiers.count
|
||||
.text SUIVIS
|
||||
.nouveaux-dossiers
|
||||
.count= current_gestionnaire.dossiers.en_construction.count
|
||||
.text NOUVEAUX
|
||||
.nouvelles-notifications
|
||||
.count= current_gestionnaire.dossiers_with_notifications_count
|
||||
.text MODIFIÉS
|
||||
|
||||
#action-block
|
||||
|
||||
#menu-block
|
||||
.split-hr-left
|
||||
#switch-buttons
|
||||
#switch-procedures.active Procédures
|
||||
#switch-notifications Notifications
|
||||
|
||||
#infos-block
|
||||
.split-hr-left
|
||||
#procedure-list
|
||||
- if current_gestionnaire.avis.any?
|
||||
= link_to backoffice_invitations_path do
|
||||
.procedure-list-element{ class: ('active' if request.path == backoffice_invitations_path) }
|
||||
Invitations
|
||||
- current_gestionnaire.procedures.by_libelle.each do |procedure|
|
||||
= link_to backoffice_dossiers_procedure_path(procedure.id), { title: procedure.libelle } do
|
||||
.procedure-list-element{ class: ('active' if procedure.id.to_s == params[:id]) }
|
||||
= procedure.libelle.truncate(50)
|
||||
- total_new = procedure.dossiers.en_construction.count
|
||||
- if total_new > 0
|
||||
.badge.progress-bar-success{ title: 'Nouveaux dossiers' }
|
||||
= total_new
|
||||
- unread_notif_count = current_gestionnaire.dossiers_with_notifications_count_for_procedure(procedure)
|
||||
- if unread_notif_count > 0
|
||||
.badge.progress-bar-warning{ title: 'Notifications' }
|
||||
= unread_notif_count
|
||||
#notifications-list.hidden
|
||||
- if current_gestionnaire.notifications.empty?
|
||||
.no-notification Aucune notification pour le moment.
|
||||
- else
|
||||
- current_gestionnaire.notifications.includes(:dossier).map(&:dossier).uniq.each do |dossier|
|
||||
= link_to backoffice_dossier_path(dossier.id) do
|
||||
.notification
|
||||
.dossier-index= "Dossier nº #{dossier.id}"
|
||||
.updated-at-index= dossier.first_unread_notification.created_at.localtime.strftime('%d/%m %H:%M')
|
||||
.count= dossier.unreaded_notifications.count
|
|
@ -1 +0,0 @@
|
|||
= render partial: 'layouts/left_panels/left_panel_backoffice_dossierscontroller_index'
|
|
@ -1,68 +0,0 @@
|
|||
#first-block
|
||||
.infos
|
||||
#dossier_id= t('dynamics.dossiers.numéro') + @facade.dossier.id.to_s
|
||||
|
||||
- if current_gestionnaire && current_gestionnaire.assigned_on_procedure?(@facade.dossier.procedure_id)
|
||||
#action-block
|
||||
- if !@facade.dossier.read_only? || @facade.dossier.en_construction?
|
||||
= link_to 'Passer en instruction', backoffice_dossier_receive_path(@facade.dossier), method: :post, class: 'btn btn-danger btn-block', data: { confirm: "Confirmer vous le passage en instruction de ce dossier ?" }
|
||||
|
||||
- elsif @facade.dossier.en_instruction?
|
||||
= form_tag(backoffice_dossier_process_dossier_url(@facade.dossier.id), method: :post) do
|
||||
= text_area :dossier, :motivation, class: "motivation-text-area", placeholder: "Motivation (facultative)"
|
||||
|
||||
%ul.list-inline
|
||||
%li
|
||||
= button_tag name: :process_action, value: "close", class: 'btn btn-success', title: 'Accepter', data: { toggle: :tooltip, confirm: "Accepter ce dossier ?" } do
|
||||
%i.fa.fa-check
|
||||
|
||||
%li
|
||||
= button_tag name: :process_action, value: "without_continuation", class: 'btn btn-warning', title: 'Classer sans suite', data: { toggle: :tooltip, confirm: "Classer sans suite ce dossier ?" } do
|
||||
%i.fa.fa-circle-o
|
||||
|
||||
%li
|
||||
= button_tag name: :process_action, value: "refuse", class: 'btn btn-danger', title: 'Refuser', data: { toggle: :tooltip, confirm: "Refuser ce dossier ?" } do
|
||||
%i.fa.fa-times
|
||||
|
||||
%hr
|
||||
= link_to 'Reouvrir', backoffice_dossier_reopen_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block', data: { confirm: "Confirmer vous la réouverture de ce dossier ?" }
|
||||
|
||||
%hr
|
||||
- if @facade.dossier.archived?
|
||||
%p
|
||||
Archivé
|
||||
= link_to 'Désarchiver', unarchive_backoffice_dossier_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block'
|
||||
|
||||
- else
|
||||
= link_to 'Archiver', archive_backoffice_dossier_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block', data: { confirm: "Confirmer vous l'archivage de ce dossier ?" }
|
||||
|
||||
|
||||
|
||||
#menu-block
|
||||
|
||||
#infos-block
|
||||
.split-hr-left
|
||||
.dossier-state= @facade.dossier.display_state
|
||||
.split-hr-left
|
||||
.notifications
|
||||
- if @facade.dossier.notifications.empty?
|
||||
Aucune notification pour le moment.
|
||||
- else
|
||||
%i.fa.fa-bell-o
|
||||
- @facade.last_notifications.each do |notification|
|
||||
.notification
|
||||
.updated-at= notification.updated_at.localtime.strftime('%d/%m/%Y %H:%M')
|
||||
= render partial: "layouts/left_panels/type_notif_fa", locals: { notification: notification }
|
||||
- if ['champs'].include?(notification.type_notif)
|
||||
- if notification.liste.size > 1
|
||||
.type= "Plusieurs attributs ont été changés, dont: #{notification.liste.join(" ")}"
|
||||
- else
|
||||
.type= "Un attribut a été changé: #{notification.liste.last}"
|
||||
- elsif ['piece_justificative'].include?(notification.type_notif)
|
||||
- if notification.liste.size > 1
|
||||
.type= "Plusieurs pièces jointes ont été changées, dont: #{notification.liste.join(" ")}"
|
||||
- else
|
||||
.type= "Une pièce jointe a été changée: #{notification.liste.last}"
|
||||
- else
|
||||
.type= notification.liste.last
|
||||
.split-hr
|
|
@ -1 +0,0 @@
|
|||
= render partial: 'layouts/left_panels/left_panel_backoffice_dossierscontroller_index'
|
|
@ -1,10 +0,0 @@
|
|||
- if gestionnaire_signed_in?
|
||||
= link_to 'nouvelle interface', procedures_path, class: 'new-design-button'
|
||||
|
||||
#search-area
|
||||
= form_tag(backoffice_dossiers_search_url, method: :get) do
|
||||
.input-group
|
||||
= text_field_tag('q', "#{@search_terms if @search_terms.present?}", id: 'q', placeholder: "Recherchez parmi tous vos dossiers", class: 'form-control')
|
||||
%span.input-group-btn
|
||||
%button.btn.btn-default#search-button
|
||||
%i.fa.fa-search
|
|
@ -1,12 +0,0 @@
|
|||
.col-xs-7.main-info
|
||||
= @facade_data_view.procedure_id.nil? ? "Tous les dossiers" : @facade_data_view.procedure.libelle
|
||||
.col-lg-3.col-md-3.col-sm-3.col-xs-3.options
|
||||
.row
|
||||
.col-lg-12.col-md-12.col-sm-12.col-xs-12
|
||||
%a.button-navbar#pref-list-dossier-open-action{ href: '#', type: :button, 'data-toggle' => 'dropdown', 'aria-haspopup' => true, 'aria-expanded' => false }
|
||||
%i.fa.fa-pencil
|
||||
Modifier le tableau
|
||||
%span.caret-right
|
||||
.row
|
||||
.col-lg-12.col-md-12.col-sm-12.col-xs-12
|
||||
= render partial: "dossiers/download_dossiers"
|
|
@ -1,2 +0,0 @@
|
|||
.col-xs-10.main-info
|
||||
Recherche dans tous les dossiers
|
|
@ -1,43 +0,0 @@
|
|||
.col-xs-7.main-info
|
||||
= @facade.dossier.procedure.libelle
|
||||
.col-xs-3.options
|
||||
- if current_gestionnaire.assigned_on_procedure?(@facade.dossier.procedure_id)
|
||||
.row
|
||||
.col-xs-12
|
||||
- if current_gestionnaire.follow?(@facade.dossier)
|
||||
= link_to unfollow_dossier_path(@facade.dossier.procedure, @facade.dossier), method: :patch, class: "button-navbar-action", id: "suivre_dossier_#{@facade.dossier.id}" do
|
||||
%i.fa.fa-user-times
|
||||
Ne plus suivre
|
||||
- else
|
||||
= link_to follow_dossier_path(@facade.dossier.procedure, @facade.dossier), method: :patch, class: 'button-navbar-action', id: "suivre_dossier_#{@facade.dossier.id}" do
|
||||
%i.fa.fa-user-plus
|
||||
Suivre le dossier
|
||||
.row
|
||||
.col-xs-12
|
||||
#invitations.dropdown-toggle{ 'data-toggle' => 'dropdown', 'aria-haspopup' => true, 'aria-expanded' => false }
|
||||
%i.fa.fa-user
|
||||
= t('utils.involved')
|
||||
.badge.progress-bar-info
|
||||
= @facade.dossier.invites.count
|
||||
.dropdown-menu.dropdown-menu-right.dropdown-pannel
|
||||
%h4= t('dynamics.dossiers.followers.title')
|
||||
%ul
|
||||
- if @facade.followers.present?
|
||||
- @facade.followers.each do |follower|
|
||||
%li= follower.email
|
||||
- else
|
||||
= t('dynamics.dossiers.followers.empty')
|
||||
%h4= t('dynamics.dossiers.invites.title')
|
||||
%p
|
||||
%b Attention, les invitations sur les dossiers vont disparaître en faveur des avis externes situés en bas de la page
|
||||
%ul
|
||||
- if @facade.invites.present?
|
||||
- @facade.invites.each do |invite|
|
||||
%li= invite.email
|
||||
- else
|
||||
= t('dynamics.dossiers.invites.empty')
|
||||
|
||||
%li
|
||||
= form_tag invites_dossier_path(dossier_id: @facade.dossier.id), method: :post, class: 'form-inline', id: 'send-invitation' do
|
||||
= text_field_tag :email, '', class: 'form-control', placeholder: 'Envoyer une invitation', id: 'invitation-email'
|
||||
= submit_tag 'Ajouter', class: 'btn btn-success', data: { confirm: "Envoyer l'invitation ?" }
|
|
@ -1,2 +0,0 @@
|
|||
.col-xs-10.main-info
|
||||
INVITATIONS
|
|
@ -5,22 +5,6 @@ fr:
|
|||
users:
|
||||
connexion_title: Connexion
|
||||
mes_dossiers: 'Mes dossiers'
|
||||
|
||||
backoffice:
|
||||
title: Gestion des dossiers
|
||||
dossiers: Dossiers
|
||||
pref_list:
|
||||
title: 'Gestion de colonnes affichées'
|
||||
description: 'Ce menu vous permet de choisir les différentes colonnes que vous souhaitez voir apparaître dans votre interface de suivi des dossiers.'
|
||||
format_csv: 'Au format CSV'
|
||||
format_xlsx: 'Au format XLSX'
|
||||
format_ods: 'Au format ODS'
|
||||
research:
|
||||
placeholder: 'Rechercher un dossier ...'
|
||||
filter_procedure:
|
||||
title: "Voir qu'une procédure :"
|
||||
first: ''
|
||||
|
||||
dossiers:
|
||||
depositaite: "Dépositaire"
|
||||
numéro: 'Dossier nº '
|
||||
|
@ -31,7 +15,6 @@ fr:
|
|||
title: "Personnes invitées à voir ce dossier"
|
||||
empty: "Aucune personne invitée"
|
||||
liste_champs: "Champs du dossier"
|
||||
|
||||
admin:
|
||||
connexion_title: Administration
|
||||
dossiers:
|
||||
|
|
|
@ -51,7 +51,6 @@ Rails.application.routes.draw do
|
|||
|
||||
get 'users' => 'users#index'
|
||||
get 'admin' => 'admin#index'
|
||||
get 'backoffice' => 'backoffice#index'
|
||||
|
||||
get 'administrations/sign_in' => 'administrations/sessions#new'
|
||||
delete 'administrations/sign_out' => 'administrations/sessions#destroy'
|
||||
|
@ -187,45 +186,6 @@ Rails.application.routes.draw do
|
|||
post 'dossier/:dossier_id' => '/invites#create', as: 'dossier'
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
get 'invitations'
|
||||
|
||||
resources :dossiers do
|
||||
post 'receive' => 'dossiers#receive'
|
||||
post 'process_dossier' => 'dossiers#process_dossier'
|
||||
member do
|
||||
post 'archive'
|
||||
post 'unarchive'
|
||||
end
|
||||
post 'reopen' => 'dossiers#reopen'
|
||||
resources :commentaires, only: [:index]
|
||||
resources :avis, only: [:create, :update]
|
||||
end
|
||||
|
||||
namespace :dossiers do
|
||||
post 'filter'
|
||||
|
||||
get 'procedure/:id' => 'procedure#index', as: 'procedure'
|
||||
post 'procedure/:id/filter' => 'procedure#filter', as: 'procedure_filter'
|
||||
end
|
||||
|
||||
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
|
||||
resources :procedures, only: [:index, :show] do
|
||||
|
@ -299,4 +259,9 @@ Rails.application.routes.draw do
|
|||
end
|
||||
|
||||
apipie
|
||||
|
||||
# Legacy routes
|
||||
get 'backoffice' => redirect('/procedures')
|
||||
get 'backoffice/sign_in' => redirect('/users/sign_in')
|
||||
get 'backoffice/dossiers/procedure/:id' => redirect('/procedures/:id')
|
||||
end
|
||||
|
|
|
@ -25,10 +25,6 @@ describe Admin::AccompagnateursController, type: :controller do
|
|||
end
|
||||
|
||||
it { expect(flash[:notice]).to be_present }
|
||||
|
||||
it 'default pref list dossier procedure columns are created' do
|
||||
expect(procedure.preference_list_dossiers.size).to eq gestionnaire.preference_list_dossiers.where('procedure_id IS NULL').size
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Backoffice::AvisController, type: :controller do
|
||||
describe '#POST create' do
|
||||
let(:claimant){ create(:gestionnaire) }
|
||||
let(:gestionnaire){ create(:gestionnaire) }
|
||||
let!(:dossier) do
|
||||
dossier = create(:dossier, state: 'en_instruction')
|
||||
claimant.procedures << [dossier.procedure]
|
||||
dossier
|
||||
end
|
||||
|
||||
subject do
|
||||
post :create, params: { dossier_id: dossier.id, avis: { email: gestionnaire.email, introduction: "Bonjour, regardez ce joli dossier." } }
|
||||
end
|
||||
|
||||
context 'when gestionnaire is not authenticated' do
|
||||
before { subject }
|
||||
|
||||
it { expect(response).to redirect_to new_user_session_path }
|
||||
it { expect(Avis.count).to eq(0) }
|
||||
end
|
||||
|
||||
context 'when gestionnaire is authenticated' do
|
||||
let(:created_avis) { Avis.last }
|
||||
|
||||
before do
|
||||
sign_in claimant
|
||||
subject
|
||||
end
|
||||
|
||||
it { expect(response).to redirect_to backoffice_dossier_path(dossier.id) }
|
||||
it { expect(Avis.count).to eq(1) }
|
||||
it { expect(created_avis.dossier_id).to eq(dossier.id) }
|
||||
it { expect(created_avis.gestionnaire).to eq(gestionnaire) }
|
||||
it { expect(created_avis.claimant).to eq(claimant) }
|
||||
it { expect(created_avis.confidentiel).to be(true) }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#POST update' do
|
||||
let(:gestionnaire){ create(:gestionnaire) }
|
||||
let(:dossier){ create(:dossier, state: 'en_instruction') }
|
||||
let(:avis){ create(:avis, dossier: dossier, gestionnaire: gestionnaire )}
|
||||
|
||||
subject { post :update, params: { dossier_id: dossier.id, id: avis.id, avis: { answer: "Ok ce dossier est valide." } } }
|
||||
|
||||
before :each do
|
||||
notification = double('notification', notify: true)
|
||||
allow(NotificationService).to receive(:new).and_return(notification)
|
||||
end
|
||||
|
||||
context 'when gestionnaire is not authenticated' do
|
||||
it { is_expected.to redirect_to new_user_session_path }
|
||||
it { expect(avis.answer).to be_nil }
|
||||
end
|
||||
|
||||
context 'when gestionnaire is authenticated' do
|
||||
before do
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
context 'and is invited on dossier' do
|
||||
it { is_expected.to redirect_to backoffice_dossier_path(dossier.id) }
|
||||
it do
|
||||
subject
|
||||
expect(avis.reload.answer).to eq("Ok ce dossier est valide.")
|
||||
expect(NotificationService).to have_received(:new).at_least(:once)
|
||||
end
|
||||
end
|
||||
|
||||
context 'but is not invited on dossier' do
|
||||
let(:gestionnaire2) { create(:gestionnaire) }
|
||||
let(:avis){ create(:avis, dossier: dossier, gestionnaire: gestionnaire2 )}
|
||||
|
||||
it { expect{ subject }.to raise_error(ActiveRecord::RecordNotFound) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,124 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Backoffice::CommentairesController, type: :controller do
|
||||
let(:dossier) { create(:dossier, :en_construction) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:email_commentaire) { 'test@test.com' }
|
||||
let(:texte_commentaire) { 'Commentaire de test' }
|
||||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
|
||||
before do
|
||||
allow(ClamavService).to receive(:safe_file?).and_return(true)
|
||||
end
|
||||
|
||||
describe '#POST create' do
|
||||
before do
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
context "when gestionnaire has no access to dossier" do
|
||||
subject { post :create, params: { dossier_id: dossier_id, texte_commentaire: texte_commentaire } }
|
||||
|
||||
it { expect { subject }.to raise_error(ActiveRecord::RecordNotFound) }
|
||||
it { expect { subject rescue nil }.to change(Commentaire, :count).by(0) }
|
||||
end
|
||||
|
||||
context "when gestionnaire is invited for avis on dossier" do
|
||||
subject { post :create, params: { dossier_id: dossier_id, texte_commentaire: texte_commentaire } }
|
||||
before { Avis.create(dossier: dossier, gestionnaire: gestionnaire, claimant: create(:gestionnaire)) }
|
||||
|
||||
it { expect{ subject }.to change(Commentaire, :count).by(1) }
|
||||
end
|
||||
|
||||
context "when gestionnaire has access to dossier" do
|
||||
before do
|
||||
gestionnaire.procedures << dossier.procedure
|
||||
end
|
||||
|
||||
context "création correct d'un commentaire" do
|
||||
subject { post :create, params: {dossier_id: dossier_id, email_commentaire: email_commentaire, texte_commentaire: texte_commentaire} }
|
||||
|
||||
it 'depuis la page admin' do
|
||||
expect(subject).to redirect_to("/backoffice/dossiers/#{dossier_id}")
|
||||
end
|
||||
|
||||
it 'gestionnaire is automatically affect to follow the dossier' do
|
||||
expect { subject }.to change(Follow, :count).by(1)
|
||||
end
|
||||
|
||||
context 'when gestionnaire already follow dossier' do
|
||||
before do
|
||||
create :follow, gestionnaire_id: gestionnaire.id, dossier_id: dossier_id
|
||||
end
|
||||
|
||||
it 'gestionnaire is automatically affect to follow the dossier' do
|
||||
expect { subject }.to change(Follow, :count).by(0)
|
||||
end
|
||||
end
|
||||
|
||||
it 'Internal notification is not create' do
|
||||
expect { subject }.to change(Notification, :count).by (0)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when document is upload whith a commentaire', vcr: {cassette_name: 'controllers_backoffice_commentaires_controller_doc_upload_with_comment'} do
|
||||
let(:document_upload) { Rack::Test::UploadedFile.new("./spec/support/files/piece_justificative_0.pdf", 'application/pdf') }
|
||||
|
||||
subject do
|
||||
post :create, params: { dossier_id: dossier_id, email_commentaire: email_commentaire, texte_commentaire: texte_commentaire, file: document_upload }
|
||||
end
|
||||
|
||||
it 'clamav check the pj' do
|
||||
expect(ClamavService).to receive(:safe_file?)
|
||||
subject
|
||||
end
|
||||
|
||||
describe 'commentaire created' do
|
||||
let(:commentaire) { Commentaire.last }
|
||||
|
||||
before do
|
||||
subject
|
||||
end
|
||||
|
||||
it 'have a piece justificative reference' do
|
||||
expect(commentaire.file.present?).to eq true
|
||||
expect(commentaire.file.class).to eq(CommentaireFileUploader)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'change dossier state after post a comment' do
|
||||
context 'gestionnaire is connected' do
|
||||
context 'when dossier is at state en_construction' do
|
||||
before do
|
||||
sign_in gestionnaire
|
||||
dossier.en_construction!
|
||||
|
||||
post :create, params: {dossier_id: dossier_id, texte_commentaire: texte_commentaire}
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it 'Notification email is send' do
|
||||
expect(NotificationMailer).to receive(:new_answer).and_return(NotificationMailer)
|
||||
expect(NotificationMailer).to receive(:deliver_now!)
|
||||
|
||||
post :create, params: {dossier_id: dossier_id, texte_commentaire: texte_commentaire}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'comment cannot be saved' do
|
||||
before do
|
||||
allow_any_instance_of(Commentaire).to receive(:save).and_return(false)
|
||||
end
|
||||
it 'Notification email is not sent' do
|
||||
expect(NotificationMailer).not_to receive(:new_answer)
|
||||
expect(NotificationMailer).not_to receive(:deliver_now!)
|
||||
|
||||
post :create, params: {dossier_id: dossier_id, texte_commentaire: texte_commentaire}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,58 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Backoffice::Dossiers::ProcedureController, type: :controller do
|
||||
let(:gestionnaire) { create :gestionnaire }
|
||||
let(:procedure) { create :procedure, :published }
|
||||
let(:archived) { false }
|
||||
let(:dossier) { create :dossier, procedure: procedure, archived: archived, state: 'en_construction'}
|
||||
|
||||
before do
|
||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
||||
sign_in gestionnaire
|
||||
gestionnaire.build_default_preferences_list_dossier procedure.id
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
let(:procedure_id) { procedure.id }
|
||||
|
||||
subject { get :index, params: {id: procedure_id} }
|
||||
|
||||
it { expect(subject.status).to eq 200 }
|
||||
|
||||
context 'when procedure id is not found' do
|
||||
let(:procedure_id) { 100000 }
|
||||
|
||||
before do
|
||||
subject
|
||||
end
|
||||
|
||||
it { expect(response.status).to eq 302 }
|
||||
it { is_expected.to redirect_to backoffice_dossiers_path }
|
||||
it { expect(flash[:alert]).to be_present}
|
||||
end
|
||||
|
||||
context 'when procedure contains a dossier' do
|
||||
render_views
|
||||
|
||||
before do
|
||||
dossier
|
||||
subject
|
||||
end
|
||||
|
||||
it { expect(response.body).to have_content('Tous les dossiers 1 dossier') }
|
||||
|
||||
context 'archived' do
|
||||
let(:archived) { true }
|
||||
|
||||
it { expect(response.body).to have_content('Tous les dossiers 0 dossiers') }
|
||||
it { expect(response.body).to have_content('Dossiers archivés 1 dossier') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #filter' do
|
||||
subject { get :filter, params: {id: procedure.id, filter_input: {"entreprise.raison_sociale" => "plop"}} }
|
||||
|
||||
it { is_expected.to redirect_to backoffice_dossiers_procedure_path(id: procedure.id) }
|
||||
end
|
||||
end
|
|
@ -1,410 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Backoffice::DossiersController, type: :controller do
|
||||
before do
|
||||
@request.env['HTTP_REFERER'] = TPS::Application::URL
|
||||
end
|
||||
let(:procedure) { create :procedure, :published }
|
||||
let(:procedure2) { create :procedure, :published }
|
||||
|
||||
let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: :en_construction) }
|
||||
let(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure2, state: :en_construction) }
|
||||
let(:dossier_archived) { create(:dossier, :with_entreprise, archived: true) }
|
||||
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:dossier2_id) { dossier2.id }
|
||||
let(:bad_dossier_id) { Dossier.count + 10 }
|
||||
|
||||
let(:gestionnaire) { create(:gestionnaire, administrateurs: [create(:administrateur)]) }
|
||||
let!(:gestionnaire2) { create(:gestionnaire, administrateurs: [create(:administrateur)]) }
|
||||
|
||||
before do
|
||||
create :assign_to, procedure: procedure, gestionnaire: gestionnaire
|
||||
create :assign_to, procedure: procedure2, gestionnaire: gestionnaire2
|
||||
|
||||
procedure.dossiers << dossier
|
||||
procedure2.dossiers << dossier2
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
subject { get :index }
|
||||
|
||||
before do
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
context 'when gestionnaire is assign to a procedure' do
|
||||
it { is_expected.to redirect_to backoffice_dossiers_procedure_path(id: procedure.id) }
|
||||
|
||||
context 'when gestionnaire is assign to many proceudure' do
|
||||
before do
|
||||
create :assign_to, procedure: create(:procedure, :published), gestionnaire: gestionnaire
|
||||
create :assign_to, procedure: create(:procedure, :published), gestionnaire: gestionnaire
|
||||
end
|
||||
|
||||
it { expect(gestionnaire.procedures.count).to eq 3 }
|
||||
|
||||
context 'when gestionnaire procedure_filter is nil' do
|
||||
it { expect(gestionnaire.procedure_filter).to be_nil }
|
||||
it { is_expected.to redirect_to backoffice_dossiers_procedure_path(id: gestionnaire.procedures.order('libelle ASC').first.id) }
|
||||
end
|
||||
|
||||
context 'when gestionnaire procedure_filter is not nil' do
|
||||
let(:procedure_filter_id) { gestionnaire.procedures.order('libelle ASC').last.id }
|
||||
|
||||
before do
|
||||
gestionnaire.update_column :procedure_filter, procedure_filter_id
|
||||
end
|
||||
|
||||
context 'when gestionnaire is assign_to the procedure filter id' do
|
||||
it { is_expected.to redirect_to backoffice_dossiers_procedure_path(id: procedure_filter_id) }
|
||||
end
|
||||
|
||||
context 'when gestionnaire not any more assign_to the procedure filter id' do
|
||||
before do
|
||||
AssignTo.where(procedure: procedure_filter_id, gestionnaire: gestionnaire).delete_all
|
||||
end
|
||||
|
||||
it { expect(gestionnaire.procedure_filter).to be_nil }
|
||||
it { expect(AssignTo.where(procedure: procedure_filter_id, gestionnaire: gestionnaire).count).to eq 0 }
|
||||
|
||||
it { is_expected.to redirect_to backoffice_dossiers_procedure_path(id: gestionnaire.procedures.order('libelle ASC').first.id) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when gestionnaire is not assign to a procedure' do
|
||||
before do
|
||||
AssignTo.where(procedure: procedure, gestionnaire: gestionnaire).delete_all
|
||||
end
|
||||
|
||||
it { is_expected.to redirect_to root_path }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
subject { get :show, params: {id: dossier_id} }
|
||||
|
||||
context 'gestionnaire is connected' do
|
||||
before do
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
expect(subject).to have_http_status(200)
|
||||
end
|
||||
|
||||
describe 'all notifications unread are changed' do
|
||||
it do
|
||||
expect(Notification).to receive(:where).with(dossier_id: dossier_id.to_s).and_return(Notification::ActiveRecord_Relation)
|
||||
expect(Notification::ActiveRecord_Relation).to receive(:update_all).with(already_read: true).and_return(true)
|
||||
|
||||
subject
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier id does not exist' do
|
||||
let(:dossier_id) { bad_dossier_id }
|
||||
|
||||
it { expect(subject).to redirect_to('/backoffice') }
|
||||
end
|
||||
|
||||
describe 'he can invite somebody for avis' do
|
||||
render_views
|
||||
|
||||
it { expect(subject.body).to include("Invitez une personne externe à consulter le dossier et à vous donner un avis sur celui ci.") }
|
||||
end
|
||||
|
||||
context 'and is invited on a dossier' do
|
||||
let(:dossier_invited){ create(:dossier, procedure: create(:procedure)) }
|
||||
let!(:avis){ create(:avis, dossier: dossier_invited, gestionnaire: gestionnaire) }
|
||||
|
||||
subject { get :show, params: { id: dossier_invited.id } }
|
||||
|
||||
render_views
|
||||
|
||||
it { expect(subject.status).to eq(200) }
|
||||
it { expect(subject.body).to include("Votre avis est sollicité sur le dossier") }
|
||||
it { expect(subject.body).to_not include("Invitez une personne externe à consulter le dossier et à vous donner un avis sur celui ci.") }
|
||||
|
||||
describe 'the notifications are not marked as read' do
|
||||
it do
|
||||
expect(Notification).not_to receive(:where)
|
||||
subject
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'gestionnaire does not connected but dossier id is correct' do
|
||||
it { is_expected.to redirect_to('/users/sign_in') }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #a_traiter' do
|
||||
context 'when gestionnaire is connected' do
|
||||
before do
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
get :index, params: {liste: :a_traiter}
|
||||
expect(response).to have_http_status(302)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #termine' do
|
||||
context 'when gestionnaire is connected' do
|
||||
before do
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
get :index, params: {liste: :termine}
|
||||
expect(response).to have_http_status(302)
|
||||
end
|
||||
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, params: {liste: :list_fake}
|
||||
expect(response).to redirect_to(backoffice_dossiers_procedure_path(id: gestionnaire.procedures.first.id))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #search' do
|
||||
describe 'by id' do
|
||||
context 'when I am logged as a gestionnaire' do
|
||||
before do
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
context 'when I own the dossier' do
|
||||
before :each do
|
||||
post :search, params: { q: dossier_id }
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'returns the expected dossier' do
|
||||
expect(assigns(:dossiers).count).to eq(1)
|
||||
expect(assigns(:dossiers).first.id).to eq(dossier_id)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when I do not own the dossier' do
|
||||
before :each do
|
||||
post :search, params: { q: dossier2_id }
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'does not return the dossier' do
|
||||
expect(assigns(:dossiers).pluck(:id)).not_to include(dossier2_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #receive' do
|
||||
before do
|
||||
dossier.en_construction!
|
||||
sign_in gestionnaire
|
||||
post :receive, params: { dossier_id: dossier_id }
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.state).to eq('en_instruction') }
|
||||
it { is_expected.to redirect_to backoffice_dossier_path(dossier) }
|
||||
it { expect(gestionnaire.follow?(dossier)).to be true }
|
||||
end
|
||||
|
||||
describe 'POST #process_dossier' do
|
||||
context "with refuse" do
|
||||
before do
|
||||
dossier.en_instruction!
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
subject { post :process_dossier, params: { process_action: "refuse", dossier_id: dossier_id} }
|
||||
|
||||
it 'change state to refuse' do
|
||||
subject
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('refuse')
|
||||
end
|
||||
|
||||
it 'Notification email is sent' do
|
||||
expect(NotificationMailer).to receive(:send_notification)
|
||||
.with(dossier, kind_of(Mails::RefusedMail), nil).and_return(NotificationMailer)
|
||||
expect(NotificationMailer).to receive(:deliver_now!)
|
||||
|
||||
subject
|
||||
end
|
||||
|
||||
it { is_expected.to redirect_to backoffice_dossier_path(id: dossier.id) }
|
||||
end
|
||||
|
||||
context "with sans_suite" do
|
||||
before do
|
||||
dossier.en_instruction!
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
subject { post :process_dossier, params: { process_action: "without_continuation", dossier_id: dossier_id} }
|
||||
|
||||
it 'change state to sans_suite' do
|
||||
subject
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('sans_suite')
|
||||
end
|
||||
|
||||
it 'Notification email is sent' do
|
||||
expect(NotificationMailer).to receive(:send_notification)
|
||||
.with(dossier, kind_of(Mails::WithoutContinuationMail), nil).and_return(NotificationMailer)
|
||||
expect(NotificationMailer).to receive(:deliver_now!)
|
||||
|
||||
subject
|
||||
end
|
||||
|
||||
it { is_expected.to redirect_to backoffice_dossier_path(id: dossier.id) }
|
||||
end
|
||||
|
||||
context "with close" do
|
||||
let(:expected_attestation) { nil }
|
||||
|
||||
before do
|
||||
dossier.en_instruction!
|
||||
sign_in gestionnaire
|
||||
|
||||
expect(NotificationMailer).to receive(:send_notification)
|
||||
.with(dossier, kind_of(Mails::ClosedMail), expected_attestation)
|
||||
.and_return(NotificationMailer)
|
||||
|
||||
expect(NotificationMailer).to receive(:deliver_now!)
|
||||
end
|
||||
|
||||
subject { post :process_dossier, params: { process_action: "close", dossier_id: dossier_id} }
|
||||
|
||||
it 'change state to accepte' do
|
||||
subject
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('accepte')
|
||||
end
|
||||
|
||||
context 'when the dossier does not have any attestation' do
|
||||
it 'Notification email is sent' do
|
||||
subject
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the dossier has an attestation' do
|
||||
before do
|
||||
attestation = Attestation.new
|
||||
allow(attestation).to receive(:pdf).and_return(double(read: 'pdf', size: 2.megabytes))
|
||||
allow(attestation).to receive(:emailable?).and_return(emailable)
|
||||
|
||||
expect_any_instance_of(Dossier).to receive(:reload)
|
||||
allow_any_instance_of(Dossier).to receive(:build_attestation).and_return(attestation)
|
||||
end
|
||||
|
||||
context 'emailable' do
|
||||
let(:emailable) { true }
|
||||
let(:expected_attestation) { 'pdf' }
|
||||
|
||||
it 'Notification email is sent with the attestation' do
|
||||
subject
|
||||
|
||||
is_expected.to redirect_to backoffice_dossier_path(id: dossier.id)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the dossier has an attestation not emailable' do
|
||||
let(:emailable) { false }
|
||||
let(:expected_attestation) { nil }
|
||||
|
||||
it 'Notification email is sent without the attestation' do
|
||||
expect(controller).to receive(:capture_message)
|
||||
|
||||
subject
|
||||
|
||||
is_expected.to redirect_to backoffice_dossier_path(id: dossier.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the attestation template uses the motivation field' do
|
||||
let(:emailable) { false }
|
||||
let(:template) { create(:attestation_template) }
|
||||
let(:procedure) { create(:procedure, :published, attestation_template: template, gestionnaires: [gestionnaire]) }
|
||||
|
||||
subject { post :process_dossier, params: { process_action: "close", dossier_id: dossier_id, dossier: { motivation: "Yallah" }}}
|
||||
|
||||
before do
|
||||
Timecop.freeze(DateTime.now)
|
||||
|
||||
expect_any_instance_of(AttestationTemplate)
|
||||
.to receive(:attestation_for)
|
||||
.with(have_attributes(motivation: "Yallah", processed_at: DateTime.now))
|
||||
end
|
||||
|
||||
after { Timecop.return }
|
||||
|
||||
it { subject }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #reopen' do
|
||||
before do
|
||||
dossier.en_instruction!
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
subject { post :reopen, params: {dossier_id: dossier_id} }
|
||||
|
||||
it 'change state to en_construction' do
|
||||
subject
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('en_construction')
|
||||
end
|
||||
|
||||
it { is_expected.to redirect_to backoffice_dossier_path(id: dossier_id) }
|
||||
end
|
||||
|
||||
describe 'POST #archive' do
|
||||
before do
|
||||
dossier.update(archived: false)
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
subject { post :archive, params: {id: dossier_id} }
|
||||
|
||||
it 'change state to archived' do
|
||||
subject
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.archived).to eq(true)
|
||||
end
|
||||
|
||||
it { is_expected.to redirect_to backoffice_dossiers_path }
|
||||
end
|
||||
end
|
|
@ -1,56 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Backoffice::PreferenceListDossierController, type: :controller do
|
||||
let(:gestionnaire) { create :gestionnaire }
|
||||
let(:libelle) { 'Plop' }
|
||||
let(:table) { 'plip' }
|
||||
let(:attr) { 'plap' }
|
||||
let(:attr_decorate) { 'plup' }
|
||||
let(:bootstrap_lg) { 'plyp' }
|
||||
|
||||
before do
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
describe '#POST add' do
|
||||
subject { post :add,
|
||||
params: {
|
||||
libelle: libelle,
|
||||
table: table,
|
||||
attr: attr,
|
||||
attr_decorate: attr_decorate,
|
||||
bootstrap_lg: bootstrap_lg
|
||||
}
|
||||
}
|
||||
|
||||
it { expect(subject.status).to eq 200 }
|
||||
it { expect { subject }.to change(PreferenceListDossier, :count).by(1) }
|
||||
|
||||
describe 'attributs' do
|
||||
let(:last) { PreferenceListDossier.last }
|
||||
|
||||
before do
|
||||
subject
|
||||
end
|
||||
|
||||
it { expect(last.libelle).to eq libelle }
|
||||
it { expect(last.table).to eq table }
|
||||
it { expect(last.attr).to eq attr }
|
||||
it { expect(last.attr_decorate).to eq attr_decorate }
|
||||
it { expect(last.bootstrap_lg).to eq bootstrap_lg }
|
||||
it { expect(last.order).to be_nil }
|
||||
it { expect(last.filter).to be_nil }
|
||||
it { expect(last.procedure_id).to be_nil }
|
||||
it { expect(last.gestionnaire).to eq gestionnaire }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#DELETE delete' do
|
||||
let!(:pref) { create :preference_list_dossier }
|
||||
|
||||
subject { delete :delete, params: {pref_id: pref.id} }
|
||||
|
||||
it { expect(subject.status).to eq 200 }
|
||||
it { expect { subject }.to change(PreferenceListDossier, :count).by(-1) }
|
||||
end
|
||||
end
|
|
@ -1,32 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Backoffice::PrivateFormulairesController, type: :controller do
|
||||
let(:gestionnaire) { create :gestionnaire }
|
||||
let(:dossier) { create :dossier, state: :en_construction }
|
||||
let(:dossier_champs_first) { 'plop' }
|
||||
|
||||
before do
|
||||
create :assign_to, procedure_id: dossier.procedure.id, gestionnaire_id: gestionnaire.id
|
||||
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
describe '#PATCH update' do
|
||||
subject { patch :update,
|
||||
params: {
|
||||
dossier_id: dossier.id,
|
||||
champs: {
|
||||
"'#{dossier.champs_private.first.id}'" => dossier_champs_first
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
before do
|
||||
subject
|
||||
end
|
||||
|
||||
it { expect(response.status).to eq 200 }
|
||||
it { expect(Dossier.find(dossier.id).champs_private.first.value).to eq dossier_champs_first }
|
||||
it { expect(flash[:notice]).to be_present }
|
||||
end
|
||||
end
|
|
@ -1,74 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe BackofficeController, type: :controller do
|
||||
describe 'GET #index' do
|
||||
context 'when gestionnaire is not connected' do
|
||||
before do
|
||||
get :index
|
||||
end
|
||||
|
||||
it { expect(response).to redirect_to :new_gestionnaire_session }
|
||||
end
|
||||
|
||||
context 'when gestionnaire is connected' do
|
||||
before do
|
||||
sign_in create(:gestionnaire)
|
||||
get :index
|
||||
end
|
||||
|
||||
it { expect(response).to redirect_to :backoffice_dossiers }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #invitations' do
|
||||
context 'when gestionnaire is not invited on any dossiers' do
|
||||
render_views
|
||||
|
||||
before do
|
||||
sign_in create(:gestionnaire)
|
||||
get :invitations
|
||||
end
|
||||
|
||||
it { expect(response.status).to eq(200) }
|
||||
it { expect(response.body).to include("INVITATIONS") }
|
||||
it { expect(response.body).to include("0 avis à rendre") }
|
||||
it { expect(response.body).to include("0 avis rendus") }
|
||||
end
|
||||
|
||||
context 'when gestionnaire is invited on a dossier' do
|
||||
let(:dossier){ create(:dossier) }
|
||||
let(:gestionnaire){ create(:gestionnaire) }
|
||||
let!(:avis){ create(:avis, dossier: dossier, gestionnaire: gestionnaire) }
|
||||
render_views
|
||||
|
||||
before do
|
||||
sign_in gestionnaire
|
||||
get :invitations
|
||||
end
|
||||
|
||||
it { expect(response.status).to eq(200) }
|
||||
it { expect(response.body).to include("1 avis à rendre") }
|
||||
it { expect(response.body).to include("0 avis rendus") }
|
||||
it { expect(response.body).to include(dossier.procedure.libelle) }
|
||||
|
||||
context 'when avis is already sent' do
|
||||
let!(:avis){ create(:avis, dossier: dossier, gestionnaire: gestionnaire, answer: "Voici mon avis.") }
|
||||
|
||||
it { expect(response.body).to include("0 avis à rendre") }
|
||||
it { expect(response.body).to include("1 avis rendu") }
|
||||
it { expect(response.body).to include(dossier.procedure.libelle) }
|
||||
end
|
||||
|
||||
context 'when dossier linked to avis is hidden' do
|
||||
before do
|
||||
dossier.update_attributes(hidden_at: Time.now)
|
||||
get :invitations
|
||||
end
|
||||
|
||||
it { expect(response.status).to eq(200) }
|
||||
it { expect(response.body).to include("0 avis à rendre") }
|
||||
it { expect(response.body).to include("0 avis rendu") }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -22,12 +22,6 @@ describe RootController, type: :controller do
|
|||
end
|
||||
|
||||
it { expect(subject).to redirect_to(procedures_path) }
|
||||
|
||||
context 'and coming with old_ui param' do
|
||||
subject { get :index, params: { old_ui: 1 } }
|
||||
|
||||
it { expect(subject).to redirect_to(backoffice_path) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when Administrateur is connected' do
|
||||
|
|
|
@ -54,12 +54,6 @@ describe DossierDecorator do
|
|||
end
|
||||
|
||||
describe '#url' do
|
||||
context "when a gestionnaire is signed_in" do
|
||||
subject { super().url(true) }
|
||||
|
||||
it { is_expected.to eq("/backoffice/dossiers/#{dossier.id}") }
|
||||
end
|
||||
|
||||
context "when a gestionnaire is not signed_in" do
|
||||
context "when the dossier is in brouillon state" do
|
||||
before do
|
||||
|
|
|
@ -1,131 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe DossiersListFacades do
|
||||
let(:gestionnaire) { create :gestionnaire }
|
||||
let(:procedure) { create :procedure, :published, libelle: 'Ma procédure' }
|
||||
let(:procedure_2) { create :procedure, :published, libelle: 'Ma seconde procédure' }
|
||||
|
||||
let!(:preference) { create :preference_list_dossier,
|
||||
gestionnaire: gestionnaire,
|
||||
table: nil,
|
||||
attr: 'state',
|
||||
attr_decorate: 'display_state'
|
||||
}
|
||||
|
||||
let!(:preference_2) { create :preference_list_dossier,
|
||||
gestionnaire: gestionnaire,
|
||||
table: 'champs',
|
||||
attr: 'state',
|
||||
attr_decorate: 'display_state',
|
||||
procedure_id: procedure.id
|
||||
}
|
||||
|
||||
before do
|
||||
create :assign_to, procedure: procedure, gestionnaire: gestionnaire
|
||||
create :assign_to, procedure: procedure_2, gestionnaire: gestionnaire
|
||||
end
|
||||
|
||||
describe '#preference_list_dossiers_filter' do
|
||||
subject { facade.preference_list_dossiers_filter }
|
||||
|
||||
context 'when procedure is not pasted at the facade' do
|
||||
let(:facade) { described_class.new gestionnaire, 'nouveaux' }
|
||||
|
||||
it { expect(subject.size).to eq 6 }
|
||||
end
|
||||
|
||||
context 'when procedure is pasted at the facade' do
|
||||
let(:facade) { described_class.new gestionnaire, 'nouveaux', procedure }
|
||||
|
||||
it { expect(subject.size).to eq 1 }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#gestionnaire_procedures_name_and_id_list' do
|
||||
let(:facade) { described_class.new gestionnaire, 'nouveaux' }
|
||||
|
||||
subject { facade.gestionnaire_procedures_name_and_id_list }
|
||||
|
||||
it { expect(subject.size).to eq 2 }
|
||||
|
||||
it { expect(subject.first).to eq({ id: procedure.id, libelle: procedure.libelle, unread_notifications: 0 }) }
|
||||
it { expect(subject.last).to eq({ id: procedure_2.id, libelle: procedure_2.libelle, unread_notifications: 0 }) }
|
||||
end
|
||||
|
||||
describe '#active_filter?' do
|
||||
let(:table) { nil }
|
||||
let(:filter) { nil }
|
||||
let(:facade) { described_class.new gestionnaire, 'nouveaux', procedure_2 }
|
||||
|
||||
let!(:preference) { create :preference_list_dossier,
|
||||
gestionnaire: gestionnaire,
|
||||
table: table,
|
||||
attr: 'state',
|
||||
attr_decorate: 'display_state',
|
||||
filter: filter,
|
||||
procedure_id: procedure_id
|
||||
}
|
||||
|
||||
subject { facade.active_filter? preference }
|
||||
|
||||
context 'when gestionnaire does not have select a procedure' do
|
||||
let(:procedure_2) { nil }
|
||||
let(:procedure_id) { nil }
|
||||
|
||||
it { expect(preference.procedure).to be_nil }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
context 'when gestionnaire have select a procedure' do
|
||||
let(:procedure_id) { procedure_2.id }
|
||||
|
||||
it { expect(preference.procedure).not_to be_nil }
|
||||
|
||||
context 'when preference is not a champs filter' do
|
||||
let(:table) { 'entreprises' }
|
||||
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
context 'when gestionnaire have an existant filter with a champ' do
|
||||
let(:table) { 'champs' }
|
||||
let(:filter) { 'plop' }
|
||||
|
||||
context 'when the preference is the existant champ filter' do
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
context 'when the preference is not the existant champ filter' do
|
||||
let(:preference) { preference_2 }
|
||||
|
||||
before do
|
||||
create :preference_list_dossier,
|
||||
gestionnaire: gestionnaire,
|
||||
table: 'champs',
|
||||
attr: 'state',
|
||||
attr_decorate: 'display_state',
|
||||
filter: 'plop',
|
||||
procedure_id: procedure_id
|
||||
end
|
||||
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when gestionnaire does not have an existant filter with a champ' do
|
||||
let(:table) { nil }
|
||||
let(:filter) { 'plop' }
|
||||
|
||||
context 'when the preference is the existant preference filter' do
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
context 'when the preference is not the existant preference filter' do
|
||||
let(:preference) { preference_2 }
|
||||
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
FactoryGirl.define do
|
||||
factory :preference_list_dossier do
|
||||
libelle 'Procedure'
|
||||
table 'procedure'
|
||||
attr 'libelle'
|
||||
attr_decorate 'libelle'
|
||||
order nil
|
||||
filter nil
|
||||
bootstrap_lg 1
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'add commentaire on backoffice' do
|
||||
let(:procedure) { create(:procedure, :published) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let!(:commentaire) { create(:commentaire, dossier: dossier, email: 'toto@toto.com') }
|
||||
let(:email_commentaire) { 'test@test.com' }
|
||||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
let(:email_pre_rempli) { 'toto@sgmap.fr' }
|
||||
let(:body) { 'Commentaire de test' }
|
||||
|
||||
before do
|
||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
||||
login_as gestionnaire, scope: :gestionnaire
|
||||
visit backoffice_dossier_path(dossier)
|
||||
end
|
||||
|
||||
context 'Affichage du formulaire de commentaire' do
|
||||
scenario 'Le formulaire envoie vers /dossiers/:dossier_id/commentaire en #POST' do
|
||||
expect(page).to have_selector("form[action='/backoffice/commentaires?dossier_id=#{dossier_id}'][method=post]")
|
||||
end
|
||||
|
||||
scenario 'Champs de texte' do
|
||||
expect(page).to have_selector('textarea[id=texte_commentaire][name=texte_commentaire]')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,36 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'when gestionnaire come to /backoffice and is not authenticated' do
|
||||
let(:procedure) { create(:procedure, :published) }
|
||||
let!(:dossier) { create(:dossier, procedure: procedure) }
|
||||
before do
|
||||
visit backoffice_path
|
||||
end
|
||||
scenario 'he is redirected to /gestionnaires/sign_id' do
|
||||
expect(page).to have_css('#user_email')
|
||||
end
|
||||
context 'when user enter bad credentials' do
|
||||
before do
|
||||
page.find_by_id(:user_email).set 'unknown@plop.com'
|
||||
page.find_by_id(:user_password).set 'password'
|
||||
page.click_on 'Se connecter'
|
||||
end
|
||||
scenario 'he stay on the same page with an error' do
|
||||
expect(page).to have_content('Mauvais couple login / mot de passe')
|
||||
end
|
||||
end
|
||||
context 'when user enter good credentials' do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
|
||||
|
||||
before do
|
||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
||||
page.find_by_id(:user_email).set gestionnaire.email
|
||||
page.find_by_id(:user_password).set gestionnaire.password
|
||||
page.click_on 'Se connecter'
|
||||
end
|
||||
scenario 'he is redirected to /procedures' do
|
||||
expect(current_path).to eq(procedures_path)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,27 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'backoffice: flux de commentaires' do
|
||||
let(:procedure) { create(:procedure, :published) }
|
||||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') }
|
||||
let(:dossier_id) { dossier.id }
|
||||
|
||||
let(:champ1) { create(:champ, dossier: dossier, type_de_champ: create(:type_de_champ_public, libelle: "subtitle1")) }
|
||||
let(:champ2) { create(:champ, dossier: dossier, type_de_champ: create(:type_de_champ_public, libelle: "subtitle2")) }
|
||||
|
||||
let!(:commentaire1) { create(:commentaire, dossier: dossier, champ: champ1) }
|
||||
let!(:commentaire2) { create(:commentaire, dossier: dossier) }
|
||||
let!(:commentaire3) { create(:commentaire, dossier: dossier, champ: champ2) }
|
||||
let!(:commentaire4) { create(:commentaire, dossier: dossier, champ: champ1) }
|
||||
|
||||
before do
|
||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
||||
login_as gestionnaire, scope: :gestionnaire
|
||||
visit backoffice_dossier_path(dossier)
|
||||
end
|
||||
|
||||
scenario "seuls les commentaires généraux sont affichés" do
|
||||
comments = find(".commentaires")
|
||||
expect(comments).to have_selector(".content", count: 1)
|
||||
end
|
||||
end
|
|
@ -1,101 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'As an Accompagnateur I can navigate and use each functionnality around procedures and their dossiers' do
|
||||
let(:user) { create(:user) }
|
||||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
let(:procedure_1) { create(:procedure, :published, :with_type_de_champ, libelle: 'procedure 1') }
|
||||
let(:procedure_2) { create(:procedure, :published, :with_type_de_champ, libelle: 'procedure 2') }
|
||||
|
||||
before 'Assign procedures to Accompagnateur and generating dossiers for each' do
|
||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_1
|
||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_2
|
||||
30.times do
|
||||
Dossier.create(procedure_id: procedure_1.id.to_s, user: user, state: 'en_construction')
|
||||
end
|
||||
22.times do
|
||||
Dossier.create(procedure_id: procedure_2.id.to_s, user: user, state: 'en_instruction')
|
||||
end
|
||||
login_as gestionnaire, scope: :gestionnaire
|
||||
visit backoffice_path
|
||||
end
|
||||
|
||||
context 'On index' do
|
||||
scenario 'Switching between procedures' do
|
||||
page.all('#procedure-list a').first.click
|
||||
expect(page).to have_current_path(backoffice_dossiers_procedure_path(id: procedure_1.id.to_s), only_path: true)
|
||||
expect(page.find('#all_dossiers .count').text).to eq('30 dossiers')
|
||||
page.all('#procedure-list a').last.click
|
||||
expect(page).to have_current_path(backoffice_dossiers_procedure_path(id: procedure_2.id.to_s), only_path: true)
|
||||
expect(page.find('#all_dossiers .count').text).to eq('22 dossiers')
|
||||
end
|
||||
|
||||
scenario 'Searching with search bar', js: true do
|
||||
page.find_by_id('search-area').trigger('click')
|
||||
fill_in 'q', with: (procedure_1.dossiers.first.id + 14)
|
||||
page.find_by_id('search-button').click
|
||||
page.find_by_id("tr_dossier_#{(procedure_1.dossiers.first.id + 14)}").click
|
||||
expect(page).to have_current_path("/backoffice/dossiers/#{(procedure_1.dossiers.first.id + 14)}")
|
||||
end
|
||||
|
||||
scenario 'Following dossier' do
|
||||
page.all('#procedure-list a').first.click
|
||||
expect(page.all('#follow_dossiers .smart-listing')[0]['data-item-count']).to eq ("0")
|
||||
page.find_by_id('all_dossiers').click
|
||||
expect(page.all('#dossiers-list a').first.text).to eq('Suivre')
|
||||
page.all('#dossiers-list a').first.click
|
||||
expect(page.all('#follow_dossiers .smart-listing')[0]['data-item-count']).to eq ("1")
|
||||
end
|
||||
|
||||
scenario 'Using sort and pagination', js: true do
|
||||
visit "/backoffice/dossiers/procedure/#{procedure_1.id}?all_state_dossiers_smart_listing[sort][id]=asc"
|
||||
wait_for_ajax
|
||||
expect(page.all("#all_state_dossiers .dossier-row")[0]['id']).to eq("tr_dossier_#{procedure_1.dossiers.first.id}")
|
||||
visit "/backoffice/dossiers/procedure/#{procedure_1.id}?all_state_dossiers_smart_listing[sort][id]=desc"
|
||||
wait_for_ajax
|
||||
expect(page.all("#all_dossiers .dossier-row")[0]['id']).to eq("tr_dossier_#{procedure_1.dossiers.last.id}")
|
||||
page.find('#all_state_dossiers .next_page a').trigger('click')
|
||||
wait_for_ajax
|
||||
page.find('#all_state_dossiers .next_page a').trigger('click')
|
||||
wait_for_ajax
|
||||
expect(page.all("#all_dossiers .dossier-row")[0]['id']).to eq("tr_dossier_#{procedure_1.dossiers.first.id + 9}")
|
||||
page.find('#all_state_dossiers .prev a').trigger('click')
|
||||
wait_for_ajax
|
||||
expect(page.all("#all_dossiers .dossier-row")[0]['id']).to eq("tr_dossier_#{procedure_1.dossiers.first.id + 19}")
|
||||
end
|
||||
|
||||
scenario 'Using filter' do
|
||||
end
|
||||
|
||||
scenario 'Have an export button' do
|
||||
expect(page.all('.export-link')[0].text).to eq('Au format CSV')
|
||||
expect(page.all('.export-link')[1].text).to eq('Au format XLSX')
|
||||
expect(page.all('.export-link')[2].text).to eq('Au format ODS')
|
||||
end
|
||||
end
|
||||
|
||||
context 'On show' do
|
||||
scenario 'Following dossier' do
|
||||
expect(page.all('#follow_dossiers .count').first.text).to eq('0 dossiers')
|
||||
|
||||
visit "/backoffice/dossiers/procedure/#{procedure_1.id}?all_state_dossiers_smart_listing[sort][id]=asc"
|
||||
page.find("#all_dossiers #suivre_dossier_#{procedure_1.dossiers.first.id}").click
|
||||
|
||||
visit "/backoffice/dossiers/#{procedure_1.dossiers.second.id}"
|
||||
page.find_by_id("suivre_dossier_#{procedure_1.dossiers.second.id}").click
|
||||
|
||||
visit "/backoffice/dossiers/procedure/#{procedure_1.id}"
|
||||
expect(page.all('#follow_dossiers .count').first.text).to eq('2 dossiers')
|
||||
end
|
||||
|
||||
if ENV['CIRCLECI'].nil?
|
||||
scenario 'Adding message', js: true do
|
||||
page.find("#all_dossiers #tr_dossier_#{procedure_1.dossiers.first.id}").trigger('click')
|
||||
expect(page).to have_current_path(backoffice_dossier_path(procedure_1.dossiers.first.id), only_path: true)
|
||||
page.find_by_id('open-message').click
|
||||
page.execute_script("$('#texte_commentaire').data('wysihtml5').editor.setValue('Contenu du nouveau message')")
|
||||
page.find_by_id('save-message').click
|
||||
expect(page.find('.last-commentaire .content').text).to eq('Contenu du nouveau message')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,79 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'usage of pref list dossier lateral panel', js: true do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
|
||||
let(:procedure) { create(:procedure, :published, administrateur: administrateur) }
|
||||
|
||||
before do
|
||||
create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction')
|
||||
create :assign_to, procedure: procedure, gestionnaire: gestionnaire
|
||||
|
||||
login_as gestionnaire, scope: :gestionnaire
|
||||
|
||||
visit backoffice_path
|
||||
end
|
||||
|
||||
context 'when user enter good credentials' do
|
||||
scenario 'he is redirected to /backoffice' do
|
||||
expect(page).to have_css('#backoffice-index')
|
||||
end
|
||||
|
||||
scenario 'lateral panel is masked' do
|
||||
expect(page).to have_css('#pref-list-menu', visible: false)
|
||||
end
|
||||
|
||||
context 'when on click on pref list button' do
|
||||
before do
|
||||
page.click_on 'pref-list-dossier-open-action'
|
||||
end
|
||||
|
||||
scenario 'lateral panel is appeared' do
|
||||
expect(page).to have_css('#pref-list-menu')
|
||||
end
|
||||
|
||||
context 'when on click on add attribut button' do
|
||||
before do
|
||||
page.click_on 'add_pref_list_entreprise_siren'
|
||||
end
|
||||
|
||||
scenario 'preference list panel is brought up to date' do
|
||||
wait_for_ajax
|
||||
expect(page).to have_css('#delete_pref_list_entreprise_siren')
|
||||
end
|
||||
|
||||
scenario 'dossier is brought up to date' do
|
||||
wait_for_ajax
|
||||
expect(page).to have_selector("a.sortable[data-attr='entreprise.siren']", visible: false)
|
||||
end
|
||||
|
||||
context 'when on click on delete attribut button' do
|
||||
before do
|
||||
page.click_on 'delete_pref_list_entreprise_siren'
|
||||
end
|
||||
|
||||
scenario 'preference list panel is brought up to date' do
|
||||
wait_for_ajax
|
||||
expect(page).not_to have_css('#delete_pref_list_entreprise_siren')
|
||||
end
|
||||
|
||||
scenario 'dossier is brought up to date', js: true do
|
||||
wait_for_ajax
|
||||
expect(page).not_to have_selector("a.sortable[data-attr='entreprise.siren']", visible: true)
|
||||
end
|
||||
|
||||
context 'when on click on close pref list button' do
|
||||
before do
|
||||
page.click_on 'pref-list-dossier-close-action'
|
||||
end
|
||||
|
||||
scenario 'lateral panel is masked' do
|
||||
wait_for_ajax
|
||||
expect(page).to have_css('#pref-list-menu', visible: false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,81 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'usage of pref list dossier lateral panel by procedure', js: true do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
|
||||
let(:procedure) { create(:procedure, :published, :with_type_de_champ, administrateur: administrateur) }
|
||||
|
||||
before do
|
||||
create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction')
|
||||
create :assign_to, procedure: procedure, gestionnaire: gestionnaire
|
||||
|
||||
login_as gestionnaire, scope: :gestionnaire
|
||||
|
||||
visit backoffice_path
|
||||
end
|
||||
|
||||
context 'when user enter good credentials' do
|
||||
scenario 'he is redirected to /backoffice/dossiers/' do
|
||||
expect(page).to have_css('#backoffice-index')
|
||||
end
|
||||
|
||||
describe 'user navigate to dossiers list by procedure' do
|
||||
before do
|
||||
visit backoffice_dossiers_procedure_path(procedure.id)
|
||||
end
|
||||
|
||||
scenario 'lateral panel is masked' do
|
||||
expect(page).to have_css('#pref-list-menu', visible: false)
|
||||
end
|
||||
|
||||
context 'when on click on pref list button' do
|
||||
before do
|
||||
page.click_on 'pref-list-dossier-open-action'
|
||||
end
|
||||
|
||||
scenario 'lateral panel is appeared' do
|
||||
wait_for_ajax
|
||||
expect(page).to have_css('#pref-list-menu')
|
||||
end
|
||||
|
||||
context 'when on click on add attribut specific at the procedure button' do
|
||||
before do
|
||||
page.click_on 'add_pref_list_champs_' + procedure.types_de_champ.first.id.to_s
|
||||
end
|
||||
|
||||
scenario 'preference list panel is brought up to date' do
|
||||
wait_for_ajax
|
||||
expect(page).to have_css('#delete_pref_list_champs_' + procedure.types_de_champ.first.id.to_s)
|
||||
end
|
||||
|
||||
context 'when on click on delete attribut button' do
|
||||
before do
|
||||
page.click_on 'delete_pref_list_champs_' + procedure.types_de_champ.first.id.to_s
|
||||
end
|
||||
|
||||
scenario 'preference list panel is brought up to date' do
|
||||
wait_for_ajax
|
||||
expect(page).not_to have_css('#delete_pref_list_champs_' + procedure.types_de_champ.first.id.to_s)
|
||||
end
|
||||
|
||||
scenario 'dossier is brought up to date' do
|
||||
wait_for_ajax
|
||||
expect(page).not_to have_selector("a.sortable[data-attr='entreprise.siren']", visible: false)
|
||||
end
|
||||
|
||||
context 'when on click on close pref list button' do
|
||||
before do
|
||||
page.click_on 'pref-list-dossier-close-action'
|
||||
end
|
||||
|
||||
scenario 'lateral panel is masked' do
|
||||
wait_for_ajax
|
||||
expect(page).to have_css('#pref-list-menu', visible: false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,64 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'on backoffice page', js: true do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
|
||||
let(:procedure) { create(:procedure, :published, administrateur: administrateur) }
|
||||
let(:procedure_individual) { create :procedure, :published, libelle: 'procedure individual', administrateur: administrateur, for_individual: true }
|
||||
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') }
|
||||
let!(:dossier_individual) { create :dossier, procedure: procedure_individual, state: 'en_construction' }
|
||||
|
||||
before do
|
||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
||||
create :follow, gestionnaire: gestionnaire, dossier: dossier
|
||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_individual
|
||||
create :follow, gestionnaire: gestionnaire, dossier: dossier_individual
|
||||
visit users_path
|
||||
end
|
||||
|
||||
context 'when gestionnaire is logged in' do
|
||||
before do
|
||||
page.find_by_id(:user_email).set gestionnaire.email
|
||||
page.find_by_id(:user_password).set gestionnaire.password
|
||||
page.click_on 'Se connecter'
|
||||
page.click_on 'Ancienne interface'
|
||||
end
|
||||
context 'when he click on first dossier' do
|
||||
before do
|
||||
page.find("#tr_dossier_#{dossier.id}", visible: true).click
|
||||
end
|
||||
|
||||
scenario 'it redirect to dossier page' do
|
||||
expect(page).to have_css('#backoffice-dossier-show')
|
||||
end
|
||||
end
|
||||
|
||||
context "and goes to the page of a dossier he hasn't access to" do
|
||||
let!(:unauthorized_dossier) { create(:dossier, :with_entreprise, state: 'en_construction') }
|
||||
|
||||
before do
|
||||
visit backoffice_dossier_path(unauthorized_dossier)
|
||||
end
|
||||
|
||||
scenario "it shows an error message" do
|
||||
expect(page).to have_content("Le dossier n'existe pas ou vous n'y avez pas accès.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when gestionnaire have enterprise and individual dossier in his inbox', js: true do
|
||||
before do
|
||||
page.find_by_id(:user_email).set gestionnaire.email
|
||||
page.find_by_id(:user_password).set gestionnaire.password
|
||||
page.click_on 'Se connecter'
|
||||
|
||||
visit backoffice_dossiers_procedure_path(id: procedure_individual.id)
|
||||
page.find("#tr_dossier_#{dossier_individual.id}", visible: true).click
|
||||
end
|
||||
|
||||
scenario 'it redirect to dossier page' do
|
||||
expect(page).to have_css('#backoffice-dossier-show')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,52 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'search file on gestionnaire backoffice' do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
|
||||
|
||||
before do
|
||||
login_as gestionnaire, scope: :gestionnaire
|
||||
end
|
||||
|
||||
context 'when gestionnaire is logged in' do
|
||||
context 'when he click on search button' do
|
||||
let(:terms) { '' }
|
||||
let!(:procedure) { create(:procedure, :published, administrateur: administrateur) }
|
||||
|
||||
before do
|
||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
||||
|
||||
visit backoffice_dossiers_url
|
||||
page.find_by_id(:q).set terms
|
||||
page.find_by_id("search-button").click
|
||||
end
|
||||
|
||||
it { expect(page).to have_css('#backoffice-search') }
|
||||
|
||||
context 'when terms input is empty' do
|
||||
it { expect(page).to have_content('Aucun dossier') }
|
||||
end
|
||||
|
||||
context 'when terms input is informed' do
|
||||
let(:terms) { 'test' }
|
||||
|
||||
it 'terms stay in input after search' do
|
||||
expect(page.find_by_id('q').value).to eq(terms)
|
||||
end
|
||||
|
||||
context 'when terms input does not return result' do
|
||||
it { expect(page).to have_content('Aucun dossier') }
|
||||
end
|
||||
|
||||
context 'when terms input does return result' do
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') }
|
||||
let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'en_construction') }
|
||||
|
||||
let(:terms) { dossier.entreprise.raison_sociale }
|
||||
|
||||
it { expect(page).to have_content(dossier.entreprise.raison_sociale) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
File diff suppressed because it is too large
Load diff
|
@ -64,63 +64,6 @@ describe Gestionnaire, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#build_default_preferences_list_dossier' do
|
||||
subject { gestionnaire.preference_list_dossiers }
|
||||
|
||||
context 'when gestionnaire is created' do
|
||||
it 'build default 5 pref list dossier object' do
|
||||
expect(subject.size).to eq 5
|
||||
end
|
||||
|
||||
it 'build dossier_id column' do
|
||||
expect(subject.first.table).to be_nil
|
||||
expect(subject.first.attr).to eq 'id'
|
||||
end
|
||||
|
||||
it 'build dossier state column' do
|
||||
expect(subject[1].table).to be_nil
|
||||
expect(subject[1].attr).to eq 'state'
|
||||
end
|
||||
|
||||
it 'build procedure libelle column' do
|
||||
expect(subject[2].table).to eq 'procedure'
|
||||
expect(subject[2].attr).to eq 'libelle'
|
||||
end
|
||||
|
||||
it 'build entreprise raison_sociale column' do
|
||||
expect(subject[3].table).to eq 'entreprise'
|
||||
expect(subject[3].attr).to eq 'raison_sociale'
|
||||
end
|
||||
|
||||
it 'build entreprise raison_sociale column' do
|
||||
expect(subject.last.table).to eq 'etablissement'
|
||||
expect(subject.last.attr).to eq 'siret'
|
||||
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
|
||||
|
||||
context 'unified login' do
|
||||
it 'syncs credentials to associated user' do
|
||||
gestionnaire = create(:gestionnaire)
|
||||
|
|
|
@ -1,338 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe PreferenceListDossier do
|
||||
it { is_expected.to have_db_column(:libelle) }
|
||||
it { is_expected.to have_db_column(:table) }
|
||||
it { is_expected.to have_db_column(:attr) }
|
||||
it { is_expected.to have_db_column(:attr_decorate) }
|
||||
it { is_expected.to have_db_column(:bootstrap_lg) }
|
||||
it { is_expected.to have_db_column(:order) }
|
||||
it { is_expected.to have_db_column(:filter) }
|
||||
it { is_expected.to have_db_column(:gestionnaire_id) }
|
||||
|
||||
it { is_expected.to belong_to(:gestionnaire) }
|
||||
it { is_expected.to belong_to(:procedure) }
|
||||
|
||||
describe '.available_columns_for' do
|
||||
let(:procedure_id) { nil }
|
||||
|
||||
subject { PreferenceListDossier.available_columns_for procedure_id }
|
||||
|
||||
describe 'dossier' do
|
||||
subject { super()[:dossier] }
|
||||
|
||||
it { expect(subject.size).to eq 4 }
|
||||
|
||||
describe 'dossier_id' do
|
||||
subject { super()[:dossier_id] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Nº' }
|
||||
it { expect(subject[:table]).to be_nil }
|
||||
it { expect(subject[:attr]).to eq 'id' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'id' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 1 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'created_at' do
|
||||
subject { super()[:created_at] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Créé le' }
|
||||
it { expect(subject[:table]).to be_nil }
|
||||
it { expect(subject[:attr]).to eq 'created_at' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'first_creation' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 2 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'updated_at' do
|
||||
subject { super()[:updated_at] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Mise à jour le' }
|
||||
it { expect(subject[:table]).to be_nil }
|
||||
it { expect(subject[:attr]).to eq 'updated_at' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'last_update' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 2 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'state' do
|
||||
subject { super()[:state] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'État' }
|
||||
it { expect(subject[:table]).to be_nil }
|
||||
it { expect(subject[:attr]).to eq 'state' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'display_state' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 1 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'procedure' do
|
||||
subject { super()[:procedure] }
|
||||
|
||||
it { expect(subject.size).to eq 3 }
|
||||
|
||||
describe 'libelle' do
|
||||
subject { super()[:libelle] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Libellé procédure' }
|
||||
it { expect(subject[:table]).to eq 'procedure' }
|
||||
it { expect(subject[:attr]).to eq 'libelle' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'libelle' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 4 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'organisation' do
|
||||
subject { super()[:organisation] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Organisme' }
|
||||
it { expect(subject[:table]).to eq 'procedure' }
|
||||
it { expect(subject[:attr]).to eq 'organisation' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'organisation' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 3 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'direction' do
|
||||
subject { super()[:direction] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Direction' }
|
||||
it { expect(subject[:table]).to eq 'procedure' }
|
||||
it { expect(subject[:attr]).to eq 'direction' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'direction' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 3 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'entreprise' do
|
||||
subject { super()[:entreprise] }
|
||||
|
||||
it { expect(subject.size).to eq 6 }
|
||||
|
||||
describe 'siren' do
|
||||
subject { super()[:siren] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'SIREN' }
|
||||
it { expect(subject[:table]).to eq 'entreprise' }
|
||||
it { expect(subject[:attr]).to eq 'siren' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'siren' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 2 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'forme_juridique' do
|
||||
subject { super()[:forme_juridique] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Forme juridique' }
|
||||
it { expect(subject[:table]).to eq 'entreprise' }
|
||||
it { expect(subject[:attr]).to eq 'forme_juridique' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'forme_juridique' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 3 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'nom_commercial' do
|
||||
subject { super()[:nom_commercial] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Nom commercial' }
|
||||
it { expect(subject[:table]).to eq 'entreprise' }
|
||||
it { expect(subject[:attr]).to eq 'nom_commercial' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'nom_commercial' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 3 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'raison_sociale' do
|
||||
subject { super()[:raison_sociale] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Raison sociale' }
|
||||
it { expect(subject[:table]).to eq 'entreprise' }
|
||||
it { expect(subject[:attr]).to eq 'raison_sociale' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'raison_sociale' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 3 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'siret_siege_social' do
|
||||
subject { super()[:siret_siege_social] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'SIRET siège social' }
|
||||
it { expect(subject[:table]).to eq 'entreprise' }
|
||||
it { expect(subject[:attr]).to eq 'siret_siege_social' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'siret_siege_social' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 2 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'date_creation' do
|
||||
subject { super()[:date_creation] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Date de création' }
|
||||
it { expect(subject[:table]).to eq 'entreprise' }
|
||||
it { expect(subject[:attr]).to eq 'date_creation' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'date_creation' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 2 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'etablissement' do
|
||||
subject { super()[:etablissement] }
|
||||
|
||||
it { expect(subject.size).to eq 3 }
|
||||
|
||||
describe 'siret' do
|
||||
subject { super()[:siret] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'SIRET' }
|
||||
it { expect(subject[:table]).to eq 'etablissement' }
|
||||
it { expect(subject[:attr]).to eq 'siret' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'siret' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 2 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'libelle' do
|
||||
subject { super()[:libelle] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Libellé NAF' }
|
||||
it { expect(subject[:table]).to eq 'etablissement' }
|
||||
it { expect(subject[:attr]).to eq 'libelle_naf' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'libelle_naf' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 3 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'code_postal' do
|
||||
subject { super()[:code_postal] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Code postal' }
|
||||
it { expect(subject[:table]).to eq 'etablissement' }
|
||||
it { expect(subject[:attr]).to eq 'code_postal' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'code_postal' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 1 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'user' do
|
||||
subject { super()[:user] }
|
||||
|
||||
it { expect(subject.size).to eq 1 }
|
||||
|
||||
describe 'email' do
|
||||
subject { super()[:email] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Email' }
|
||||
it { expect(subject[:table]).to eq 'user' }
|
||||
it { expect(subject[:attr]).to eq 'email' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'email' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 2 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'france_connect' do
|
||||
subject { super()[:france_connect] }
|
||||
|
||||
it { expect(subject.size).to eq 3 }
|
||||
|
||||
describe 'gender' do
|
||||
subject { super()[:gender] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Civilité (FC)' }
|
||||
it { expect(subject[:table]).to eq 'france_connect_information' }
|
||||
it { expect(subject[:attr]).to eq 'gender' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'gender_fr' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 1 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'family_name' do
|
||||
subject { super()[:family_name] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Nom (FC)' }
|
||||
it { expect(subject[:table]).to eq 'france_connect_information' }
|
||||
it { expect(subject[:attr]).to eq 'family_name' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'family_name' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 2 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'gender' do
|
||||
subject { super()[:given_name] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Prénom (FC)' }
|
||||
it { expect(subject[:table]).to eq 'france_connect_information' }
|
||||
it { expect(subject[:attr]).to eq 'given_name' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'given_name' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 2 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a procedure ID is pasted' do
|
||||
let(:procedure) { (create :procedure, :with_type_de_champ, :with_type_de_champ_private) }
|
||||
let(:procedure_id) { procedure.id }
|
||||
|
||||
describe 'champs' do
|
||||
subject { super()[:champs] }
|
||||
|
||||
it { expect(subject.size).to eq 1 }
|
||||
|
||||
describe 'first champs' do
|
||||
subject { super()["type_de_champ_#{procedure.types_de_champ.first.id}"] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq procedure.types_de_champ.first.libelle }
|
||||
it { expect(subject[:table]).to eq 'champs' }
|
||||
it { expect(subject[:attr]).to eq procedure.types_de_champ.first.id }
|
||||
it { expect(subject[:attr_decorate]).to eq 'value' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 2 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'champs private' do
|
||||
subject { super()[:champs_private] }
|
||||
|
||||
it { expect(subject.size).to eq 1 }
|
||||
|
||||
describe 'first champs' do
|
||||
subject { super()["type_de_champ_private_#{procedure.types_de_champ_private.first.id}"] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq procedure.types_de_champ_private.first.libelle }
|
||||
it { expect(subject[:table]).to eq 'champs_private' }
|
||||
it { expect(subject[:attr]).to eq procedure.types_de_champ_private.first.id }
|
||||
it { expect(subject[:attr_decorate]).to eq 'value' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 2 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,10 +0,0 @@
|
|||
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
|
|
@ -30,34 +30,4 @@ describe AccompagnateurService do
|
|||
it { expect(accompagnateur.procedures).not_to include procedure }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#build_default_column' do
|
||||
subject { accompagnateur_service.build_default_column }
|
||||
|
||||
context 'when to is not assign' do
|
||||
let(:to) { AccompagnateurService::NOT_ASSIGN }
|
||||
|
||||
it { is_expected.to be_nil }
|
||||
end
|
||||
|
||||
context 'when to is assign' do
|
||||
let(:to) { AccompagnateurService::ASSIGN }
|
||||
|
||||
context 'when gestionnaire has already preference for this procedure' do
|
||||
before do
|
||||
create :preference_list_dossier, gestionnaire: accompagnateur, procedure: procedure
|
||||
end
|
||||
|
||||
it { is_expected.to be_nil }
|
||||
end
|
||||
|
||||
context 'when gestionnaire has not preference for this procedure' do
|
||||
before do
|
||||
subject
|
||||
end
|
||||
|
||||
it { expect(accompagnateur.preference_list_dossiers.where('procedure_id IS NULL').size).to eq procedure.preference_list_dossiers.size }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,374 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe DossiersListGestionnaireService do
|
||||
let(:gestionnaire) { create :gestionnaire }
|
||||
let(:preference_smart_listing_page) { gestionnaire.preference_smart_listing_page }
|
||||
let(:liste) { 'all_state' }
|
||||
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 '#join_filter' do
|
||||
subject { DossiersListGestionnaireService.new(gestionnaire, liste, nil).joins_filter }
|
||||
|
||||
it { is_expected.to eq []}
|
||||
|
||||
context 'when a filter is fielded' 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 [:entreprise] }
|
||||
end
|
||||
|
||||
context 'when a filter is empty' do
|
||||
before do
|
||||
gestionnaire.preference_list_dossiers
|
||||
.find_by(table: 'entreprise', attr: 'raison_sociale', procedure: nil)
|
||||
.update_column :filter, ''
|
||||
end
|
||||
|
||||
it { is_expected.to eq [] }
|
||||
end
|
||||
|
||||
context 'when a filter is nil' do
|
||||
before do
|
||||
gestionnaire.preference_list_dossiers
|
||||
.find_by(table: 'entreprise', attr: 'raison_sociale', procedure: nil)
|
||||
.update_column :filter, nil
|
||||
end
|
||||
|
||||
it { is_expected.to eq [] }
|
||||
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
|
||||
|
||||
context "when filter containe the character <'> " do
|
||||
before do
|
||||
gestionnaire.preference_list_dossiers
|
||||
.find_by(table: 'entreprise', attr: 'raison_sociale', procedure: nil)
|
||||
.update_column :filter, "MCDONALD'S FRANCE"
|
||||
end
|
||||
|
||||
it { is_expected.to eq "CAST(dossiers.id as TEXT) LIKE '%23%' AND CAST(entreprises.raison_sociale as TEXT) LIKE '%MCDONALD''S FRANCE%'" }
|
||||
end
|
||||
|
||||
context "when filter is empty " do
|
||||
before do
|
||||
gestionnaire.preference_list_dossiers
|
||||
.find_by(table: 'entreprise', attr: 'raison_sociale', procedure: nil)
|
||||
.update_column :filter, ""
|
||||
end
|
||||
|
||||
it { is_expected.to eq "CAST(dossiers.id as TEXT) LIKE '%23%'" }
|
||||
end
|
||||
|
||||
context 'when preference list contain a champ' do
|
||||
before do
|
||||
create :preference_list_dossier,
|
||||
gestionnaire: gestionnaire,
|
||||
table: 'champs',
|
||||
attr: '34',
|
||||
attr_decorate: '',
|
||||
filter: 'plop',
|
||||
procedure_id: create(:procedure)
|
||||
end
|
||||
|
||||
it { is_expected.to eq "CAST(dossiers.id as TEXT) LIKE '%23%' AND CAST(entreprises.raison_sociale as TEXT) LIKE '%plop%' AND champs.type_de_champ_id = 34 AND CAST(champs.value as TEXT) LIKE '%plop%'" }
|
||||
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) { 'all_state' }
|
||||
|
||||
let(:page) { 2 }
|
||||
let(:new_page) { 1 }
|
||||
|
||||
before do
|
||||
preference_smart_listing_page.update page: page, liste: liste, 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) { 'all_state' }
|
||||
|
||||
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 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) { 'all_state' }
|
||||
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
|
||||
|
||||
describe 'state filter methods' do
|
||||
let!(:procedure) { create :procedure }
|
||||
let!(:dossier) { create(:dossier, procedure: procedure, state: 'brouillon') }
|
||||
let!(:dossier2) { create(:dossier, procedure: procedure, state: 'en_construction') } #nouveaux
|
||||
let!(:dossier3) { create(:dossier, procedure: procedure, state: 'en_construction') } #nouveaux
|
||||
let!(:dossier6) { create(:dossier, procedure: procedure, state: 'en_instruction') } #a_instruire
|
||||
let!(:dossier7) { create(:dossier, procedure: procedure, state: 'en_instruction') } #a_instruire
|
||||
let!(:dossier8) { create(:dossier, procedure: procedure, state: 'accepte') } #termine
|
||||
let!(:dossier9) { create(:dossier, procedure: procedure, state: 'refuse') } #termine
|
||||
let!(:dossier10) { create(:dossier, procedure: procedure, state: 'sans_suite') } #termine
|
||||
let!(:dossier11) { create(:dossier, procedure: procedure, state: 'accepte') } #termine
|
||||
let!(:dossier12) { create(:dossier, procedure: procedure, state: 'en_construction', archived: true) } #a_traiter #archived
|
||||
let!(:dossier14) { create(:dossier, procedure: procedure, state: 'accepte', archived: true) } #termine #archived
|
||||
|
||||
describe '#termine' do
|
||||
subject { DossiersListGestionnaireService.new(gestionnaire, liste, procedure).termine }
|
||||
|
||||
it { expect(subject.size).to eq(4) }
|
||||
it { expect(subject).to include(dossier8, dossier9, dossier10, dossier11) }
|
||||
end
|
||||
|
||||
describe '#a_instruire' do
|
||||
subject { DossiersListGestionnaireService.new(gestionnaire, liste, procedure).a_instruire }
|
||||
|
||||
it { expect(subject.size).to eq(2) }
|
||||
it { expect(subject).to include(dossier6, dossier7) }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,87 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'backoffice/dossiers/index.html.haml', type: :view do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
|
||||
|
||||
let!(:procedure) { create(:procedure, :published, administrateur: administrateur) }
|
||||
|
||||
let!(:decorate_dossier_en_construction) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction').decorate }
|
||||
let!(:decorate_dossier_en_instruction) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_instruction').decorate }
|
||||
let!(:decorate_dossier_accepte) { create(:dossier, :with_entreprise, procedure: procedure, state: 'accepte').decorate }
|
||||
let!(:decorate_dossier_refuse) { create(:dossier, :with_entreprise, procedure: procedure, state: 'refuse').decorate }
|
||||
let!(:decorate_dossier_sans_suite) { create(:dossier, :with_entreprise, procedure: procedure, state: 'sans_suite').decorate }
|
||||
|
||||
let(:dossiers_list_facade) { DossiersListFacades.new gestionnaire, nil }
|
||||
|
||||
let(:new_dossiers_list) { dossiers_list_facade.service.nouveaux }
|
||||
let(:follow_dossiers_list) { dossiers_list_facade.service.suivi }
|
||||
let(:all_state_dossiers_list) { dossiers_list_facade.service.all_state }
|
||||
|
||||
before do
|
||||
decorate_dossier_en_instruction.entreprise.update_column(:raison_sociale, 'plup')
|
||||
decorate_dossier_accepte.entreprise.update_column(:raison_sociale, 'plyp')
|
||||
decorate_dossier_refuse.entreprise.update_column(:raison_sociale, 'plzp')
|
||||
decorate_dossier_sans_suite.entreprise.update_column(:raison_sociale, 'plnp')
|
||||
|
||||
create :preference_list_dossier,
|
||||
gestionnaire: gestionnaire,
|
||||
table: nil,
|
||||
attr: 'state',
|
||||
attr_decorate: 'display_state'
|
||||
|
||||
create :preference_list_dossier,
|
||||
gestionnaire: gestionnaire,
|
||||
table: 'procedure',
|
||||
attr: 'libelle',
|
||||
attr_decorate: 'libelle'
|
||||
|
||||
create :preference_list_dossier,
|
||||
gestionnaire: gestionnaire,
|
||||
table: 'entreprise',
|
||||
attr: 'raison_sociale',
|
||||
attr_decorate: 'raison_sociale'
|
||||
|
||||
create :preference_list_dossier,
|
||||
gestionnaire: gestionnaire,
|
||||
table: nil,
|
||||
attr: 'last_update',
|
||||
attr_decorate: 'last_update'
|
||||
|
||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
||||
sign_in gestionnaire
|
||||
|
||||
assign :facade_data_view, dossiers_list_facade
|
||||
|
||||
assign(:new_dossiers, (smart_listing_create :new_dossiers,
|
||||
new_dossiers_list,
|
||||
partial: "backoffice/dossiers/list",
|
||||
array: true))
|
||||
|
||||
assign(:follow_dossiers, (smart_listing_create :follow_dossiers,
|
||||
follow_dossiers_list,
|
||||
partial: "backoffice/dossiers/list",
|
||||
array: true))
|
||||
|
||||
assign(:all_state_dossiers, (smart_listing_create :all_state_dossiers,
|
||||
all_state_dossiers_list,
|
||||
partial: "backoffice/dossiers/list",
|
||||
array: true))
|
||||
|
||||
render
|
||||
end
|
||||
|
||||
subject { rendered }
|
||||
|
||||
it { is_expected.to have_content('Nouveaux dossiers 1 dossier') }
|
||||
it { is_expected.to have_content('Dossiers suivis 0 dossiers') }
|
||||
it { is_expected.to have_content('Tous les dossiers 5 dossiers') }
|
||||
|
||||
it { is_expected.to have_content('État') }
|
||||
it { is_expected.to have_content('Libellé procédure') }
|
||||
it { is_expected.to have_content('Raison sociale') }
|
||||
it { is_expected.to have_content('Mise à jour le') }
|
||||
|
||||
it { is_expected.to have_content('plup') }
|
||||
it { is_expected.to have_content('plyp') }
|
||||
end
|
|
@ -1,52 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'backoffice/dossiers/show.html.haml', type: :view do
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, state: state, motivation: "Motivation de décision") }
|
||||
let(:state) { 'accepte' }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
|
||||
before do
|
||||
sign_in gestionnaire
|
||||
assign(:facade, (DossierFacades.new dossier.id, gestionnaire.email))
|
||||
|
||||
@request.env['PATH_INFO'] = 'backoffice/user'
|
||||
end
|
||||
|
||||
context 'on the dossier gestionnaire page' do
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
it 'button Modifier les document est present' do
|
||||
expect(rendered).not_to have_content('Modifier les documents')
|
||||
expect(rendered).not_to have_css('#upload-pj-modal')
|
||||
end
|
||||
|
||||
it 'enterprise informations are present' do
|
||||
expect(rendered).to have_selector('#infos_entreprise')
|
||||
end
|
||||
|
||||
it 'dossier informations are present' do
|
||||
expect(rendered).to have_selector('#infos-dossiers')
|
||||
end
|
||||
|
||||
context 'edit link are present' do
|
||||
it 'edit carto' do
|
||||
expect(rendered).to_not have_selector('a[id=modif_carte]')
|
||||
end
|
||||
|
||||
it 'edit description' do
|
||||
expect(rendered).to_not have_selector('a[id=modif_description]')
|
||||
end
|
||||
|
||||
it 'Editer mon dossier button doesnt present' do
|
||||
expect(rendered).to_not have_css('#maj_infos')
|
||||
end
|
||||
end
|
||||
|
||||
it "shows the motivation" do
|
||||
expect(rendered).to have_content("Motivation de décision")
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,128 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml', type: :view do
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, state: state, archived: archived) }
|
||||
let(:state) { 'brouillon' }
|
||||
let(:archived) { false }
|
||||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
let!(:assign_to) { create(:assign_to, gestionnaire: gestionnaire, procedure: dossier.procedure) }
|
||||
|
||||
before do
|
||||
sign_in gestionnaire
|
||||
assign(:facade, (DossierFacades.new dossier.id, gestionnaire.email))
|
||||
|
||||
@request.env['PATH_INFO'] = 'backoffice/user'
|
||||
|
||||
render
|
||||
end
|
||||
|
||||
subject { rendered }
|
||||
|
||||
it 'dossier number is present' do
|
||||
expect(rendered).to have_selector('#dossier_id')
|
||||
expect(rendered).to have_content(dossier.id)
|
||||
end
|
||||
|
||||
context 'button dossier state changements' do
|
||||
shared_examples 'button Passer en instruction is present' do
|
||||
it { expect(rendered).to have_link('Passer en instruction') }
|
||||
end
|
||||
|
||||
context 'when dossier have state en_construction' do
|
||||
let(:state) { 'en_construction' }
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content('En construction') }
|
||||
|
||||
include_examples 'button Passer en instruction is present'
|
||||
end
|
||||
|
||||
context 'when dossier have state en_instruction' do
|
||||
let(:state) { 'en_instruction' }
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content('En instruction') }
|
||||
|
||||
it 'button accepter / refuser / classer sans suite are present' do
|
||||
expect(rendered).to have_css('button[title="Accepter"]')
|
||||
expect(rendered).to have_css('button[title="Classer sans suite"]')
|
||||
expect(rendered).to have_css('button[title="Refuser"]')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier have state accepte' do
|
||||
let(:state) { 'accepte' }
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content('Accepté') }
|
||||
|
||||
it 'button Accepter le dossier is not present' do
|
||||
expect(rendered).not_to have_css('form[data-toggle="tooltip"][title="Accepter"]')
|
||||
expect(rendered).not_to have_css('form[data-toggle="tooltip"][title="Classer sans suite"]')
|
||||
expect(rendered).not_to have_css('form[data-toggle="tooltip"][title="Refuser"]')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier have state sans_suite' do
|
||||
let(:state) { 'sans_suite' }
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content('Sans suite') }
|
||||
|
||||
it 'button Déclarer complet is not present' do
|
||||
expect(rendered).not_to have_css('form[data-toggle="tooltip"][title="Accepter"]')
|
||||
expect(rendered).not_to have_css('form[data-toggle="tooltip"][title="Classer sans suite"]')
|
||||
expect(rendered).not_to have_css('form[data-toggle="tooltip"][title="Refuser"]')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier have state refuse' do
|
||||
let(:state) { 'refuse' }
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content('Refusé') }
|
||||
|
||||
it 'button Déclarer complet is not present' do
|
||||
expect(rendered).not_to have_css('form[data-toggle="tooltip"][title="Accepter"]')
|
||||
expect(rendered).not_to have_css('form[data-toggle="tooltip"][title="Classer sans suite"]')
|
||||
expect(rendered).not_to have_css('form[data-toggle="tooltip"][title="Refuser"]')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier is not archived' do
|
||||
let(:archived) { false }
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_link('Archiver') }
|
||||
end
|
||||
|
||||
context 'when dossier is archived' do
|
||||
let(:archived) { true }
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content('Archivé') }
|
||||
it { expect(rendered).to have_link('Désarchiver') }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -18,7 +18,6 @@ describe 'users/dossiers/index.html.haml', type: :view do
|
|||
before do
|
||||
sign_in user
|
||||
|
||||
assign :dossiers_list_facade, (DossiersListFacades.new user, liste)
|
||||
assign(:dossiers, (smart_listing_create :dossiers,
|
||||
dossiers_to_display,
|
||||
partial: "users/dossiers/list",
|
||||
|
|
Loading…
Reference in a new issue