commit
81897e68ba
5 changed files with 11 additions and 36 deletions
|
@ -21,14 +21,6 @@ class DossiersListFacades
|
|||
@current_devise_profil.followed_dossiers.count
|
||||
end
|
||||
|
||||
def total_new_dossier
|
||||
current_devise_profil.dossiers.state_nouveaux.not_archived.count
|
||||
end
|
||||
|
||||
def new_dossier_number procedure_id
|
||||
current_devise_profil.dossiers.state_nouveaux.not_archived.where(procedure_id: procedure_id).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
|
||||
|
|
|
@ -4,7 +4,7 @@ class AutoReceiveDossiersForProcedureJob < ApplicationJob
|
|||
def perform(procedure_id, state)
|
||||
procedure = Procedure.find_by(id: procedure_id)
|
||||
if procedure
|
||||
procedure.dossiers.state_nouveaux.update_all(state: state, en_instruction_at: Time.now)
|
||||
procedure.dossiers.state_en_construction.update_all(state: state, en_instruction_at: Time.now)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,11 +8,7 @@ class Dossier < ActiveRecord::Base
|
|||
sans_suite: 'sans_suite'
|
||||
}
|
||||
|
||||
BROUILLON = %w(brouillon)
|
||||
NOUVEAUX = %w(en_construction)
|
||||
EN_CONSTRUCTION = %w(en_construction)
|
||||
EN_INSTRUCTION = %w(en_instruction)
|
||||
EN_CONSTRUCTION_OU_INSTRUCTION = EN_CONSTRUCTION + EN_INSTRUCTION
|
||||
EN_CONSTRUCTION_OU_INSTRUCTION = %w(en_construction en_instruction)
|
||||
TERMINE = %w(accepte refuse sans_suite)
|
||||
|
||||
has_one :etablissement, dependent: :destroy
|
||||
|
@ -41,11 +37,10 @@ class Dossier < ActiveRecord::Base
|
|||
accepts_nested_attributes_for :champs_private
|
||||
|
||||
default_scope { where(hidden_at: nil) }
|
||||
scope :state_brouillon, -> { where(state: BROUILLON) }
|
||||
scope :state_not_brouillon, -> { where.not(state: BROUILLON) }
|
||||
scope :state_nouveaux, -> { where(state: NOUVEAUX) }
|
||||
scope :state_en_construction, -> { where(state: EN_CONSTRUCTION) }
|
||||
scope :state_en_instruction, -> { where(state: EN_INSTRUCTION) }
|
||||
scope :state_brouillon, -> { where(state: 'brouillon') }
|
||||
scope :state_not_brouillon, -> { where.not(state: 'brouillon') }
|
||||
scope :state_en_construction, -> { where(state: 'en_construction') }
|
||||
scope :state_en_instruction, -> { where(state: 'en_instruction') }
|
||||
scope :state_en_construction_ou_instruction, -> { where(state: EN_CONSTRUCTION_OU_INSTRUCTION) }
|
||||
scope :state_termine, -> { where(state: TERMINE) }
|
||||
|
||||
|
@ -55,7 +50,7 @@ class Dossier < ActiveRecord::Base
|
|||
scope :order_by_updated_at, -> (order = :desc) { order(updated_at: order) }
|
||||
|
||||
scope :all_state, -> { not_archived.state_not_brouillon }
|
||||
scope :nouveaux, -> { not_archived.state_nouveaux }
|
||||
scope :en_construction, -> { not_archived.state_en_construction }
|
||||
scope :en_instruction, -> { not_archived.state_en_instruction }
|
||||
scope :termine, -> { not_archived.state_termine }
|
||||
scope :downloadable_sorted, -> { state_not_brouillon.includes(:entreprise, :etablissement, :champs, :champs_private).order(en_construction_at: 'asc') }
|
||||
|
@ -144,18 +139,6 @@ class Dossier < ActiveRecord::Base
|
|||
champs.joins(', types_de_piece_justificative').where("pieces_justificatives.type_de_piece_justificative_id = types_de_piece_justificative.id AND types_de_piece_justificative.procedure_id = #{procedure.id}").order('order_place ASC')
|
||||
end
|
||||
|
||||
def brouillon?
|
||||
BROUILLON.include?(state)
|
||||
end
|
||||
|
||||
def en_construction?
|
||||
EN_CONSTRUCTION.include?(state)
|
||||
end
|
||||
|
||||
def en_instruction?
|
||||
EN_INSTRUCTION.include?(state)
|
||||
end
|
||||
|
||||
def en_construction_ou_instruction?
|
||||
EN_CONSTRUCTION_OU_INSTRUCTION.include?(state)
|
||||
end
|
||||
|
@ -347,7 +330,7 @@ class Dossier < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def send_dossier_received
|
||||
if state_changed? && EN_INSTRUCTION.include?(state)
|
||||
if state_changed? && en_instruction?
|
||||
NotificationMailer.send_dossier_received(id).deliver_later
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,7 +28,7 @@ class DossiersListGestionnaireService
|
|||
end
|
||||
|
||||
def nouveaux
|
||||
@nouveaux ||= filter_dossiers.nouveaux.order_by_updated_at('asc')
|
||||
@nouveaux ||= filter_dossiers.en_construction.order_by_updated_at('asc')
|
||||
end
|
||||
|
||||
def a_instruire
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
.count= current_gestionnaire.followed_dossiers.count
|
||||
.text SUIVIS
|
||||
.nouveaux-dossiers
|
||||
.count= current_gestionnaire.dossiers.nouveaux.count
|
||||
.count= current_gestionnaire.dossiers.en_construction.count
|
||||
.text NOUVEAUX
|
||||
.nouvelles-notifications
|
||||
.count= current_gestionnaire.dossiers_with_notifications_count
|
||||
|
@ -28,7 +28,7 @@
|
|||
= 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.nouveaux.count
|
||||
- total_new = procedure.dossiers.en_construction.count
|
||||
- if total_new > 0
|
||||
.badge.progress-bar-success{ title: 'Nouveaux dossiers' }
|
||||
= total_new
|
||||
|
|
Loading…
Reference in a new issue