refactor(message): badges à corriger/en attente/corrigé when related to a correction

This commit is contained in:
Colin Darie 2023-06-02 15:46:23 +02:00
parent 52c8553576
commit 7f871728c7
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
7 changed files with 48 additions and 2 deletions

View file

@ -8,6 +8,13 @@ class Dossiers::MessageComponent < ApplicationComponent
attr_reader :commentaire, :connected_user, :messagerie_seen_at
def correction_badge
return if commentaire.dossier_correction.nil?
return helpers.correction_resolved_badge if commentaire.dossier_correction.resolved?
helpers.pending_correction_badge(connected_user.is_a?(Instructeur) ? :for_instructeur : :for_user)
end
private
def show_reply_button?

View file

@ -6,8 +6,9 @@
= commentaire_issuer
- if commentaire_from_guest?
%span.fr-text--xs.fr-text-mention--grey.font-weight-normal= t('.guest')
- if commentaire.flagged_pending_correction?
= helpers.pending_correction_badge(connected_user.is_a?(Instructeur) ? :for_instructeur : :for_user)
= correction_badge
%span.date{ class: ["fr-text--xs", "fr-text-mention--grey", "font-weight-normal", highlight_if_unseen_class], data: scroll_to_target }
= commentaire_date
.rich-text

View file

@ -98,6 +98,10 @@ module DossierHelper
tag.span(Dossier.human_attribute_name("pending_correction.#{for_profile}"), class: ['fr-badge fr-badge--sm fr-badge--warning super', html_class], role: 'status')
end
def correction_resolved_badge
tag.span(Dossier.human_attribute_name("pending_correction.resolved"), class: ['fr-badge fr-badge--sm fr-badge--success super'], role: 'status')
end
def demandeur_dossier(dossier)
if dossier.procedure.for_individual?
"#{dossier&.individual&.nom} #{dossier&.individual&.prenom}"

View file

@ -16,4 +16,8 @@ class DossierCorrection < ApplicationRecord
validates_associated :commentaire
scope :pending, -> { where(resolved_at: nil) }
def resolved?
resolved_at.present?
end
end