Browse Source

feat: rename display_label

pull/1696/head
natdeanlewissoftwire 3 years ago
parent
commit
ad8c35fb6a
  1. 1
      app/models/form/lettings/questions/address_line1.rb
  2. 4
      app/models/form/question.rb
  3. 1
      app/models/form/sales/questions/address_line1.rb
  4. 4
      app/services/bulk_upload/lettings/year2022/row_parser.rb
  5. 4
      app/services/bulk_upload/lettings/year2023/row_parser.rb
  6. 4
      app/services/bulk_upload/sales/year2022/row_parser.rb
  7. 4
      app/services/bulk_upload/sales/year2023/row_parser.rb

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

@ -2,7 +2,6 @@ class Form::Lettings::Questions::AddressLine1 < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "address_line1" @id = "address_line1"
@check_answer_label = "Address"
@header = "Address line 1" @header = "Address line 1"
@error_label = "Address line 1" @error_label = "Address line 1"
@type = "text" @type = "text"

4
app/models/form/question.rb

@ -196,7 +196,7 @@ class Form::Question
type == "radio" && RADIO_REFUSED_VALUE[id.to_sym]&.include?(value) type == "radio" && RADIO_REFUSED_VALUE[id.to_sym]&.include?(value)
end end
def display_label def error_display_label
error_label || check_answer_label || header || id.humanize error_label || check_answer_label || header || id.humanize
end end
@ -204,7 +204,7 @@ class Form::Question
return I18n.t("validations.declaration.missing") if id == "declaration" return I18n.t("validations.declaration.missing") if id == "declaration"
return I18n.t("validations.privacynotice.missing") if id == "privacynotice" return I18n.t("validations.privacynotice.missing") if id == "privacynotice"
I18n.t("validations.not_answered", question: display_label.downcase) I18n.t("validations.not_answered", question: error_display_label.downcase)
end end
def suffix_label(log) def suffix_label(log)

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

@ -2,7 +2,6 @@ class Form::Sales::Questions::AddressLine1 < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "address_line1" @id = "address_line1"
@check_answer_label = "Address"
@header = "Address line 1" @header = "Address line 1"
@error_label = "Address line 1" @error_label = "Address line 1"
@type = "text" @type = "text"

4
app/services/bulk_upload/lettings/year2022/row_parser.rb

@ -774,13 +774,13 @@ private
if setup_question?(question) if setup_question?(question)
fields.each do |field| fields.each do |field|
if errors.select { |e| fields.include?(e.attribute) }.none? if errors.select { |e| fields.include?(e.attribute) }.none?
errors.add(field, I18n.t("validations.not_answered", question: question.display_label&.downcase), category: :setup) errors.add(field, I18n.t("validations.not_answered", question: question.error_display_label&.downcase), category: :setup)
end end
end end
else else
fields.each do |field| fields.each do |field|
unless errors.any? { |e| fields.include?(e.attribute) } unless errors.any? { |e| fields.include?(e.attribute) }
errors.add(field, I18n.t("validations.not_answered", question: question.display_label&.downcase)) errors.add(field, I18n.t("validations.not_answered", question: question.error_display_label&.downcase))
end end
end end
end end

4
app/services/bulk_upload/lettings/year2023/row_parser.rb

@ -681,14 +681,14 @@ private
if setup_question?(question) if setup_question?(question)
fields.each do |field| fields.each do |field|
if errors.select { |e| fields.include?(e.attribute) }.none? if errors.select { |e| fields.include?(e.attribute) }.none?
question_text = question.display_label.presence || "this question" question_text = question.error_display_label.presence || "this question"
errors.add(field, I18n.t("validations.not_answered", question: question_text.downcase), category: :setup) errors.add(field, I18n.t("validations.not_answered", question: question_text.downcase), category: :setup)
end end
end end
else else
fields.each do |field| fields.each do |field|
unless errors.any? { |e| fields.include?(e.attribute) } unless errors.any? { |e| fields.include?(e.attribute) }
question_text = question.display_label.presence || "this question" question_text = question.error_display_label.presence || "this question"
errors.add(field, I18n.t("validations.not_answered", question: question_text.downcase)) errors.add(field, I18n.t("validations.not_answered", question: question_text.downcase))
end end
end end

4
app/services/bulk_upload/sales/year2022/row_parser.rb

@ -1057,9 +1057,9 @@ private
fields.each do |field| fields.each do |field|
unless errors.any? { |e| fields.include?(e.attribute) } unless errors.any? { |e| fields.include?(e.attribute) }
if setup_question?(question) if setup_question?(question)
errors.add(field, I18n.t("validations.not_answered", question: question.display_label&.downcase), category: :setup) errors.add(field, I18n.t("validations.not_answered", question: question.error_display_label&.downcase), category: :setup)
else else
errors.add(field, I18n.t("validations.not_answered", question: question.display_label&.downcase)) errors.add(field, I18n.t("validations.not_answered", question: question.error_display_label&.downcase))
end end
end end
end end

4
app/services/bulk_upload/sales/year2023/row_parser.rb

@ -1210,13 +1210,13 @@ private
if setup_question?(question) if setup_question?(question)
fields.each do |field| fields.each do |field|
unless errors.any? { |e| fields.include?(e.attribute) } unless errors.any? { |e| fields.include?(e.attribute) }
errors.add(field, I18n.t("validations.not_answered", question: question.display_label&.downcase), category: :setup) errors.add(field, I18n.t("validations.not_answered", question: question.error_display_label&.downcase), category: :setup)
end end
end end
else else
fields.each do |field| fields.each do |field|
unless errors.any? { |e| fields.include?(e.attribute) } unless errors.any? { |e| fields.include?(e.attribute) }
errors.add(field, I18n.t("validations.not_answered", question: question.display_label&.downcase)) errors.add(field, I18n.t("validations.not_answered", question: question.error_display_label&.downcase))
end end
end end
end end

Loading…
Cancel
Save