From 786bc64d85e5e028a36e625e5390b9851c14e350 Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Thu, 8 Jun 2023 15:07:43 +0200 Subject: [PATCH] feat(sva): add sva badge on page dossier for instructeur --- app/assets/stylesheets/badges.scss | 12 ++++++++++++ .../instructeurs/sva_svr_decision_badge_component.rb | 8 +++++++- .../sva_svr_decision_badge_component.html.haml | 3 ++- app/helpers/procedure_helper.rb | 2 +- .../instructeurs/dossiers/_header_top.html.haml | 12 ++++++++---- 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/badges.scss b/app/assets/stylesheets/badges.scss index 26bb9ce4e..e7ea9ba54 100644 --- a/app/assets/stylesheets/badges.scss +++ b/app/assets/stylesheets/badges.scss @@ -29,3 +29,15 @@ vertical-align: baseline; } } + +.badge-group { + display: flex; + + .fr-badge { + margin-right: $default-spacer; + } + + .fr-badge:last-child { + margin-right: 0; + } +} diff --git a/app/components/instructeurs/sva_svr_decision_badge_component.rb b/app/components/instructeurs/sva_svr_decision_badge_component.rb index 6f001d01d..460be1953 100644 --- a/app/components/instructeurs/sva_svr_decision_badge_component.rb +++ b/app/components/instructeurs/sva_svr_decision_badge_component.rb @@ -2,10 +2,12 @@ class Instructeurs::SVASVRDecisionBadgeComponent < ApplicationComponent attr_reader :object + attr_reader :with_label - def initialize(projection_or_dossier:, decision:) + def initialize(projection_or_dossier:, decision:, with_label: false) @object = projection_or_dossier @decision = decision.to_sym + @with_label = with_label end def render? @@ -43,4 +45,8 @@ class Instructeurs::SVASVRDecisionBadgeComponent < ApplicationComponent def svr? @decision == :svr end + + def label_for_badge + sva? ? "SVA :" : "SVR :" + end end diff --git a/app/components/instructeurs/sva_svr_decision_badge_component/sva_svr_decision_badge_component.html.haml b/app/components/instructeurs/sva_svr_decision_badge_component/sva_svr_decision_badge_component.html.haml index bc987c4fd..76511ad4e 100644 --- a/app/components/instructeurs/sva_svr_decision_badge_component/sva_svr_decision_badge_component.html.haml +++ b/app/components/instructeurs/sva_svr_decision_badge_component/sva_svr_decision_badge_component.html.haml @@ -3,8 +3,9 @@ = t(sva? ? '.no_sva' : '.no_svr') - else %span{ class: classes } + - if with_label.present? + = label_for_badge - if pending_correction? = t('.remaining_days_after_correction', count: days_count) - else = t('.in_days', count: days_count) - diff --git a/app/helpers/procedure_helper.rb b/app/helpers/procedure_helper.rb index 993b8bb08..2f9e5b76f 100644 --- a/app/helpers/procedure_helper.rb +++ b/app/helpers/procedure_helper.rb @@ -8,7 +8,7 @@ module ProcedureHelper def procedure_badge(procedure) return nil unless procedure.brouillon? - tag.span(t('helpers.procedure.testing_procedure'), class: 'fr-badge') + tag.span(t('helpers.procedure.testing_procedure'), class: 'fr-badge fr-badge--sm') end def procedure_publish_label(procedure, key) diff --git a/app/views/instructeurs/dossiers/_header_top.html.haml b/app/views/instructeurs/dossiers/_header_top.html.haml index ca3b04a88..886473b43 100644 --- a/app/views/instructeurs/dossiers/_header_top.html.haml +++ b/app/views/instructeurs/dossiers/_header_top.html.haml @@ -4,11 +4,15 @@ %h1.fr-h3.fr-mb-1w = "Dossier nº #{dossier.id}" - = status_badge(dossier.state, 'super') - = pending_correction_badge(:for_instructeur) if dossier.pending_correction? - = link_to dossier.procedure.libelle.truncate_words(10), instructeur_procedure_path(dossier.procedure), title: dossier.procedure.libelle, class: "fr-link" - = procedure_badge(dossier.procedure) + .fr-mt-2w.badge-group + = procedure_badge(dossier.procedure) + + = status_badge(dossier.state) + = pending_correction_badge(:for_instructeur) if dossier.pending_correction? + = render Instructeurs::SVASVRDecisionBadgeComponent.new(projection_or_dossier: dossier, decision: dossier.procedure.sva_svr_configuration.decision, with_label: true) + + .header-actions.fr-ml-auto = render partial: 'instructeurs/dossiers/header_actions', locals: { dossier: }