Skip to content

Commit

Permalink
add correct action for instructeur
Browse files Browse the repository at this point in the history
  • Loading branch information
lisa-durand committed Jun 11, 2024
1 parent a163d1c commit 51dfcd3
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 4 deletions.
4 changes: 4 additions & 0 deletions app/models/dossier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,10 @@ def extend_conservation(conservation_extension)
brouillon_close_to_expiration_notice_sent_at: nil,
en_construction_close_to_expiration_notice_sent_at: nil,
termine_close_to_expiration_notice_sent_at: nil)

if hidden_at.present?
update(hidden_at: nil, hidden_by_reason: nil)
end
end

def show_procedure_state_warning?
Expand Down
8 changes: 5 additions & 3 deletions app/services/dossier_projection_service.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class DossierProjectionService
class DossierProjection < Struct.new(:dossier_id, :state, :archived, :hidden_by_user_at, :hidden_by_administration_at, :for_tiers, :prenom, :nom, :batch_operation_id, :sva_svr_decision_on, :corrections, :columns) do
class DossierProjection < Struct.new(:dossier_id, :state, :archived, :hidden_by_user_at, :hidden_by_administration_at, :hidden_at, :for_tiers, :prenom, :nom, :batch_operation_id, :sva_svr_decision_on, :corrections, :columns) do
def pending_correction?
return false if corrections.blank?

Expand Down Expand Up @@ -44,13 +44,14 @@ def self.project(dossiers_ids, fields)
batch_operation_field = { TABLE => 'self', COLUMN => 'batch_operation_id' }
hidden_by_user_at_field = { TABLE => 'self', COLUMN => 'hidden_by_user_at' }
hidden_by_administration_at_field = { TABLE => 'self', COLUMN => 'hidden_by_administration_at' }
hidden_at_field = { TABLE => 'self', COLUMN => 'hidden_at' }
for_tiers_field = { TABLE => 'self', COLUMN => 'for_tiers' }
individual_first_name = { TABLE => 'individual', COLUMN => 'prenom' }
individual_last_name = { TABLE => 'individual', COLUMN => 'nom' }
sva_svr_decision_on_field = { TABLE => 'self', COLUMN => 'sva_svr_decision_on' }
dossier_corrections = { TABLE => 'dossier_corrections', COLUMN => 'resolved_at' }
champ_value = champ_value_formatter(dossiers_ids, fields)
([state_field, archived_field, sva_svr_decision_on_field, hidden_by_user_at_field, hidden_by_administration_at_field, for_tiers_field, individual_first_name, individual_last_name, batch_operation_field, dossier_corrections] + fields) # the view needs state and archived dossier attributes
([state_field, archived_field, sva_svr_decision_on_field, hidden_by_user_at_field, hidden_by_administration_at_field, hidden_at_field, for_tiers_field, individual_first_name, individual_last_name, batch_operation_field, dossier_corrections] + fields)
.each { |f| f[:id_value_h] = {} }
.group_by { |f| f[TABLE] } # one query per table
.each do |table, fields|
Expand All @@ -73,7 +74,7 @@ def self.project(dossiers_ids, fields)
.pluck(:id, *fields.map { |f| f[COLUMN].to_sym })
.each do |id, *columns|
fields.zip(columns).each do |field, value|
if [state_field, archived_field, hidden_by_user_at_field, hidden_by_administration_at_field, for_tiers_field, batch_operation_field, sva_svr_decision_on_field].include?(field)
if [state_field, archived_field, hidden_by_user_at_field, hidden_by_administration_at_field, hidden_at_field, for_tiers_field, batch_operation_field, sva_svr_decision_on_field].include?(field)
field[:id_value_h][id] = value
else
field[:id_value_h][id] = value&.strftime('%d/%m/%Y') # other fields are datetime
Expand Down Expand Up @@ -150,6 +151,7 @@ def self.project(dossiers_ids, fields)
archived_field[:id_value_h][dossier_id],
hidden_by_user_at_field[:id_value_h][dossier_id],
hidden_by_administration_at_field[:id_value_h][dossier_id],
hidden_at_field[:id_value_h][dossier_id],
for_tiers_field[:id_value_h][dossier_id],
individual_first_name[:id_value_h][dossier_id],
individual_last_name[:id_value_h][dossier_id],
Expand Down
1 change: 1 addition & 0 deletions app/views/instructeurs/dossiers/_header_actions.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
dossier_is_followed: current_instructeur&.follow?(dossier),
close_to_expiration: dossier.close_to_expiration?,
hidden_by_administration: dossier.hidden_by_administration?,
hidden_at: dossier.hidden_at.present?,
has_pending_correction: dossier.pending_correction?,
has_blocking_pending_correction: dossier.procedure.feature_enabled?(:blocking_pending_correction) && dossier.pending_correction?,
turbo: true,
Expand Down
8 changes: 7 additions & 1 deletion app/views/instructeurs/procedures/_dossier_actions.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
- if hidden_by_administration
- if hidden_by_administration && hidden_at
%li
= button_to repousser_expiration_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, class: "fr-btn fr-icon-refresh-line" do
= t('views.instructeurs.dossiers.restore_and_extend')

- elsif hidden_by_administration
%li
= button_to restore_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, class: "fr-btn fr-icon-refresh-line" do
= t('views.instructeurs.dossiers.restore')

- elsif close_to_expiration || Dossier::TERMINE.include?(state)
%li
- if close_to_expiration
Expand Down
1 change: 1 addition & 0 deletions app/views/instructeurs/procedures/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id),
close_to_expiration: @statut == 'expirant',
hidden_by_administration: @statut == 'supprimes_recemment',
hidden_at: p.hidden_at.present?,
sva_svr: @procedure.sva_svr_enabled?,
has_blocking_pending_correction: @procedure.feature_enabled?(:blocking_pending_correction) && p.pending_correction?,
turbo: false,
Expand Down
1 change: 1 addition & 0 deletions app/views/recherche/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id),
close_to_expiration: nil,
hidden_by_administration: nil,
hidden_at: nil,
sva_svr: p.sva_svr_decision_on.present?,
has_blocking_pending_correction: p.pending_correction? && Flipper.enabled?(:blocking_pending_correction, ProcedureFlipperActor.new(procedure_id)),
turbo: false,
Expand Down
1 change: 1 addition & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ fr:
acts_on_behalf: "agit pour"
deleted_by_administration: "Dossier supprimé par l’administration"
restore: "Restaurer"
restore_and_extend: "Restaurer et étendre la conservation"
filters:
title: Sélectionner un filtre
select_all: Tout selectionner
Expand Down

0 comments on commit 51dfcd3

Please sign in to comment.