Unscope the procedures on Gestionnaire and add #visible_procedures
This commit is contained in:
parent
948a29aea2
commit
ac6ba40598
3 changed files with 8 additions and 4 deletions
|
@ -6,7 +6,7 @@ module NewGestionnaire
|
||||||
ITEMS_PER_PAGE = 25
|
ITEMS_PER_PAGE = 25
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@procedures = current_gestionnaire.procedures.order(archived_at: :desc, published_at: :desc)
|
@procedures = current_gestionnaire.visible_procedures.order(archived_at: :desc, published_at: :desc)
|
||||||
|
|
||||||
dossiers = current_gestionnaire.dossiers
|
dossiers = current_gestionnaire.dossiers
|
||||||
@dossiers_count_per_procedure = dossiers.all_state.group(:procedure_id).reorder(nil).count
|
@dossiers_count_per_procedure = dossiers.all_state.group(:procedure_id).reorder(nil).count
|
||||||
|
@ -202,7 +202,7 @@ module NewGestionnaire
|
||||||
end
|
end
|
||||||
|
|
||||||
def redirect_to_avis_if_needed
|
def redirect_to_avis_if_needed
|
||||||
if current_gestionnaire.procedures.count == 0 && current_gestionnaire.avis.count > 0
|
if current_gestionnaire.visible_procedures.count == 0 && current_gestionnaire.avis.count > 0
|
||||||
redirect_to gestionnaire_avis_index_path
|
redirect_to gestionnaire_avis_index_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ class Gestionnaire < ActiveRecord::Base
|
||||||
has_and_belongs_to_many :administrateurs
|
has_and_belongs_to_many :administrateurs
|
||||||
|
|
||||||
has_many :assign_to, dependent: :destroy
|
has_many :assign_to, dependent: :destroy
|
||||||
has_many :procedures, -> { publiees_ou_archivees }, through: :assign_to
|
has_many :procedures, through: :assign_to
|
||||||
has_many :dossiers, -> { state_not_brouillon }, through: :procedures
|
has_many :dossiers, -> { state_not_brouillon }, through: :procedures
|
||||||
has_many :follows
|
has_many :follows
|
||||||
has_many :followed_dossiers, through: :follows, source: :dossier
|
has_many :followed_dossiers, through: :follows, source: :dossier
|
||||||
|
@ -14,6 +14,10 @@ class Gestionnaire < ActiveRecord::Base
|
||||||
|
|
||||||
include CredentialsSyncableConcern
|
include CredentialsSyncableConcern
|
||||||
|
|
||||||
|
def visible_procedures
|
||||||
|
procedures.publiees_ou_archivees
|
||||||
|
end
|
||||||
|
|
||||||
def procedure_filter
|
def procedure_filter
|
||||||
procedure_id = self[:procedure_filter]
|
procedure_id = self[:procedure_filter]
|
||||||
if procedures.find_by(id: procedure_id).present?
|
if procedures.find_by(id: procedure_id).present?
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
- if nav_bar_profile == :gestionnaire && gestionnaire_signed_in?
|
- if nav_bar_profile == :gestionnaire && gestionnaire_signed_in?
|
||||||
- current_url = request.path_info
|
- current_url = request.path_info
|
||||||
%ul.header-tabs
|
%ul.header-tabs
|
||||||
- if current_gestionnaire.procedures.count > 0
|
- if current_gestionnaire.visible_procedures.count > 0
|
||||||
%li
|
%li
|
||||||
= link_to "Procédures", gestionnaire_procedures_path, class: (controller_name != 'avis') ? "tab-link active" : 'tab-link'
|
= link_to "Procédures", gestionnaire_procedures_path, class: (controller_name != 'avis') ? "tab-link active" : 'tab-link'
|
||||||
- if current_gestionnaire.avis.count > 0
|
- if current_gestionnaire.avis.count > 0
|
||||||
|
|
Loading…
Reference in a new issue