feat(sva): instructeurs dashboard sva/svr colonnes with multiple use cases

This commit is contained in:
Colin Darie 2023-06-07 19:11:37 +02:00
parent e43eea7fcf
commit f1504e9724
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
11 changed files with 83 additions and 16 deletions

View file

@ -0,0 +1,46 @@
# frozen_string_literal: true
class Instructeurs::SVASVRDecisionBadgeComponent < ApplicationComponent
attr_reader :object
def initialize(projection_or_dossier:, decision:)
@object = projection_or_dossier
@decision = decision.to_sym
end
def render?
[:en_construction, :en_instruction].include? object.state.to_sym
end
def without_date?
object.sva_svr_decision_on.nil?
end
def classes
class_names(
'fr-badge fr-badge--sm': true,
'fr-badge--warning': soon?,
'fr-badge--info': !soon?
)
end
def soon?
object.sva_svr_decision_on < 7.days.from_now.to_date
end
def pending_correction?
object.pending_correction?
end
def days_count
(object.sva_svr_decision_on - Date.current).to_i
end
def sva?
@decision == :sva
end
def svr?
@decision == :svr
end
end

View file

@ -0,0 +1,10 @@
---
en:
no_sva: Submitted before SVA
no_svr: Submitted before SVR
in_days:
zero: Today
one: Tomorrow
other: in %{count} days
remaining_days_after_correction:
other: "%{count} d. after correction"

View file

@ -0,0 +1,10 @@
---
fr:
no_sva: Déposé avant SVA
no_svr: Déposé avant SVR
in_days:
zero: Aujourdhui
one: Demain
other: dans %{count} jours
remaining_days_after_correction:
other: "%{count} j. après correction"

View file

@ -0,0 +1,10 @@
- if without_date?
%span.fr-badge.fr-badge--sm
= t(sva? ? '.no_sva' : '.no_svr')
- else
%span{ class: classes }
- if pending_correction?
= t('.remaining_days_after_correction', count: days_count)
- else
= t('.in_days', count: days_count)

View file

@ -55,7 +55,7 @@ class DossierProjectionService
.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, batch_operation_field].include?(field)
if [state_field, archived_field, hidden_by_user_at_field, hidden_by_administration_at_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

View file

@ -174,17 +174,10 @@
- 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?
- if @procedure.sva_svr_enabled?
%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))
%span.cell-link
= link_to_if p.hidden_by_administration_at.blank?, render(Instructeurs::SVASVRDecisionBadgeComponent.new(projection_or_dossier: p, decision: @procedure.sva_svr_configuration.decision), path)
%td.action-col.follow-col
%ul.inline.fr-btns-group.fr-btns-group--sm.fr-btns-group--inline.fr-btns-group--icon-right

View file

@ -387,7 +387,6 @@ 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,7 +389,6 @@ 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,7 +17,7 @@ en:
en_construction_since: Submitted since
en_instruction_since: Instructed since
processed_since: Finished since
sva_svr_decision_on: SVA decision on
sva_svr_decision_on: SVA decision
user:
email: Requester
followers_instructeurs:

View file

@ -17,7 +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
sva_svr_decision_on: Décision SVA
user:
email: Demandeur
followers_instructeurs:

View file

@ -25,7 +25,7 @@ describe "procedure filters" 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("Décision SVA")
expect(page).to have_link(new_unfollow_dossier.user.email)
end
end