From a4cf186ad2b50a0709b8ae134c47dc3fa80ddd76 Mon Sep 17 00:00:00 2001 From: Samuel Young Date: Mon, 9 Feb 2026 14:14:49 +0000 Subject: [PATCH] CLDC-4200: Add mechanism for custom CYA header labels also simplify the view logic for check answers summary list --- .../check_answers_summary_list_card_component.html.erb | 4 ++-- app/components/check_answers_summary_list_card_component.rb | 5 ++++- app/models/form/question.rb | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/components/check_answers_summary_list_card_component.html.erb b/app/components/check_answers_summary_list_card_component.html.erb index 4c1f9aa2d..8b0c7d9b0 100644 --- a/app/components/check_answers_summary_list_card_component.html.erb +++ b/app/components/check_answers_summary_list_card_component.html.erb @@ -1,8 +1,8 @@ <% if applicable_questions.first %>
- <% if applicable_questions.first.check_answers_card_number != 0 && applicable_questions.first.check_answers_card_number.present? %> + <% if check_answers_card_label(applicable_questions.first).present? %>
-

<%= check_answers_card_title(applicable_questions.first) %>

+

<%= check_answers_card_label(applicable_questions.first) %>

<% end %> diff --git a/app/components/check_answers_summary_list_card_component.rb b/app/components/check_answers_summary_list_card_component.rb index e11f69068..1dc345f01 100644 --- a/app/components/check_answers_summary_list_card_component.rb +++ b/app/components/check_answers_summary_list_card_component.rb @@ -22,7 +22,10 @@ class CheckAnswersSummaryListCardComponent < ViewComponent::Base [question.question_number_string, question.check_answer_label.to_s.presence || question.header.to_s].compact.join(" - ") end - def check_answers_card_title(question) + def check_answers_card_label(question) + return question.check_answers_card_title if question.check_answers_card_title.present? + return unless question.check_answers_card_number.present? && question.check_answers_card_number != 0 + return "Lead tenant" if question.form.type == "lettings" && question.check_answers_card_number == 1 return "Buyer #{question.check_answers_card_number}" if question.check_answers_card_number <= number_of_buyers diff --git a/app/models/form/question.rb b/app/models/form/question.rb index c826493a0..b6f3b8b2f 100644 --- a/app/models/form/question.rb +++ b/app/models/form/question.rb @@ -6,7 +6,7 @@ class Form::Question :conditional_for, :readonly, :answer_options, :page, :inferred_answers, :hidden_in_check_answers, :inferred_check_answers_value, :top_guidance_partial, :bottom_guidance_partial, :prefix, :suffix, - :requires_js, :fields_added, :derived, :check_answers_card_number, + :requires_js, :fields_added, :derived, :check_answers_card_number, :check_answers_card_title, :unresolved_hint_text, :question_number, :hide_question_number_on_page, :plain_label, :error_label, :strip_commas