Browse Source

feat: fix error labels for address questions

pull/1696/head
natdeanlewissoftwire 3 years ago
parent
commit
f75fa4c949
  1. 2
      app/helpers/question_view_helper.rb
  2. 5
      app/models/form/lettings/questions/address_line1.rb
  3. 4
      app/models/form/lettings/questions/county.rb
  4. 4
      app/models/form/lettings/questions/postcode_for_full_address.rb
  5. 4
      app/models/form/lettings/questions/town_or_city.rb
  6. 10
      app/models/form/question.rb
  7. 5
      app/models/form/sales/questions/address_line1.rb
  8. 4
      app/models/form/sales/questions/county.rb
  9. 4
      app/models/form/sales/questions/postcode_for_full_address.rb
  10. 4
      app/models/form/sales/questions/town_or_city.rb

2
app/helpers/question_view_helper.rb

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

5
app/models/form/lettings/questions/address_line1.rb

@ -4,10 +4,13 @@ class Form::Lettings::Questions::AddressLine1 < ::Form::Question
@id = "address_line1"
@check_answer_label = "Address"
@header = "Address line 1"
@error_label = "Address line 1"
@type = "text"
@plain_label = true
@check_answer_label = "Q12 - Address lines 1 and 2"
@check_answer_label = "Address lines 1 and 2"
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
@question_number = 12
@hide_question_number_on_page = true
end
def answer_label(log, _current_user = nil)

4
app/models/form/lettings/questions/county.rb

@ -5,7 +5,9 @@ class Form::Lettings::Questions::County < ::Form::Question
@header = "County (optional)"
@type = "text"
@plain_label = true
@check_answer_label = "Q12 - County"
@check_answer_label = "County"
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
@question_number = 12
@hide_question_number_on_page = true
end
end

4
app/models/form/lettings/questions/postcode_for_full_address.rb

@ -17,7 +17,9 @@ class Form::Lettings::Questions::PostcodeForFullAddress < ::Form::Question
},
}
@plain_label = true
@check_answer_label = "Q12 - Postcode"
@check_answer_label = "Postcode"
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
@question_number = 12
@hide_question_number_on_page = true
end
end

4
app/models/form/lettings/questions/town_or_city.rb

@ -5,7 +5,9 @@ class Form::Lettings::Questions::TownOrCity < ::Form::Question
@header = "Town or city"
@type = "text"
@plain_label = true
@check_answer_label = "Q12 - Town or city"
@check_answer_label = "Town or city"
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
@question_number = 12
@hide_question_number_on_page = true
end
end

10
app/models/form/question.rb

@ -4,7 +4,7 @@ class Form::Question
:conditional_for, :readonly, :answer_options, :page, :check_answer_label,
:inferred_answers, :hidden_in_check_answers, :inferred_check_answers_value,
:guidance_partial, :prefix, :suffix, :requires_js, :fields_added, :derived,
:check_answers_card_number, :unresolved_hint_text, :question_number, :plain_label
:check_answers_card_number, :unresolved_hint_text, :question_number, :hide_question_number_on_page, :plain_label, :error_label
module GuidancePosition
TOP = 1
@ -41,7 +41,9 @@ class Form::Question
@check_answers_card_number = hsh["check_answers_card_number"] || 0
@unresolved_hint_text = hsh["unresolved_hint_text"]
@question_number = hsh["question_number"]
@hide_question_number_on_page = hsh["hide_question_number_on_page"]
@plain_label = hsh["plain_label"]
@error_label = hsh["error_label"]
@disable_clearing_if_not_routed_or_dynamic_answer_options = hsh["disable_clearing_if_not_routed_or_dynamic_answer_options"]
end
end
@ -195,7 +197,7 @@ class Form::Question
end
def display_label
check_answer_label || header || id.humanize
error_label || check_answer_label || header || id.humanize
end
def unanswered_error_message
@ -241,8 +243,8 @@ class Form::Question
selected_answer_option_is_derived?(log) || has_inferred_check_answers_value?(log)
end
def question_number_string(conditional: false)
if @question_number && !conditional && form.start_date.year >= 2023
def question_number_string(hidden: false)
if @question_number && !hidden && form.start_date.year >= 2023
"Q#{@question_number}"
end
end

5
app/models/form/sales/questions/address_line1.rb

@ -4,10 +4,13 @@ class Form::Sales::Questions::AddressLine1 < ::Form::Question
@id = "address_line1"
@check_answer_label = "Address"
@header = "Address line 1"
@error_label = "Address line 1"
@type = "text"
@plain_label = true
@check_answer_label = "Q15 - Address lines 1 and 2"
@check_answer_label = "Address lines 1 and 2"
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
@question_number = 15
@hide_question_number_on_page = true
end
def answer_label(log, _current_user = nil)

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

@ -5,7 +5,9 @@ class Form::Sales::Questions::County < ::Form::Question
@header = "County (optional)"
@type = "text"
@plain_label = true
@check_answer_label = "Q15 - County"
@check_answer_label = "County"
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
@question_number = 15
@hide_question_number_on_page = true
end
end

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

@ -17,7 +17,9 @@ class Form::Sales::Questions::PostcodeForFullAddress < ::Form::Question
},
}
@plain_label = true
@check_answer_label = "Q15 - Postcode"
@check_answer_label = "Postcode"
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
@question_number = 15
@hide_question_number_on_page = true
end
end

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

@ -5,7 +5,9 @@ class Form::Sales::Questions::TownOrCity < ::Form::Question
@header = "Town or city"
@type = "text"
@plain_label = true
@check_answer_label = "Q15 - Town or city"
@check_answer_label = "Town or city"
@disable_clearing_if_not_routed_or_dynamic_answer_options = true
@question_number = 12
@hide_question_number_on_page = true
end
end

Loading…
Cancel
Save