From 07f10070e9163cdb6234df0379f80d866160a948 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Wed, 21 Jun 2023 12:37:21 +0200 Subject: [PATCH] fix(sva): disable svr configuration since until implementation --- app/components/dsfr/radio_button_list_component.rb | 6 ++++++ .../radio_button_list_component.html.haml | 10 +++++++--- app/components/procedure/sva_svr_form_component.rb | 4 ++-- app/models/sva_svr_configuration.rb | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/components/dsfr/radio_button_list_component.rb b/app/components/dsfr/radio_button_list_component.rb index 9c1d7fa2b..fc67c3625 100644 --- a/app/components/dsfr/radio_button_list_component.rb +++ b/app/components/dsfr/radio_button_list_component.rb @@ -13,4 +13,10 @@ class Dsfr::RadioButtonListComponent < ApplicationComponent # https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/bouton-radio/ @error.present? end + + def each_button + @buttons.each do |button| + yield(*button.values_at(:label, :value, :hint), **button.except(:label, :value, :hint)) + end + end end diff --git a/app/components/dsfr/radio_button_list_component/radio_button_list_component.html.haml b/app/components/dsfr/radio_button_list_component/radio_button_list_component.html.haml index fa5bebdee..8776b11af 100644 --- a/app/components/dsfr/radio_button_list_component/radio_button_list_component.html.haml +++ b/app/components/dsfr/radio_button_list_component/radio_button_list_component.html.haml @@ -2,14 +2,18 @@ %legend.fr-fieldset__legend--regular.fr-fieldset__legend = content - - @buttons.map { _1.values_at(:label, :value, :hint) }.each do |label, value, hint| + - each_button do |label, value, hint, **button_options| .fr-fieldset__element .fr-radio-group - = @form.radio_button @target, value + = @form.radio_button @target, value, **button_options = @form.label @target, value: value, class: 'fr-label' do - capture do = label - %span.fr-hint-text= hint + + = button_options[:after_label] if button_options[:after_label] + + %span.fr-hint-text= hint if hint + .fr-messages-group{ 'aria-live': 'assertive' } - if error? %p.fr-message.fr-message--error= error diff --git a/app/components/procedure/sva_svr_form_component.rb b/app/components/procedure/sva_svr_form_component.rb index ee39138fa..d7ae1cfe4 100644 --- a/app/components/procedure/sva_svr_form_component.rb +++ b/app/components/procedure/sva_svr_form_component.rb @@ -18,9 +18,9 @@ class Procedure::SVASVRFormComponent < ApplicationComponent scope = ".decision_buttons" [ - { label: t("disabled", scope:), value: "disabled" }, + { label: t("disabled", scope:), value: "disabled", disabled: form_disabled? }, { label: t("sva", scope:), value: "sva", hint: t("sva_hint", scope:) }, - { label: t("svr", scope:), value: "svr", hint: t("svr_hint", scope:) } + { label: t("svr", scope:), value: "svr", hint: t("svr_hint", scope:), disabled: true, after_label: tag.span("Disponible prochainement", class: "fr-badge fr-badge--sm fr-ml-1w") } ] end diff --git a/app/models/sva_svr_configuration.rb b/app/models/sva_svr_configuration.rb index 62af13fa7..038aa9c01 100644 --- a/app/models/sva_svr_configuration.rb +++ b/app/models/sva_svr_configuration.rb @@ -11,7 +11,7 @@ class SVASVRConfiguration UNIT_OPTIONS = ['days', 'weeks', 'months'] RESUME_OPTIONS = ['continue', 'reset'] - validates :decision, inclusion: { in: DECISION_OPTIONS } + validates :decision, inclusion: { in: DECISION_OPTIONS.without('svr') } validates :period, presence: true, numericality: { only_integer: true }, if: -> { enabled? } validates :unit, presence: true, inclusion: { in: UNIT_OPTIONS }, if: -> { enabled? } validates :resume, presence: true, inclusion: { in: RESUME_OPTIONS }, if: -> { enabled? }