Browse Source

extract displaying of the informative text into a helper

pull/338/head
Kat 3 years ago committed by MadeTech Dushan
parent
commit
4c2f3e0a48
  1. 7
      app/helpers/interuption_screen_helper.rb
  2. 3
      app/views/form/_interruption_screen_question.html.erb

7
app/helpers/interuption_screen_helper.rb

@ -0,0 +1,7 @@
module InteruptionScreenHelper
def display_informative_text(informative_text, case_log)
translation_question = informative_text["argument"].map { |x| case_log.form.get_question(x) }
translation = I18n.t(informative_text["translation"], informative_text["argument"][0].to_sym => translation_question[0].answer_label(case_log), informative_text["argument"][1].to_sym => translation_question[1].answer_label(case_log))
"<span>#{translation}</span>".html_safe
end
end

3
app/views/form/_interruption_screen_question.html.erb

@ -2,8 +2,7 @@
title_text: title_text,
classes: 'app-panel--interruption',
) do %>
<% translation_question = informative_text["argument"].map {|x| case_log.form.get_question(x)} %>
<%= I18n.t(informative_text["translation"], informative_text["argument"][0].to_sym => translation_question[0].answer_label(case_log), informative_text["argument"][1].to_sym => translation_question[1].answer_label(case_log)) %>
<%= display_informative_text(informative_text, case_log) %>
<%= f.govuk_radio_buttons_fieldset question.id.to_sym,
legend: legend(question, page_header, conditional),
hint: { text: question.hint_text&.html_safe } do %>

Loading…
Cancel
Save