3 changed files with 65 additions and 0 deletions
@ -0,0 +1,16 @@
|
||||
class Form::Sales::Pages::PersonGenderSameAsSex < ::Form::Page |
||||
def initialize(id, hsh, subsection, person_index:) |
||||
super(id, hsh, subsection) |
||||
@person_index = person_index |
||||
@depends_on = [ |
||||
{ "details_known_#{person_index}" => 1 }, |
||||
] |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Sales::Questions::PersonGenderSameAsSex.new(nil, nil, self, person_index: @person_index), |
||||
Form::Sales::Questions::PersonGenderDescription.new(nil, nil, self, person_index: @person_index), |
||||
] |
||||
end |
||||
end |
||||
@ -0,0 +1,16 @@
|
||||
class Form::Sales::Questions::PersonGenderDescription < ::Form::Question |
||||
def initialize(id, hsh, page, person_index:) |
||||
super(id, hsh, page) |
||||
@id = "gender_description#{person_index}" |
||||
@type = "text" |
||||
@check_answers_card_number = person_index |
||||
@person_index = person_index |
||||
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
||||
end |
||||
|
||||
QUESTION_NUMBER_FROM_YEAR = { 2026 => 0 }.freeze |
||||
|
||||
def derived?(log) |
||||
log.public_send("gender_same_as_sex#{@person_index}") != 2 |
||||
end |
||||
end |
||||
@ -0,0 +1,33 @@
|
||||
class Form::Sales::Questions::PersonGenderSameAsSex < ::Form::Question |
||||
def initialize(id, hsh, page, person_index:) |
||||
super(id, hsh, page) |
||||
@id = "gender_same_as_sex#{person_index}" |
||||
@type = "radio" |
||||
@check_answers_card_number = person_index |
||||
@conditional_for = { "gender_description#{person_index}" => [2] } |
||||
@inferred_check_answers_value = [{ "condition" => { "gender_same_as_sex#{person_index}" => 2 }, "value" => "No" }] |
||||
@person_index = person_index |
||||
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { |
||||
"1" => { "value" => "Yes" }, |
||||
"2" => { "value" => "No, enter gender identity" }, |
||||
"divider" => { "value" => true }, |
||||
"3" => { "value" => "Person prefers not to say" }, |
||||
}.freeze |
||||
|
||||
def answer_options |
||||
ANSWER_OPTIONS |
||||
end |
||||
|
||||
QUESTION_NUMBER_FROM_YEAR = { 2026 => 0 }.freeze |
||||
|
||||
def label_from_value(value, _log = nil, _user = nil) |
||||
return unless value |
||||
|
||||
return "Prefers not to say" if value == 3 |
||||
|
||||
super |
||||
end |
||||
end |
||||
Loading…
Reference in new issue