display sva date and possibility to order in instructeur table

This commit is contained in:
Lisa Durand 2023-06-07 17:25:41 +02:00 committed by Colin Darie
parent d7b0b1c01f
commit e43eea7fcf
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
9 changed files with 57 additions and 3 deletions

View file

@ -45,6 +45,7 @@ class ProcedurePresentation < ApplicationRecord
field_hash('self', 'en_construction_at', type: :date),
field_hash('self', 'en_instruction_at', type: :date),
field_hash('self', 'processed_at', type: :date),
field_hash('self', 'sva_svr_decision_on', type: :date),
field_hash('self', 'updated_since', type: :date, virtual: true),
field_hash('self', 'depose_since', type: :date, virtual: true),
field_hash('self', 'en_construction_since', type: :date, virtual: true),
@ -118,11 +119,15 @@ class ProcedurePresentation < ApplicationRecord
end
def displayed_fields_for_headers
[
array = [
field_hash('self', 'id', classname: 'number-col'),
*displayed_fields,
field_hash('self', 'state', classname: 'state-col')
]
array << field_hash('self', 'sva_svr_decision_on', classname: 'sva-col') if procedure.sva_svr_enabled?
array
end
def sorted_ids(dossiers, count)

View file

@ -1,5 +1,5 @@
class DossierProjectionService
class DossierProjection < Struct.new(:dossier_id, :state, :archived, :hidden_by_user_at, :hidden_by_administration_at, :batch_operation_id, :corrections, :columns) do
class DossierProjection < Struct.new(:dossier_id, :state, :archived, :hidden_by_user_at, :hidden_by_administration_at, :batch_operation_id, :sva_svr_decision_on, :corrections, :columns) do
def pending_correction?
return false if corrections.blank?
@ -29,8 +29,9 @@ class DossierProjectionService
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' }
sva_svr_decision_on_field = { TABLE => 'self', COLUMN => 'sva_svr_decision_on' }
dossier_corrections = { TABLE => 'dossier_corrections', COLUMN => 'resolved_at' }
([state_field, archived_field, hidden_by_user_at_field, hidden_by_administration_at_field, 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, batch_operation_field, dossier_corrections] + fields) # the view needs state and archived dossier attributes
.each { |f| f[:id_value_h] = {} }
.group_by { |f| f[TABLE] } # one query per table
.each do |table, fields|
@ -130,6 +131,7 @@ class DossierProjectionService
hidden_by_user_at_field[:id_value_h][dossier_id],
hidden_by_administration_at_field[:id_value_h][dossier_id],
batch_operation_field[:id_value_h][dossier_id],
sva_svr_decision_on_field[:id_value_h][dossier_id],
dossier_corrections[:id_value_h][dossier_id],
fields.map { |f| f[:id_value_h][dossier_id] }
)

View file

@ -174,6 +174,18 @@
- status << pending_correction_badge(:for_instructeur, html_class: "fr-mt-1v") if p.pending_correction?
= link_to_if(p.hidden_by_administration_at.blank?, safe_join(status), path, class: class_names("cell-link": true, "fr-py-0": status.many?))
- if @procedure.sva?
%td
- if p.hidden_by_administration_at.present?
%span.cell-link
.fr-badge.fr-badge--info.fr-badge--sm
= t('views.instructeurs.dossiers.sva_svr_decision_on', time_ago: time_ago_in_words(p.sva_svr_decision_on))
- else
%a.cell-link{ href: path }
.fr-badge.fr-badge--info.fr-badge--sm
= t('views.instructeurs.dossiers.sva_svr_decision_on', time_ago: time_ago_in_words(p.sva_svr_decision_on))
%td.action-col.follow-col
%ul.inline.fr-btns-group.fr-btns-group--sm.fr-btns-group--inline.fr-btns-group--icon-right
= render partial: 'instructeurs/procedures/dossier_actions', locals: { procedure_id: @procedure.id,

View file

@ -387,6 +387,7 @@ en:
stop_follow: No longer follow
no_file: No file
dossier_synthesis: Summary of files
sva_svr_decision_on: "%{time_ago} left"
avis:
introduction_file_explaination: "File attached to the request for advice"
search:

View file

@ -389,6 +389,7 @@ fr:
save: Enregistrer
no_file: Aucun dossier
dossier_synthesis: Synthèse des dossiers
sva_svr_decision_on: "%{time_ago} restant(s)"
avis:
introduction_file_explaination: "Fichier joint à la demande davis"
search:

View file

@ -17,6 +17,7 @@ en:
en_construction_since: Submitted since
en_instruction_since: Instructed since
processed_since: Finished since
sva_svr_decision_on: SVA decision on
user:
email: Requester
followers_instructeurs:

View file

@ -17,6 +17,7 @@ fr:
en_construction_since: En construction depuis
en_instruction_since: En instruction depuis
processed_since: Terminé depuis
sva_svr_decision_on: SVA date de décision
user:
email: Demandeur
followers_instructeurs:

View file

@ -21,6 +21,15 @@ describe "procedure filters" do
end
end
scenario "should display sva by default if procedure has sva enabled" do
procedure.update!(sva_svr: SVASVRConfiguration.new(decision: :sva).attributes)
visit instructeur_procedure_path(procedure)
within ".dossiers-table" do
expect(page).to have_link("SVA date de décision")
expect(page).to have_link(new_unfollow_dossier.user.email)
end
end
scenario "should list all dossiers" do
within ".dossiers-table" do
expect(page).to have_link(new_unfollow_dossier.id.to_s)

View file

@ -31,6 +31,28 @@ describe "procedure sort", js: true do
expect(find(".dossiers-table tbody tr:nth-child(3) .number-col a").text).to eq(followed_dossier.id.to_s)
end
scenario "should be able to sort with header with sva date" do
procedure.update!(sva_svr: SVASVRConfiguration.new(decision: :sva).attributes)
followed_dossier_2.update!(sva_svr_decision_on: Date.tomorrow)
followed_dossier.update!(sva_svr_decision_on: Date.today)
visit instructeur_procedure_path(procedure, statut: "suivis")
# sorted by notifications (updated_at desc) by default, filtered by followed
expect(all(".dossiers-table tbody tr").count).to eq(3)
expect(find(".dossiers-table tbody tr:nth-child(2) .number-col a").text).to eq(followed_dossier.id.to_s)
expect(find(".dossiers-table tbody tr:nth-child(3) .number-col a").text).to eq(followed_dossier_2.id.to_s)
find("thead .sva-col a").click # sort by sva date asc
expect(find(".dossiers-table tbody tr:nth-child(2) .number-col a").text).to eq(followed_dossier.id.to_s)
expect(find(".dossiers-table tbody tr:nth-child(3) .number-col a").text).to eq(followed_dossier_2.id.to_s)
find("thead .sva-col a").click # reverse order - sort by sva date desc
expect(find(".dossiers-table tbody tr:nth-child(2) .number-col a").text).to eq(followed_dossier_2.id.to_s)
expect(find(".dossiers-table tbody tr:nth-child(3) .number-col a").text).to eq(followed_dossier.id.to_s)
end
scenario "should be able to sort with direct link to notification sort" do
# the real input checkbox is hidden - DSFR set a fake checkbox with a label, so we can't use "check/uncheck" methods
# but we can assert on the hidden checkbox state