Browse Source
# Conflicts: # app/models/form/sales/subsections/household_characteristics.rbpull/1093/head
15 changed files with 98 additions and 120 deletions
@ -1,29 +1,18 @@ |
|||||||
class Form::Sales::Pages::PersonAge < ::Form::Page |
class Form::Sales::Pages::PersonAge < Form::Sales::Pages::Person |
||||||
def initialize(id, hsh, subsection) |
def initialize(id, hsh, subsection, person_index:) |
||||||
super |
super |
||||||
@header = "" |
@header = "" |
||||||
@description = "" |
@description = "" |
||||||
@subsection = subsection |
@subsection = subsection |
||||||
@depends_on = [ |
@depends_on = [ |
||||||
{ "details_known_#{person_display_number(PERSON_INDEX)}" => 1, "jointpur" => joint_purchase? ? 1 : 2 }, |
{ details_known_question_id => 1, "jointpur" => joint_purchase? ? 1 : 2 }, |
||||||
] |
] |
||||||
end |
end |
||||||
|
|
||||||
PERSON_INDEX = { |
|
||||||
"person_1_age" => 2, |
|
||||||
"person_2_age" => 3, |
|
||||||
"person_3_age" => 4, |
|
||||||
"person_4_age" => 5, |
|
||||||
"person_1_age_joint_purchase" => 3, |
|
||||||
"person_2_age_joint_purchase" => 4, |
|
||||||
"person_3_age_joint_purchase" => 5, |
|
||||||
"person_4_age_joint_purchase" => 6, |
|
||||||
}.freeze |
|
||||||
|
|
||||||
def questions |
def questions |
||||||
@questions ||= [ |
@questions ||= [ |
||||||
Form::Sales::Questions::PersonAgeKnown.new("age#{person_database_number(PERSON_INDEX)}_known", nil, self), |
Form::Sales::Questions::PersonAgeKnown.new(field_for_person("age", "_known"), nil, self, person_index: @person_index), |
||||||
Form::Sales::Questions::PersonAge.new("age#{person_database_number(PERSON_INDEX)}", nil, self), |
Form::Sales::Questions::PersonAge.new(field_for_person("age"), nil, self, person_index: @person_index), |
||||||
] |
] |
||||||
end |
end |
||||||
end |
end |
||||||
|
|||||||
@ -1,28 +1,17 @@ |
|||||||
class Form::Sales::Pages::PersonWorkingSituation < ::Form::Page |
class Form::Sales::Pages::PersonWorkingSituation < Form::Sales::Pages::Person |
||||||
def initialize(id, hsh, subsection) |
def initialize(id, hsh, subsection, person_index:) |
||||||
super |
super |
||||||
@header = "" |
@header = "" |
||||||
@description = "" |
@description = "" |
||||||
@subsection = subsection |
@subsection = subsection |
||||||
@depends_on = [ |
@depends_on = [ |
||||||
{ "details_known_#{person_display_number(PERSON_INDEX)}" => 1, "jointpur" => joint_purchase? ? 1 : 2 }, |
{ details_known_question_id => 1, "jointpur" => joint_purchase? ? 1 : 2 }, |
||||||
] |
] |
||||||
end |
end |
||||||
|
|
||||||
def questions |
def questions |
||||||
@questions ||= [ |
@questions ||= [ |
||||||
Form::Sales::Questions::PersonWorkingSituation.new("ecstat#{person_database_number(PERSON_INDEX)}", nil, self), |
Form::Sales::Questions::PersonWorkingSituation.new(field_for_person("ecstat"), nil, self, person_index: @person_index), |
||||||
] |
] |
||||||
end |
end |
||||||
|
|
||||||
PERSON_INDEX = { |
|
||||||
"person_1_working_situation" => 2, |
|
||||||
"person_2_working_situation" => 3, |
|
||||||
"person_3_working_situation" => 4, |
|
||||||
"person_4_working_situation" => 5, |
|
||||||
"person_1_working_situation_joint_purchase" => 3, |
|
||||||
"person_2_working_situation_joint_purchase" => 4, |
|
||||||
"person_3_working_situation_joint_purchase" => 5, |
|
||||||
"person_4_working_situation_joint_purchase" => 6, |
|
||||||
}.freeze |
|
||||||
end |
end |
||||||
|
|||||||
@ -1,23 +1,15 @@ |
|||||||
class Form::Sales::Questions::PersonAge < ::Form::Question |
class Form::Sales::Questions::PersonAge < Form::Sales::Questions::Person |
||||||
def initialize(id, hsh, page) |
def initialize(id, hsh, page, person_index:) |
||||||
super |
super |
||||||
@check_answer_label = "Person #{person_display_number(PERSON_INDEX)}’s age" |
@check_answer_label = "Person #{person_display_number}’s age" |
||||||
@header = "Age" |
@header = "Age" |
||||||
@type = "numeric" |
@type = "numeric" |
||||||
@page = page |
@page = page |
||||||
@width = 3 |
@width = 3 |
||||||
@inferred_check_answers_value = { |
@inferred_check_answers_value = { |
||||||
"condition" => { "age#{person_database_number(PERSON_INDEX)}_known" => 1 }, |
"condition" => { field_for_person("age", "_known") => 1 }, |
||||||
"value" => "Not known", |
"value" => "Not known", |
||||||
} |
} |
||||||
@check_answers_card_number = person_database_number(PERSON_INDEX) |
@check_answers_card_number = person_index |
||||||
end |
end |
||||||
|
|
||||||
PERSON_INDEX = { |
|
||||||
"age2" => 2, |
|
||||||
"age3" => 3, |
|
||||||
"age4" => 4, |
|
||||||
"age5" => 5, |
|
||||||
"age6" => 6, |
|
||||||
}.freeze |
|
||||||
end |
end |
||||||
|
|||||||
@ -1,38 +1,30 @@ |
|||||||
class Form::Sales::Questions::PersonAgeKnown < ::Form::Question |
class Form::Sales::Questions::PersonAgeKnown < ::Form::Sales::Questions::Person |
||||||
def initialize(id, hsh, page) |
def initialize(id, hsh, page, person_index:) |
||||||
super |
super |
||||||
@check_answer_label = "Person #{person_display_number(PERSON_INDEX)}’s age known?" |
@check_answer_label = "Person #{person_display_number}’s age known?" |
||||||
@header = "Do you know person #{person_display_number(PERSON_INDEX)}’s age?" |
@header = "Do you know person #{person_display_number}’s age?" |
||||||
@type = "radio" |
@type = "radio" |
||||||
@answer_options = ANSWER_OPTIONS |
@answer_options = ANSWER_OPTIONS |
||||||
@page = page |
@page = page |
||||||
@hint_text = "" |
@hint_text = "" |
||||||
@conditional_for = { |
@conditional_for = { |
||||||
"age#{person_database_number(PERSON_INDEX)}" => [0], |
field_for_person("age") => [0], |
||||||
} |
} |
||||||
@hidden_in_check_answers = { |
@hidden_in_check_answers = { |
||||||
"depends_on" => [ |
"depends_on" => [ |
||||||
{ |
{ |
||||||
"age#{person_database_number(PERSON_INDEX)}_known" => 0, |
field_for_person("age", "_known") => 0, |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
"age#{person_database_number(PERSON_INDEX)}_known" => 1, |
field_for_person("age", "_known") => 1, |
||||||
}, |
}, |
||||||
], |
], |
||||||
} |
} |
||||||
@check_answers_card_number = person_database_number(PERSON_INDEX) |
@check_answers_card_number = @person_index |
||||||
end |
end |
||||||
|
|
||||||
ANSWER_OPTIONS = { |
ANSWER_OPTIONS = { |
||||||
"0" => { "value" => "Yes" }, |
"0" => { "value" => "Yes" }, |
||||||
"1" => { "value" => "No" }, |
"1" => { "value" => "No" }, |
||||||
}.freeze |
}.freeze |
||||||
|
|
||||||
PERSON_INDEX = { |
|
||||||
"age2_known" => 2, |
|
||||||
"age3_known" => 3, |
|
||||||
"age4_known" => 4, |
|
||||||
"age5_known" => 5, |
|
||||||
"age6_known" => 6, |
|
||||||
}.freeze |
|
||||||
end |
end |
||||||
|
|||||||
Loading…
Reference in new issue