Merge pull request #9252 from colinux/fix-demande-updated-at

ETQ usager/instructeur: fix date de modification du dossier
This commit is contained in:
Colin Darie 2023-06-28 08:46:39 +00:00 committed by GitHub
commit 67999af679
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 68 additions and 25 deletions

View file

@ -2,6 +2,7 @@ class Dossiers::ChampRowShowComponent < ApplicationComponent
include ChampHelper
include DossierHelper
include ApplicationHelper
def initialize(champs:, demande_seen_at:, profile:, repetition:)
@repetition = repetition
@champs = champs
@ -11,6 +12,7 @@ class Dossiers::ChampRowShowComponent < ApplicationComponent
def updated_after_deposer?(champ)
return false if champ.dossier.depose_at.blank?
champ.updated_at > champ.dossier.depose_at
end
@ -18,4 +20,12 @@ class Dossiers::ChampRowShowComponent < ApplicationComponent
# we are using the span delimiter that doesn't insert spaces when copying and pasting the number
number_with_delimiter(num, delimiter: tag.span(class: 'numbers-delimiter'))
end
def blank_key(champ)
key = ".blank"
key += "_optional" if @profile == "usager"
key += "_attachment" if champ.type_de_champ.piece_justificative?
key
end
end

View file

@ -1,3 +1,6 @@
---
en:
blank: "blank (optional)"
blank: "empty"
blank_attachment: "document not supplied"
blank_optional: "empty (optional)"
blank_optional_attachment: "document not supplied (optional)"

View file

@ -1,3 +1,6 @@
---
fr:
blank: "non saisi (facultatif)"
blank: "non saisi"
blank_attachment: "pièce justificative non saisie"
blank_optional: "non saisi (facultatif)"
blank_optional_attachment: "pièce justificative non saisie (facultative)"

View file

@ -14,10 +14,10 @@
%span{ class: highlight_if_unseen_class(@demande_seen_at, champ.updated_at) }
= t(:updated_at, scope: [:views, :shared, :dossiers, :form], datetime: try_format_datetime(champ.updated_at))
- if champ.blank? && ![TypeDeChamp.type_champs.fetch(:piece_justificative), TypeDeChamp.type_champs.fetch(:titre_identite)].include?(champ.type_champ)
- if champ.blank?
.champ-content.fr-text-mention--grey{ class: [highlight_if_unseen_class(@demande_seen_at, champ.updated_at), champ.type_champ] }
%p
%em= t('.blank')
%em= t(blank_key(champ))
- else
.champ-content{ class: [highlight_if_unseen_class(@demande_seen_at, champ.updated_at), champ.type_champ] }
- case champ.type_champ

View file

@ -43,6 +43,10 @@ class Champs::PieceJustificativeChamp < Champ
mandatory? && !piece_justificative_file.attached?
end
def blank?
piece_justificative_file.blank?
end
def for_export
piece_justificative_file.map { _1.filename.to_s }.join(', ')
end

View file

@ -37,6 +37,10 @@ class Champs::TitreIdentiteChamp < Champ
mandatory? && !piece_justificative_file.attached?
end
def blank?
piece_justificative_file.blank?
end
def for_export
piece_justificative_file.attached? ? "présent" : "absent"
end

View file

@ -1,8 +1,4 @@
- pj = champ.piece_justificative_file
- if pj.attached?
.fr-downloads-group
%ul
- pj.attachments.each do |attachment|
- champ.piece_justificative_file.attachments.each do |attachment|
%li= render Attachment::ShowComponent.new(attachment:, new_tab: true)
- else
Pièce justificative non fournie

View file

@ -1,28 +1,29 @@
%div
%p.fr-my-2w.fr-px-4v
.fr-px-2w
%p.fr-my-2w
= t(:submitted_at, scope: [:views, :shared, :dossiers, :form], datetime: l(dossier.depose_at))
%br
- if dossier.updated_at != dossier.depose_at
= t(:updated_at, scope: [:views, :shared, :dossiers, :form], datetime: l(dossier.updated_at))
- if dossier.last_champ_updated_at.present? && dossier.last_champ_updated_at > dossier.depose_at
= t(:updated_at, scope: [:views, :shared, :dossiers, :form], datetime: l(dossier.last_champ_updated_at))
- if dossier.justificatif_motivation.attached?
.fr-my-4v.fr-px-4v
-# download component already has margin bottom
%div
%p.champ-label Justificatif :
.champ-content.fr-text-action-high--grey
.champ-content
.action
= render Attachment::ShowComponent.new(attachment: dossier.justificatif_motivation.attachment)
- if dossier.motivation.present?
.fr-my-4v.fr-px-4v
.fr-mb-2w
%p.champ-label Motivation :
.champ-content.fr-text-action-high--grey
.champ-content
.action
= dossier.motivation
- if dossier.attestation.present?
.fr-my-4v.fr-px-4v
.fr-mb-2w
%p.champ-label Attestation :
.champ-content.fr-text-action-high--grey
.champ-content
.action
= link_to('Voir lattestation', attestation_instructeur_dossier_path(dossier.procedure, dossier), target: '_blank', rel: 'noopener')

View file

@ -1,14 +1,18 @@
describe 'shared/dossiers/champs', type: :view do
let(:instructeur) { create(:instructeur) }
let(:demande_seen_at) { nil }
let(:profile) { "instructeur" }
before do
view.extend DossierHelper
view.extend DossierLinkHelper
if profile == "instructeur"
allow(view).to receive(:current_instructeur).and_return(instructeur)
end
end
subject { render 'shared/dossiers/champs', champs: champs, dossier: dossier, demande_seen_at: demande_seen_at, profile: nil }
subject { render 'shared/dossiers/champs', champs:, dossier:, demande_seen_at:, profile: }
context "there are some champs" do
let(:dossier) { create(:dossier) }
@ -108,8 +112,26 @@ describe 'shared/dossiers/champs', type: :view do
let(:champ) { create(:champ_dossier_link, dossier: dossier, value: nil) }
let(:champs) { [champ] }
it { is_expected.to include("non saisi") }
context 'when profile is usager' do
let(:profile) { "usager" }
it { is_expected.to include("non saisi (facultatif)") }
end
end
context "with a piece justificative without value" do
let(:dossier) { create(:dossier) }
let(:champ) { create(:champ_without_piece_justificative, dossier:) }
let(:champs) { [champ] }
it { is_expected.to include("pièce justificative non saisie") }
context 'when profile is usager' do
let(:profile) { "usager" }
it { is_expected.to include("pièce justificative non saisie (facultative)") }
end
end
context "with seen_at" do
let(:dossier) { create(:dossier) }