Browse Source

feat: add gender identity questions for all 4 people, combine into single page/question

pull/1100/head
natdeanlewissoftwire 4 years ago
parent
commit
e4ff471005
  1. 18
      app/models/form/sales/pages/person1_gender_identity.rb
  2. 18
      app/models/form/sales/pages/person1_gender_identity_joint_purchase.rb
  3. 17
      app/models/form/sales/pages/person_gender_identity.rb
  4. 18
      app/models/form/sales/questions/person1_gender_identity.rb
  5. 18
      app/models/form/sales/questions/person_gender_identity.rb
  6. 10
      app/models/form/sales/subsections/household_characteristics.rb

18
app/models/form/sales/pages/person1_gender_identity.rb

@ -1,18 +0,0 @@
class Form::Sales::Pages::Person1GenderIdentity < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "person_1_gender_identity"
@header = ""
@description = ""
@subsection = subsection
@depends_on = [
{ "details_known_1" => 1, "jointpur" => 2 },
]
end
def questions
@questions ||= [
Form::Sales::Questions::Person1GenderIdentity.new("sex2", nil, self),
]
end
end

18
app/models/form/sales/pages/person1_gender_identity_joint_purchase.rb

@ -1,18 +0,0 @@
class Form::Sales::Pages::Person1GenderIdentityJointPurchase < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "person_1_gender_identity_joint_purchase"
@header = ""
@description = ""
@subsection = subsection
@depends_on = [
{ "details_known_1" => 1, "jointpur" => 1 },
]
end
def questions
@questions ||= [
Form::Sales::Questions::Person1GenderIdentity.new("sex3", nil, self),
]
end
end

17
app/models/form/sales/pages/person_gender_identity.rb

@ -0,0 +1,17 @@
class Form::Sales::Pages::PersonGenderIdentity < Form::Sales::Pages::Person
def initialize(id, hsh, subsection, person_index:)
super
@header = ""
@description = ""
@subsection = subsection
@depends_on = [
{ details_known_question_id => 1, "jointpur" => joint_purchase? ? 1 : 2 },
]
end
def questions
@questions ||= [
Form::Sales::Questions::PersonGenderIdentity.new(field_for_person("sex"), nil, self, person_index: @person_index),
]
end
end

18
app/models/form/sales/questions/person1_gender_identity.rb

@ -1,18 +0,0 @@
class Form::Sales::Questions::Person1GenderIdentity < ::Form::Question
def initialize(id, hsh, page)
super
@check_answer_label = "Person 1’s gender identity"
@header = "Which of these best describes Person 1’s gender identity?"
@type = "radio"
@page = page
@answer_options = ANSWER_OPTIONS
@check_answers_card_number = id == "sex2" ? 2 : 3
end
ANSWER_OPTIONS = {
"F" => { "value" => "Female" },
"M" => { "value" => "Male" },
"X" => { "value" => "Non-binary" },
"R" => { "value" => "Buyer prefers not to say" },
}.freeze
end

18
app/models/form/sales/questions/person_gender_identity.rb

@ -0,0 +1,18 @@
class Form::Sales::Questions::PersonGenderIdentity < ::Form::Sales::Questions::Person
def initialize(id, hsh, page, person_index:)
super
@check_answer_label = "Person #{person_display_number}’s gender identity"
@header = "Which of these best describes Person #{person_display_number}’s gender identity?"
@type = "radio"
@page = page
@answer_options = ANSWER_OPTIONS
@check_answers_card_number = person_index
end
ANSWER_OPTIONS = {
"F" => { "value" => "Female" },
"M" => { "value" => "Male" },
"X" => { "value" => "Non-binary" },
"R" => { "value" => "Person prefers not to say" },
}.freeze
end

10
app/models/form/sales/subsections/household_characteristics.rb

@ -32,23 +32,29 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::Person1Known.new(nil, nil, self),
Form::Sales::Pages::PersonAge.new("person_1_age", nil, self, person_index: 2),
Form::Sales::Pages::PersonAge.new("person_1_age_joint_purchase", nil, self, person_index: 3),
Form::Sales::Pages::Person1GenderIdentity.new(nil, nil, self),
Form::Sales::Pages::Person1GenderIdentityJointPurchase.new(nil, nil, self),
Form::Sales::Pages::PersonGenderIdentity.new("person_1_gender_identity", nil, self, person_index: 2),
Form::Sales::Pages::PersonGenderIdentity.new("person_1_gender_identity_joint_purchase", nil, self, person_index: 3),
Form::Sales::Pages::PersonWorkingSituation.new("person_1_working_situation", nil, self, person_index: 2),
Form::Sales::Pages::PersonWorkingSituation.new("person_1_working_situation_joint_purchase", nil, self, person_index: 3),
Form::Sales::Pages::Person2Known.new(nil, nil, self),
Form::Sales::Pages::PersonAge.new("person_2_age", nil, self, person_index: 3),
Form::Sales::Pages::PersonAge.new("person_2_age_joint_purchase", nil, self, person_index: 4),
Form::Sales::Pages::PersonGenderIdentity.new("person_2_gender_identity", nil, self, person_index: 3),
Form::Sales::Pages::PersonGenderIdentity.new("person_2_gender_identity_joint_purchase", nil, self, person_index: 4),
Form::Sales::Pages::PersonWorkingSituation.new("person_2_working_situation", nil, self, person_index: 3),
Form::Sales::Pages::PersonWorkingSituation.new("person_2_working_situation_joint_purchase", nil, self, person_index: 4),
Form::Sales::Pages::Person3Known.new(nil, nil, self),
Form::Sales::Pages::PersonAge.new("person_3_age", nil, self, person_index: 4),
Form::Sales::Pages::PersonAge.new("person_3_age_joint_purchase", nil, self, person_index: 5),
Form::Sales::Pages::PersonGenderIdentity.new("person_3_gender_identity", nil, self, person_index: 4),
Form::Sales::Pages::PersonGenderIdentity.new("person_3_gender_identity_joint_purchase", nil, self, person_index: 5),
Form::Sales::Pages::PersonWorkingSituation.new("person_3_working_situation", nil, self, person_index: 4),
Form::Sales::Pages::PersonWorkingSituation.new("person_3_working_situation_joint_purchase", nil, self, person_index: 5),
Form::Sales::Pages::Person4Known.new(nil, nil, self),
Form::Sales::Pages::PersonAge.new("person_4_age", nil, self, person_index: 5),
Form::Sales::Pages::PersonAge.new("person_4_age_joint_purchase", nil, self, person_index: 6),
Form::Sales::Pages::PersonGenderIdentity.new("person_4_gender_identity", nil, self, person_index: 5),
Form::Sales::Pages::PersonGenderIdentity.new("person_4_gender_identity_joint_purchase", nil, self, person_index: 6),
Form::Sales::Pages::PersonWorkingSituation.new("person_4_working_situation", nil, self, person_index: 5),
Form::Sales::Pages::PersonWorkingSituation.new("person_4_working_situation_joint_purchase", nil, self, person_index: 6),
]

Loading…
Cancel
Save