Browse Source

feat: add dynamic cya card titles

pull/1103/head
natdeanlewissoftwire 4 years ago
parent
commit
167a503a1a
  1. 7
      app/components/check_answers_summary_list_card_component.html.erb
  2. 29
      app/components/check_answers_summary_list_card_component.rb

7
app/components/check_answers_summary_list_card_component.html.erb

@ -2,12 +2,7 @@
<div class="x-govuk-summary-card govuk-!-margin-bottom-6">
<% if applicable_questions.first.check_answers_card_number != 0 && applicable_questions.first.check_answers_card_number.present? %>
<div class="x-govuk-summary-card__header">
<% if applicable_questions.first.check_answers_card_number == 1 %>
<h3 class="x-govuk-summary-card__title">Lead tenant</h3>
<% end %>
<% if applicable_questions.first.check_answers_card_number > 1 %>
<h3 class="x-govuk-summary-card__title">Person <%= applicable_questions.first.check_answers_card_number %></h3>
<% end %>
<h3 class="x-govuk-summary-card__title"><%= check_answers_card_title(applicable_questions.first) %></h3>
</div>
<% end %>
<div class="x-govuk-summary-card__body">

29
app/components/check_answers_summary_list_card_component.rb

@ -15,4 +15,33 @@ class CheckAnswersSummaryListCardComponent < ViewComponent::Base
def get_answer_label(question)
question.answer_label(log).presence || "<span class=\"app-!-colour-muted\">You didn’t answer this question</span>".html_safe
end
def check_answers_card_title(question)
case question.form.type
when "lettings"
case question.check_answers_card_number
when 1
"Lead tenant"
when 2..8
"Person #{question.check_answers_card_number}"
end
when "sales"
case log[:jointpur]
when 1
case question.check_answers_card_number
when 1..2
"Buyer #{question.check_answers_card_number}"
when 3..6
"Person #{question.check_answers_card_number - 2}"
end
when 2
case question.check_answers_card_number
when 1
"Buyer #{question.check_answers_card_number}"
when 2..5
"Person #{question.check_answers_card_number - 1}"
end
end
end
end
end

Loading…
Cancel
Save