From 57541657cfcc4f447121106ebe1b40360bec6e5e Mon Sep 17 00:00:00 2001 From: Charles Shin Date: Wed, 9 Oct 2019 18:21:25 -0700 Subject: [PATCH] DIV-963: Updated child support act display logic and wording. --- .../migrations/0019_auto_20191008_2141.py | 22 +++++++++++ edivorce/apps/core/static/js/main.js | 38 +++++++++++++++++++ edivorce/apps/core/templates/pdf/form38.html | 2 +- .../question/06_children_what_for.html | 29 +++++++------- edivorce/apps/core/utils/derived.py | 11 +++++- 5 files changed, 86 insertions(+), 16 deletions(-) create mode 100644 edivorce/apps/core/migrations/0019_auto_20191008_2141.py diff --git a/edivorce/apps/core/migrations/0019_auto_20191008_2141.py b/edivorce/apps/core/migrations/0019_auto_20191008_2141.py new file mode 100644 index 00000000..3e47568c --- /dev/null +++ b/edivorce/apps/core/migrations/0019_auto_20191008_2141.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.18 on 2019-10-08 21:41 +from __future__ import unicode_literals + +from django.db import migrations + +def string_to_json(apps, schema_editor): + Responses = apps.get_model('core', 'UserResponse') + for response in Responses.objects.filter(question_id='child_support_act'): + if not (response.value.startswith('["') and response.value.endswith('"]')): + response.value = '["%s"]' % (response.value) + response.save() + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0018_bceiduser_has_accepted_terms'), + ] + + operations = [ + migrations.RunPython(string_to_json), + ] diff --git a/edivorce/apps/core/static/js/main.js b/edivorce/apps/core/static/js/main.js index 3785b0dc..b552b846 100755 --- a/edivorce/apps/core/static/js/main.js +++ b/edivorce/apps/core/static/js/main.js @@ -21,6 +21,13 @@ $('input[type=number]').each(function() { $(window).load(function(){ $('#questions_modal, #terms_modal').modal('show'); + + // Load child support act question text if child_suuport_in_order exist on the page and answered before. + var childSupport = $('input[name="child_support_in_order"]:checked'); + if (childSupport !== undefined) { + var wantChildSupport = childSupport.val() === 'NO' ? false : true; + updateChildSupportActQuestion(wantChildSupport); + } }); // Temporarily store table row data. @@ -1234,3 +1241,34 @@ $(".question-well").click(function () { $('.no-collapse').on('click', function (e) { e.stopPropagation(); }); + +// Handle complicated logic show/hide child support act question with different wordings on Step 6. What are you asking for. +$('input[name="child_support_in_order"]').change(function() { + var wantChildSupport = $(this).val() === 'NO' ? false : true; + updateChildSupportActQuestion(wantChildSupport); +}); + +var updateChildSupportActQuestion = function (wantChildSupport) { + var wantChildOrder = $('#child_support_act').data('want_child_order') === true ? true : false; + + if (!wantChildOrder) { + if (!wantChildSupport) { + $('#child_support_act').hide(); + } else { + $('#child_support_act').show(); + } + } else { + $('#child_support_act').show(); + var childSupportActQuestionText = ''; + + if (!wantChildSupport) { + childSupportActQuestionText = "Please indicate which act you are asking for an order regarding Arrangements for Parenting or Contact under."; + + $('#child_support_act_question').text(childSupportActQuestionText); + } else { + childSupportActQuestionText = "Please indicate which act you are asking for an order regarding Child Support and Arrangements for Parenting or Contact under."; + + $('#child_support_act_question').text(childSupportActQuestionText); + } + } +}; diff --git a/edivorce/apps/core/templates/pdf/form38.html b/edivorce/apps/core/templates/pdf/form38.html index 406e7678..d18f440f 100644 --- a/edivorce/apps/core/templates/pdf/form38.html +++ b/edivorce/apps/core/templates/pdf/form38.html @@ -177,7 +177,7 @@ {% if responses.children_of_marriage == 'YES' %}

There are children of the marriage as defined by - {{ responses.child_support_act }}, and + {{ derived.child_support_acts }}, and

    diff --git a/edivorce/apps/core/templates/question/06_children_what_for.html b/edivorce/apps/core/templates/question/06_children_what_for.html index 3612383d..bd573f52 100644 --- a/edivorce/apps/core/templates/question/06_children_what_for.html +++ b/edivorce/apps/core/templates/question/06_children_what_for.html @@ -379,19 +379,22 @@ {% endif %} -
    -

    Please indicate which act you are asking for child support under.

    -
    - -
    -
    - + {# DIV-963: Show/hide logic and text update will be handled by JavaScript function updateChildSupportActQuestion() #} +
    +

    Please indicate which act(s) you are asking for child support under.

    +
    +
    + +
    +
    + +