Browse Source

CLDC-4141: New question and page models

pull/3156/head
Katherine Langford 3 weeks ago
parent
commit
65e1967cff
  1. 15
      app/models/form/lettings/pages/lead_tenant_sex_registered_at_birth1.rb
  2. 18
      app/models/form/lettings/pages/person_sex_registered_at_birth.rb
  3. 20
      app/models/form/lettings/questions/person_sex_registered_at_birth.rb
  4. 21
      app/models/form/lettings/questions/sex_registered_at_birth1.rb

15
app/models/form/lettings/pages/lead_tenant_sex_registered_at_birth1.rb

@ -0,0 +1,15 @@
# frozen_string_literal: true
class Form::Lettings::Pages::LeadTenantSexRegisteredAtBirth1 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "lead_tenant_sex_registered_at_birth"
@depends_on = [{ "declaration" => 1 }]
end
def questions
@questions ||= [
Form::Sales::Questions::SexRegisteredAtBirth1.new(nil, nil, self),
]
end
end

18
app/models/form/lettings/pages/person_sex_registered_at_birth.rb

@ -0,0 +1,18 @@
# frozen_string_literal: true
class Form::Lettings::Pages::PersonSexRegisteredAtBirth < ::Form::Page
def initialize(id, hsh, subsection, person_index:)
super(id, hsh, subsection)
@id = "person_#{person_index}_sex_registered_at_birth"
@person_index = person_index
@depends_on = [
{ "details_known_#{person_index}" => 0 },
]
end
def questions
@questions ||= [
Form::Lettings::Questions::PersonSexRegisteredAtBirth.new("sexrab#{@person_index}", nil, self, person_index: @person_index),
]
end
end

20
app/models/form/lettings/questions/person_sex_registered_at_birth.rb

@ -0,0 +1,20 @@
# frozen_string_literal: true
class Form::Lettings::Questions::PersonSexRegisteredAtBirth < ::Form::Question
def initialize(id, hsh, page, person_index:)
super(id, hsh, page)
@type = "radio"
@check_answers_card_number = person_index
@answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
ANSWER_OPTIONS = {
"F" => { "value" => "Female" },
"M" => { "value" => "Male" },
"divider" => { "value" => true },
"R" => { "value" => "Person prefers not to say" },
}.freeze
QUESTION_NUMBER_FROM_YEAR = { 2026 => 0 }.freeze
end

21
app/models/form/lettings/questions/sex_registered_at_birth1.rb

@ -0,0 +1,21 @@
# frozen_string_literal: true
class Form::Lettings::Questions::SexRegisteredAtBirth1 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "sexrab1"
@type = "radio"
@check_answers_card_number = 1
@answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
ANSWER_OPTIONS = {
"F" => { "value" => "Female" },
"M" => { "value" => "Male" },
"divider" => { "value" => true },
"R" => { "value" => "Buyer prefers not to say" },
}.freeze
QUESTION_NUMBER_FROM_YEAR = { 2026 => 0 }.freeze
end
Loading…
Cancel
Save