Browse Source

Refactor partial used for check answers summary list

pull/499/head
Paul Robert Lloyd 3 years ago
parent
commit
26e7f16d28
  1. 18
      app/views/form/_check_answers_summary_list.html.erb
  2. 14
      app/views/form/_check_answers_table.html.erb
  3. 9
      app/views/form/check_answers.html.erb
  4. 9
      app/views/form/review.html.erb

18
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) %><br>
<% question.get_inferred_answers(@case_log).each do |inferred_answer| %>
<span class="govuk-!-font-weight-regular app-!-colour-muted"><%= inferred_answer %></span>
<% 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 %>

14
app/views/form/_check_answers_table.html.erb

@ -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) %><br>
<% question.get_inferred_answers(@case_log).each do |inferred_answer| %>
<span class="govuk-!-font-weight-regular app-!-colour-muted"><%= inferred_answer %></span>
<% 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 %>

9
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:,
<%= render partial: 'form/check_answers_summary_list', locals: {
subsection:,
case_log: @case_log,
} %>
<% end %>
<% end %>
<%= form_with model: @case_log, method: "get" do |f| %>
<%= f.govuk_submit "Save and return to log" do %>

9
app/views/form/review.html.erb

@ -21,15 +21,10 @@
<h3 class="x-govuk-summary-card__title"><%= subsection.label %></h3>
</div>
<div class="x-govuk-summary-card__body">
<%= govuk_summary_list do |summary_list| %>
<% subsection.applicable_questions(@case_log).each do |question| %>
<%= render partial: 'form/check_answers_table', locals: {
summary_list:,
question:,
<%= render partial: 'form/check_answers_summary_list', locals: {
subsection:,
case_log: @case_log,
} %>
<% end %>
<% end %>
</div>
</div>
<% end %>

Loading…
Cancel
Save