From 4c2f3e0a48870603941f402533ceefb79dccbd3a Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 8 Mar 2022 09:09:13 +0000 Subject: [PATCH] extract displaying of the informative text into a helper --- app/helpers/interuption_screen_helper.rb | 7 +++++++ app/views/form/_interruption_screen_question.html.erb | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 app/helpers/interuption_screen_helper.rb diff --git a/app/helpers/interuption_screen_helper.rb b/app/helpers/interuption_screen_helper.rb new file mode 100644 index 000000000..c5578c009 --- /dev/null +++ b/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)) + "#{translation}".html_safe + end +end diff --git a/app/views/form/_interruption_screen_question.html.erb b/app/views/form/_interruption_screen_question.html.erb index 8071bf539..d43d539f2 100644 --- a/app/views/form/_interruption_screen_question.html.erb +++ b/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 %>