From 26e7f16d28fefed20dff33057dd12064723a256d Mon Sep 17 00:00:00 2001 From: Paul Robert Lloyd Date: Mon, 25 Apr 2022 17:50:58 +0100 Subject: [PATCH] Refactor partial used for check answers summary list --- .../form/_check_answers_summary_list.html.erb | 18 ++++++++++++++++++ app/views/form/_check_answers_table.html.erb | 14 -------------- app/views/form/check_answers.html.erb | 13 ++++--------- app/views/form/review.html.erb | 13 ++++--------- 4 files changed, 26 insertions(+), 32 deletions(-) create mode 100644 app/views/form/_check_answers_summary_list.html.erb delete mode 100644 app/views/form/_check_answers_table.html.erb diff --git a/app/views/form/_check_answers_summary_list.html.erb b/app/views/form/_check_answers_summary_list.html.erb new file mode 100644 index 000000000..a2aa3311f --- /dev/null +++ b/app/views/form/_check_answers_summary_list.html.erb @@ -0,0 +1,18 @@ +<%= govuk_summary_list do |summary_list| %> + <% subsection.applicable_questions(@case_log).each do |question| %> + <% summary_list.row do |row| %> + <% row.key { question.check_answer_label.to_s.presence || question.header.to_s } %> + <% row.value do %> + <%= get_answer_label(question, @case_log) %>
+ <% question.get_inferred_answers(@case_log).each do |inferred_answer| %> + <%= inferred_answer %> + <% end %> + <% end %> + <% row.action( + text: question.action_text(@case_log), + href: question.action_href(@case_log, question.page.id), + visually_hidden_text: question.check_answer_label.to_s.downcase, + ) %> + <% end %> + <% end %> +<% end %> diff --git a/app/views/form/_check_answers_table.html.erb b/app/views/form/_check_answers_table.html.erb deleted file mode 100644 index afae78056..000000000 --- a/app/views/form/_check_answers_table.html.erb +++ /dev/null @@ -1,14 +0,0 @@ -<% summary_list.row do |row| %> - <% row.key { question.check_answer_label.to_s.presence || question.header.to_s } %> - <% row.value do %> - <%= get_answer_label(question, @case_log) %>
- <% question.get_inferred_answers(@case_log).each do |inferred_answer| %> - <%= inferred_answer %> - <% end %> - <% end %> - <% row.action( - text: question.action_text(@case_log), - href: question.action_href(@case_log, question.page.id), - visually_hidden_text: question.check_answer_label.to_s.downcase, - ) %> -<% end %> diff --git a/app/views/form/check_answers.html.erb b/app/views/form/check_answers.html.erb index b7ac5c24b..0a98b35b1 100644 --- a/app/views/form/check_answers.html.erb +++ b/app/views/form/check_answers.html.erb @@ -19,15 +19,10 @@ <% end %> <%= display_answered_questions_summary(subsection, @case_log) %> - <%= govuk_summary_list do |summary_list| %> - <% subsection.applicable_questions(@case_log).each do |question| %> - <%= render partial: "form/check_answers_table", locals: { - summary_list:, - question:, - case_log: @case_log, - } %> - <% end %> - <% end %> + <%= render partial: 'form/check_answers_summary_list', locals: { + subsection:, + case_log: @case_log, + } %> <%= form_with model: @case_log, method: "get" do |f| %> <%= f.govuk_submit "Save and return to log" do %> diff --git a/app/views/form/review.html.erb b/app/views/form/review.html.erb index 0254e1022..19e8498d6 100644 --- a/app/views/form/review.html.erb +++ b/app/views/form/review.html.erb @@ -21,15 +21,10 @@

<%= subsection.label %>

- <%= govuk_summary_list do |summary_list| %> - <% subsection.applicable_questions(@case_log).each do |question| %> - <%= render partial: 'form/check_answers_table', locals: { - summary_list:, - question:, - case_log: @case_log, - } %> - <% end %> - <% end %> + <%= render partial: 'form/check_answers_summary_list', locals: { + subsection:, + case_log: @case_log, + } %>
<% end %>