@ -99,13 +99,6 @@ class Form::Question
! ! derived
! ! derived
end
end
def has_inferred_check_answers_value? ( log )
return true if selected_answer_option_is_derived? ( log )
return inferred_check_answers_value & . any? { | inferred_value | inferred_value [ " condition " ] . values . first == log [ inferred_value [ " condition " ] . keys . first ] } if inferred_check_answers_value . present?
false
end
def displayed_answer_options ( log , _current_user = nil )
def displayed_answer_options ( log , _current_user = nil )
answer_options . select do | _key , val |
answer_options . select do | _key , val |
! val . is_a? ( Hash ) || ! val [ " depends_on " ] || form . depends_on_met ( val [ " depends_on " ] , log )
! val . is_a? ( Hash ) || ! val [ " depends_on " ] || form . depends_on_met ( val [ " depends_on " ] , log )
@ -113,7 +106,7 @@ class Form::Question
end
end
def action_text ( log )
def action_text ( log )
if has_inferred_check_answers_value? ( log )
if is_derived_or_ has_inferred_check_answers_value?( log )
" Change "
" Change "
elsif type == " checkbox "
elsif type == " checkbox "
answer_options . keys . any? { | key | value_is_yes? ( log [ key ] ) } ? " Change " : " Answer "
answer_options . keys . any? { | key | value_is_yes? ( log [ key ] ) } ? " Change " : " Answer "
@ -261,6 +254,10 @@ class Form::Question
@guidance_partial && @guidance_position == GuidancePosition :: BOTTOM
@guidance_partial && @guidance_position == GuidancePosition :: BOTTOM
end
end
def is_derived_or_has_inferred_check_answers_value? ( log )
selected_answer_option_is_derived? ( log ) || has_inferred_check_answers_value? ( log )
end
private
private
def selected_answer_option_is_derived? ( log )
def selected_answer_option_is_derived? ( log )
@ -268,6 +265,12 @@ private
selected_option . is_a? ( Hash ) && selected_option [ " depends_on " ] && form . depends_on_met ( selected_option [ " depends_on " ] , log )
selected_option . is_a? ( Hash ) && selected_option [ " depends_on " ] && form . depends_on_met ( selected_option [ " depends_on " ] , log )
end
end
def has_inferred_check_answers_value? ( log )
return false unless inferred_check_answers_value
inferred_check_answers_value & . any? { | inferred_value | log [ inferred_value [ " condition " ] . keys . first ] == inferred_value [ " condition " ] . values . first }
end
def has_inferred_display_value? ( log )
def has_inferred_display_value? ( log )
inferred_check_answers_value . present? && inferred_check_answers_value . any? { | inferred_value | log [ inferred_value [ " condition " ] . keys . first ] == inferred_value [ " condition " ] . values . first }
inferred_check_answers_value . present? && inferred_check_answers_value . any? { | inferred_value | log [ inferred_value [ " condition " ] . keys . first ] == inferred_value [ " condition " ] . values . first }
end
end
@ -310,7 +313,7 @@ private
def inferred_answer_value ( log )
def inferred_answer_value ( log )
return unless inferred_check_answers_value
return unless inferred_check_answers_value
inferred_answer = inferred_check_answers_value . find { | inferred_value | inferred_value [ " condition " ] . values . first == log [ inferred_value [ " condition " ] . keys . first ] }
inferred_answer = inferred_check_answers_value . find { | inferred_value | log [ inferred_value [ " condition " ] . keys . first ] == inferred_value [ " condition " ] . values . first }
inferred_answer [ " value " ] if inferred_answer . present?
inferred_answer [ " value " ] if inferred_answer . present?
end
end