Browse Source

feat: add buyer 2-1 relationship question and page (migration and schema to come in next commit)

pull/919/head
natdeanlewissoftwire 3 years ago
parent
commit
54bfea6422
  1. 16
      app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb
  2. 29
      app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb
  3. 10
      app/models/form/sales/questions/other_buyer2_relationship_to_buyer1.rb
  4. 1
      app/models/form/sales/subsections/household_characteristics.rb

16
app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb

@ -0,0 +1,16 @@
class Form::Sales::Pages::Buyer2RelationshipToBuyer1 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_relationship_to_buyer_1"
@header = ""
@description = ""
@subsection = subsection
end
def questions
@questions ||= [
Form::Sales::Questions::Buyer2RelationshipToBuyer1.new(nil, nil, self),
Form::Sales::Questions::OtherBuyer2RelationshipToBuyer1.new(nil, nil, self),
]
end
end

29
app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb

@ -0,0 +1,29 @@
class Form::Sales::Questions::Buyer2RelationshipToBuyer1 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "relat2"
@check_answer_label = "Buyer 2's relationship to buyer 1"
@header = "What is buyer 2's relationship to buyer 1?"
@type = "radio"
@hint_text = ""
@page = page
@answer_options = ANSWER_OPTIONS
@conditional_for = {
"otherrelat2" => ["X"],
}
@hidden_in_check_answers = {
"depends_on" => [
{
"relat2" => "X",
},
],
}
end
ANSWER_OPTIONS = {
"P" => { "value" => "Parent" },
"C" => { "value" => "Child" },
"X" => { "value" => "Other" },
"R" => { "value" => "Buyer prefers not to say" },
}.freeze
end

10
app/models/form/sales/questions/other_buyer2_relationship_to_buyer1.rb

@ -0,0 +1,10 @@
class Form::Sales::Questions::OtherBuyer2RelationshipToBuyer1 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "otherrelat2"
@check_answer_label = "Buyer 2's relationship to buyer 1"
@header = "Buyer 2's relationship to buyer 1"
@type = "text"
@page = page
end
end

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

@ -12,6 +12,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::Age1.new(nil, nil, self),
Form::Sales::Pages::GenderIdentity1.new(nil, nil, self),
Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self),
Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self),
]
end
end

Loading…
Cancel
Save