7 changed files with 67 additions and 31 deletions
@ -0,0 +1,14 @@ |
|||||||
|
class Form::Sales::Pages::Person < ::Form::Page |
||||||
|
def initialize(id, hsh, subsection, person_index) |
||||||
|
super(id, hsh, subsection) |
||||||
|
@person_index = person_index |
||||||
|
end |
||||||
|
|
||||||
|
def person_display_number |
||||||
|
joint_purchase? ? @person_index - 2 : @person_index - 1 |
||||||
|
end |
||||||
|
|
||||||
|
def joint_purchase? |
||||||
|
id.include?("_joint_purchase") |
||||||
|
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(id, hsh, subsection, person_index) |
||||||
@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_#{person_display_number}" => 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("ecstat#{@person_index}", nil, self, @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 |
||||||
|
|||||||
@ -0,0 +1,14 @@ |
|||||||
|
class Form::Sales::Questions::Person < ::Form::Question |
||||||
|
def initialize(id, hsh, page, person_index) |
||||||
|
super(id, hsh, page) |
||||||
|
@person_index = person_index |
||||||
|
end |
||||||
|
|
||||||
|
def person_display_number |
||||||
|
joint_purchase? ? @person_index - 2 : @person_index - 1 |
||||||
|
end |
||||||
|
|
||||||
|
def joint_purchase? |
||||||
|
page.id.include?("_joint_purchase") |
||||||
|
end |
||||||
|
end |
||||||
Loading…
Reference in new issue