Browse Source

feat: household characteristics numbering

pull/1381/head
natdeanlewissoftwire 3 years ago
parent
commit
12457c14c7
  1. 2
      app/components/check_answers_summary_list_card_component.html.erb
  2. 4
      app/components/check_answers_summary_list_card_component.rb
  3. 2
      app/helpers/check_answers_helper.rb
  4. 2
      app/helpers/question_view_helper.rb
  5. 4
      app/models/form/question.rb
  6. 1
      app/models/form/sales/questions/age1.rb
  7. 1
      app/models/form/sales/questions/age2.rb
  8. 1
      app/models/form/sales/questions/person_age.rb
  9. 2
      app/views/form/_textarea_question.html.erb

2
app/components/check_answers_summary_list_card_component.html.erb

@ -10,7 +10,7 @@
<%= govuk_summary_list do |summary_list| %> <%= govuk_summary_list do |summary_list| %>
<% applicable_questions.each do |question| %> <% applicable_questions.each do |question| %>
<% summary_list.row do |row| %> <% summary_list.row do |row| %>
<% row.key { question.check_answer_label.to_s.presence || question.header.to_s } %> <% row.key { get_question_label(question) } %>
<% row.value do %> <% row.value do %>
<span class="govuk-!-margin-right-4"><%= get_answer_label(question) %></span> <span class="govuk-!-margin-right-4"><%= get_answer_label(question) %></span>

4
app/components/check_answers_summary_list_card_component.rb

@ -17,6 +17,10 @@ class CheckAnswersSummaryListCardComponent < ViewComponent::Base
question.answer_label(log, user).presence || unanswered_value question.answer_label(log, user).presence || unanswered_value
end end
def get_question_label(question)
[question.question_number_string(false), question.check_answer_label.to_s.presence || question.header.to_s].compact.join(" - ")
end
def check_answers_card_title(question) def check_answers_card_title(question)
return "Lead tenant" if question.form.type == "lettings" && question.check_answers_card_number == 1 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 return "Buyer #{question.check_answers_card_number}" if question.check_answers_card_number <= number_of_buyers

2
app/helpers/check_answers_helper.rb

@ -47,6 +47,6 @@ private
end end
def get_question_label(question) def get_question_label(question)
[question.question_number_string, question.check_answer_label.to_s.presence || question.header.to_s].compact.join(" - ") [question.question_number_string(false), question.check_answer_label.to_s.presence || question.header.to_s].compact.join(" - ")
end end
end end

2
app/helpers/question_view_helper.rb

@ -7,7 +7,7 @@ module QuestionViewHelper
def legend(question, page_header, conditional) def legend(question, page_header, conditional)
{ {
text: [question.question_number_string, question.header.html_safe].compact.join(" - "), text: [question.question_number_string(conditional), question.header.html_safe].compact.join(" - "),
size: label_size(page_header, conditional), size: label_size(page_header, conditional),
tag: label_tag(page_header, conditional), tag: label_tag(page_header, conditional),
} }

4
app/models/form/question.rb

@ -259,8 +259,8 @@ class Form::Question
selected_answer_option_is_derived?(log) || has_inferred_check_answers_value?(log) selected_answer_option_is_derived?(log) || has_inferred_check_answers_value?(log)
end end
def question_number_string def question_number_string(conditional)
if @question_number if @question_number && !conditional
"Q#{@question_number}" "Q#{@question_number}"
end end
end end

1
app/models/form/sales/questions/age1.rb

@ -19,5 +19,6 @@ class Form::Sales::Questions::Age1 < ::Form::Question
@check_answers_card_number = 1 @check_answers_card_number = 1
@min = 16 @min = 16
@max = 110 @max = 110
@question_number = 20
end end
end end

1
app/models/form/sales/questions/age2.rb

@ -13,5 +13,6 @@ class Form::Sales::Questions::Age2 < ::Form::Question
@check_answers_card_number = 2 @check_answers_card_number = 2
@max = 110 @max = 110
@min = 0 @min = 0
@question_number = 28
end end
end end

1
app/models/form/sales/questions/person_age.rb

@ -12,5 +12,6 @@ class Form::Sales::Questions::PersonAge < ::Form::Question
@check_answers_card_number = person_index @check_answers_card_number = person_index
@min = 0 @min = 0
@max = 110 @max = 110
@question_number = 29 + person_index * 4
end end
end end

2
app/views/form/_textarea_question.html.erb

@ -2,7 +2,7 @@
<%= f.govuk_text_area question.id.to_sym, <%= f.govuk_text_area question.id.to_sym,
caption: caption(caption_text, page_header, conditional), caption: caption(caption_text, page_header, conditional),
label: legend(question, page_header, conditional, @log), label: legend(question, page_header, conditional),
hint: { text: question.hint_text&.html_safe }, hint: { text: question.hint_text&.html_safe },
width: question.width || nil, width: question.width || nil,
**stimulus_html_attributes(question) %> **stimulus_html_attributes(question) %>

Loading…
Cancel
Save