Browse Source

refactor indexes

CLDC-1530-working-situation
Kat 2 years ago
parent
commit
f004d3cc6f
  1. 40
      app/models/form/sales/questions/person_working_situation.rb

40
app/models/form/sales/questions/person_working_situation.rb

@ -1,12 +1,12 @@
class Form::Sales::Questions::PersonWorkingSituation < ::Form::Question
def initialize(id, hsh, page)
super
@check_answer_label = "Person #{PERSON_INDEX[page.id]}’s working situation"
@header = "Which of these best describes Person #{PERSON_INDEX[page.id]}’s working situation?"
@check_answer_label = "Person #{person_display_number}’s working situation"
@header = "Which of these best describes Person #{person_display_number}’s working situation?"
@type = "radio"
@page = page
@answer_options = ANSWER_OPTIONS
@check_answers_card_number = CARD_INDEX[page.id]
@check_answers_card_number = person_database_number
end
ANSWER_OPTIONS = {
@ -23,25 +23,23 @@ class Form::Sales::Questions::PersonWorkingSituation < ::Form::Question
"9" => { "value" => "Child under 16" },
}.freeze
CARD_INDEX = {
"person_1_working_situation" => 2,
"person_1_working_situation_joint_purchase" => 3,
"person_2_working_situation" => 3,
"person_2_working_situation_joint_purchase" => 4,
"person_3_working_situation" => 4,
"person_3_working_situation_joint_purchase" => 5,
"person_4_working_situation" => 5,
"person_4_working_situation_joint_purchase" => 6,
}.freeze
def person_database_number
PERSON_INDEX[id]
end
PERSON_INDEX = {
"person_1_working_situation" => 1,
"person_1_working_situation_joint_purchase" => 1,
"person_2_working_situation" => 2,
"person_2_working_situation_joint_purchase" => 2,
"person_3_working_situation" => 3,
"person_3_working_situation_joint_purchase" => 3,
"person_4_working_situation" => 4,
"person_4_working_situation_joint_purchase" => 4,
"ecstat2" => 2,
"ecstat3" => 3,
"ecstat4" => 4,
"ecstat5" => 5,
"ecstat6" => 6,
}.freeze
def person_display_number
joint_purchase? ? PERSON_INDEX[id] - 2 : PERSON_INDEX[id] - 1
end
def joint_purchase?
page.id.include?("_joint_purchase")
end
end

Loading…
Cancel
Save