From e7d5c9a19bdf77b99dd37884cf78783fc2d4dc2d Mon Sep 17 00:00:00 2001 From: Benard Ebinu Date: Fri, 10 Nov 2017 17:10:10 -0800 Subject: [PATCH] DIV-519: Adding questions to find out the number of children and displaying appropriate warning messages --- .gitignore | 1 + edivorce/apps/core/static/js/functions.js | 69 ++++++++++++++----- edivorce/apps/core/static/js/main.js | 2 +- .../templates/prequalification/step_04.html | 47 ++++++++++++- .../apps/core/templatetags/input_field.py | 2 + .../apps/core/utils/question_step_mapping.py | 4 +- edivorce/apps/core/utils/step_completeness.py | 32 ++++++++- edivorce/fixtures/Question.json | 40 +++++++---- 8 files changed, 161 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index 5d44b85e..0cca26b7 100644 --- a/.gitignore +++ b/.gitignore @@ -69,3 +69,4 @@ target/ # Noise .DS_Store .sass-cache/ +edivorce/apps/core/static/css/main.css.map diff --git a/edivorce/apps/core/static/js/functions.js b/edivorce/apps/core/static/js/functions.js index a8d8fcd0..f6933db7 100644 --- a/edivorce/apps/core/static/js/functions.js +++ b/edivorce/apps/core/static/js/functions.js @@ -7,15 +7,59 @@ var reveal = function(el) { var id = '#' + el.data("target_id"); var css_class = el.data("target_class"); var related_id = el.data("related_id"); - // hide or show based on target id + var reveal_condition = el.data("reveal_condition"); + var should_reveal = true; + + if (reveal_condition !== undefined) { + should_reveal = false; + if (reveal_condition.startsWith(">=")) { + should_reveal = el.val() >= parseInt(reveal_condition.slice(2), 10); + } else if (reveal_condition.startsWith("<=")) { + should_reveal = el.val() <= parseInt(reveal_condition.slice(2), 10); + } else if (reveal_condition.startsWith("==")) { + should_reveal = el.val() === parseInt(reveal_condition.slice(2), 10); + } else if (reveal_condition.startsWith("<")) { + should_reveal = el.val() < parseInt(reveal_condition.slice(1), 10); + } else if (reveal_condition.startsWith(">")) { + should_reveal = el.val() > parseInt(reveal_condition.slice(1), 10) ; + } + + if (!should_reveal) { + if (related_id !== undefined){ + $('#' + related_id).hide(); + } + if (css_class !== undefined){ + $('.' + css_class).hide(); + } + } + } + + if (should_reveal) { + showHideTargetId(el, id, related_id); + showHideRevealClass(el, css_class); + + if (el.prop('name') === "provide_certificate_later" || el.prop('name') === "original_marriage_certificate") { + if ($('input[name=provide_certificate_later]:checked').val() !== 'YES' && $('input[name=original_marriage_certificate]:checked').val() === 'NO') { + $('#is_certificate_in_english').hide(); + } + else { + $('#is_certificate_in_english').show(); + } + } + } +}; + +// hide or show based on target id +var showHideTargetId = function(el, id, related_id) { if (el.data("reveal_target") === true && el.prop('checked')) { $(id).show(); if (related_id !== undefined){ $('#' + related_id).hide(); } if (id === "#has_children"){ - reveal($("input[name=any_under_19]:checked")); + reveal($("input[name=number_children_over_19]")); } + // reveal nested question as well if (id ==="#marriage_certificate"){ reveal($("input[name=provide_certificate_later]:checked")); @@ -26,24 +70,17 @@ var reveal = function(el) { $('#' + related_id).show(); } } +}; - // hide or show based on target css class +// Controls show or hiding a target css class +var showHideRevealClass = function(el, target_css_class) { if (el.data("reveal_class") === false) { - if (css_class !== undefined){ - $('.' + css_class).hide(); + if (target_css_class !== undefined){ + $('.' + target_css_class).hide(); } } else { - if (css_class !== undefined){ - $('.' + css_class).show(); - } - } - - if (el.prop('name') === "provide_certificate_later" || el.prop('name') === "original_marriage_certificate"){ - if ($('input[name=provide_certificate_later]:checked').val() !== 'YES' && $('input[name=original_marriage_certificate]:checked').val() === 'NO') { - $('#is_certificate_in_english').hide(); - } - else { - $('#is_certificate_in_english').show(); + if (target_css_class !== undefined){ + $('.' + target_css_class).show(); } } }; diff --git a/edivorce/apps/core/static/js/main.js b/edivorce/apps/core/static/js/main.js index 07b9c522..f70ccd94 100755 --- a/edivorce/apps/core/static/js/main.js +++ b/edivorce/apps/core/static/js/main.js @@ -50,7 +50,7 @@ $(function () { $(this).parent().find('.radio-with-other').prop('checked', true); }); - $("input[type=radio], input[type=checkbox], input[type=text], .response-textarea, .response-dropdown").on("change", ajaxOnChange); + $("input[type=number], input[type=radio], input[type=checkbox], input[type=text], .response-textarea, .response-dropdown").on("change", ajaxOnChange); // If relationship is common law and they want spousal support, update spouse_support_act with hidden input field, spouse_support_act_common_law if ($("#spouse_support_act_common_law").length) { diff --git a/edivorce/apps/core/templates/prequalification/step_04.html b/edivorce/apps/core/templates/prequalification/step_04.html index 45417ea6..7e5e6c4f 100644 --- a/edivorce/apps/core/templates/prequalification/step_04.html +++ b/edivorce/apps/core/templates/prequalification/step_04.html @@ -193,13 +193,13 @@

How many children are under the age of 19?

-{# {% input_field type="text" name="number_children_under_19" data_target_id="number_children_under_19" %}#} + {% input_field type="number" name="number_children_under_19" value="0" min="0" data_target_id="number_children_under_19" %}

How many children are 19 years or older?

-{# {% input_field type="text" name="number_children_over_19" data_target_id="number_children_over_19" data_reveal_target="true" data_related_id="financial_support" data_target_class="not-disqualified-age" data_reveal_class="false"%}#} + {% input_field type="number" name="number_children_over_19" value="0" min="0" data_target_id="number_children_over_19" data_related_id="financial_support" data_target_class="not-disqualified-age" data_reveal_class="true" data_reveal_condition=">0" %}
+ +
+
+

+ If you have a child support agreement, you can change it at any time if both of you agree. +

+

+ If the other party doesn’t agree with a change you want to make, you can apply to court + to set aside all or part of the agreement. The court would then replace it with a court + order. The court may set aside your agreement if it’s different from what the court would + have ordered under the law. +

+

+ If you have a court order, either party can apply to lower or raise child support payments + if there’s a change in circumstances, such as: +

+
    +
  • a long-term income change for the payor,
  • +
  • a change to the child’s special or extraordinary expenses, or
  • +
  • a change in parenting arrangements or contact.
  • +
+

+ The court can also change the order if: +

+
    +
  • circumstances have changed so much that a court would make a different order now,
  • +
  • one party didn’t provide all the required financial information when the order was made, or
  • +
  • there’s important new information that wasn’t available when the first order was made.
  • +
+

+ If you have taken over responsibility for the daily care of a child from the other parent + or guardian, you can apply to change the child support order or agreement so the other parent + or guardian pays you child support. +

+
+