From f35826bbcf8f2e3a114435e8ae3f5fb8e0fa6d19 Mon Sep 17 00:00:00 2001 From: Benard Ebinu Date: Tue, 9 Jan 2018 11:12:31 -0800 Subject: [PATCH] DIV-678: show fact sheet c when claimants have appropriate children arrangements --- edivorce/apps/core/static/js/main.js | 29 +++++++++++++--------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/edivorce/apps/core/static/js/main.js b/edivorce/apps/core/static/js/main.js index f28068d3..40bd3b7f 100755 --- a/edivorce/apps/core/static/js/main.js +++ b/edivorce/apps/core/static/js/main.js @@ -367,24 +367,18 @@ $(function () { }; var evaluateFactSheetShowCriteria = function(childrenData) { - var childWithBoth = false; + var childWithBoth = 0; var childWithYou = 0; var childWithSpouse = 0; - var childWithOther = 0; childrenData.forEach(function(child) { - if (child.child_live_with === 'Lives with both') { - childWithBoth |= true; + if (child.child_live_with === 'Lives with you' ) { + childWithYou += 1; } - if (childrenData.length > 1 ) { - if (child.child_live_with === 'Lives with you' ) { - childWithYou += 1; - } - if (child.child_live_with === 'Lives with spouse') { - childWithSpouse +=1 ; - } - if (child.child_live_with === 'Other') { - childWithOther +=1 ; - } + if (child.child_live_with === 'Lives with spouse') { + childWithSpouse +=1; + } + if (child.child_live_with === 'Lives with both') { + childWithBoth += 1; } }); @@ -396,9 +390,12 @@ $(function () { } // show fact sheet c - if (childWithYou === 1 && (childWithSpouse > 0 || childWithOther > 0 || childWithBoth)) { + // When the claimants have indicated that they have more than one child, then show fact sheet c if each + // claimant has sole custody of at least one of the children or if one claimant has sole custody of at least one + // child and the both claimants have shared custody of the remaining children. + if (childWithYou && (childWithSpouse || childWithBoth)) { $('#fact_sheet_c').show(); - } else if (childWithSpouse === 1 && (childWithYou > 0 || childWithOther > 0 || childWithBoth)) { + } else if (childWithSpouse && (childWithYou || childWithBoth)) { $('#fact_sheet_c').show(); } else { $('#fact_sheet_c').hide();