Browse Source

add question_number method to question

CLDC-1864-question-numbering-too
Kat 2 years ago
parent
commit
9d3632b2e6
  1. 4
      app/helpers/question_view_helper.rb
  2. 4
      app/models/form/question.rb
  3. 4
      app/models/form/sales/questions/ownership_scheme.rb
  4. 4
      app/models/form/sales/questions/purchaser_code.rb
  5. 4
      app/models/form/sales/questions/sale_date.rb
  6. 4
      app/models/form/sales/questions/shared_ownership_type.rb
  7. 2
      app/views/form/_textarea_question.html.erb

4
app/helpers/question_view_helper.rb

@ -5,9 +5,9 @@ module QuestionViewHelper
{ text: caption_text.html_safe, size: "l" } { text: caption_text.html_safe, size: "l" }
end end
def legend(question, page_header, conditional) def legend(question, page_header, conditional, log = nil)
{ {
text: question.header.html_safe, text: [question.question_number(log), 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

@ -258,6 +258,10 @@ 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(log)
nil
end
private private
def selected_answer_option_is_derived?(log) def selected_answer_option_is_derived?(log)

4
app/models/form/sales/questions/ownership_scheme.rb

@ -13,4 +13,8 @@ class Form::Sales::Questions::OwnershipScheme < ::Form::Question
"2" => { "value" => "Yes - a discounted ownership scheme" }, "2" => { "value" => "Yes - a discounted ownership scheme" },
"3" => { "value" => "No - this is an outright or other sale" }, "3" => { "value" => "No - this is an outright or other sale" },
}.freeze }.freeze
def question_number(log)
"Q3"
end
end end

4
app/models/form/sales/questions/purchaser_code.rb

@ -8,4 +8,8 @@ class Form::Sales::Questions::PurchaserCode < ::Form::Question
@type = "text" @type = "text"
@width = 10 @width = 10
end end
def question_number(log)
"Q2"
end
end end

4
app/models/form/sales/questions/sale_date.rb

@ -6,4 +6,8 @@ class Form::Sales::Questions::SaleDate < ::Form::Question
@header = "What is the sale completion date?" @header = "What is the sale completion date?"
@type = "date" @type = "date"
end end
def question_number(log)
"Q1"
end
end end

4
app/models/form/sales/questions/shared_ownership_type.rb

@ -18,4 +18,8 @@ class Form::Sales::Questions::SharedOwnershipType < ::Form::Question
"31" => { "value" => "Right to Shared Ownership" }, "31" => { "value" => "Right to Shared Ownership" },
"30" => { "value" => "Shared Ownership - 2021 model lease" }, "30" => { "value" => "Shared Ownership - 2021 model lease" },
}.freeze }.freeze
def question_number(log)
"Q4"
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), label: legend(question, page_header, conditional, @log),
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