From e018d2975d26bd9dd970c2cc2d70ec0dbbab72ba Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 8 Dec 2022 16:07:06 +0100 Subject: [PATCH] =?UTF-8?q?amelioration(administrateur/carte-email):=20la?= =?UTF-8?q?=20carte=20des=20emails=20affichait=20toujours=20'A=20configure?= =?UTF-8?q?r'.=20Desormais=20si=20les=205=20mail=20configurable=20on=20ete?= =?UTF-8?q?=20modifi=C3=A9s,=20on=20affiche=20'Valid=C3=A9'=20+=20on=20aff?= =?UTF-8?q?iche=20le=20nombre=20de=20mail=20personnalis=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../procedure/card/emails_component.rb | 20 +++++++++++++++++++ .../emails_component.html.haml | 8 +++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/app/components/procedure/card/emails_component.rb b/app/components/procedure/card/emails_component.rb index e773ceb66..60d5dd31b 100644 --- a/app/components/procedure/card/emails_component.rb +++ b/app/components/procedure/card/emails_component.rb @@ -1,8 +1,18 @@ class Procedure::Card::EmailsComponent < ApplicationComponent + CUSTOMIZABLE_COUNT = 5 + def initialize(procedure:) @procedure = procedure end + def customized_progress + "#{customized_count} / #{CUSTOMIZABLE_COUNT}" + end + + def fully_customized? + customized_count == CUSTOMIZABLE_COUNT + end + private def error_messages @@ -14,4 +24,14 @@ class Procedure::Card::EmailsComponent < ApplicationComponent @procedure.errors.messages_for(:without_continuation_mail) ].flatten.to_sentence end + + def customized_count + [ + @procedure.initiated_mail, + @procedure.received_mail, + @procedure.closed_mail, + @procedure.refused_mail, + @procedure.without_continuation_mail + ].map { |mail| mail&.updated_at }.compact.size + end end diff --git a/app/components/procedure/card/emails_component/emails_component.html.haml b/app/components/procedure/card/emails_component/emails_component.html.haml index a81399470..5918224ba 100644 --- a/app/components/procedure/card/emails_component/emails_component.html.haml +++ b/app/components/procedure/card/emails_component/emails_component.html.haml @@ -5,10 +5,16 @@ - if error_messages.present? %span.icon.refuse %p.fr-tile-status-error À modifier + - elsif fully_customized? + %span.icon.accept + %p.fr-tile-status-todo Validé - else %span.icon.clock %p.fr-tile-status-todo À configurer %div - %h3.fr-h6.fr-mt-10v= t('.title') + .line-count.fr-my-1w + %p.fr-tag= customized_progress + + %h3.fr-h6= t('.title') %p.fr-tile-subtitle Notifications automatiques %p.fr-btn.fr-btn--tertiary= t('views.shared.actions.edit')