From 160c4f7e5a815b37b4b36f38b7deeb3ced96589a Mon Sep 17 00:00:00 2001 From: Benard Ebinu Date: Wed, 3 Jan 2018 15:29:18 -0800 Subject: [PATCH] DIV-627: All fields in Fact Sheet B properly persist --- edivorce/apps/core/static/js/main.js | 24 +++++ .../question/06_children_your_children.html | 20 ++-- edivorce/fixtures/Question.json | 96 +++++++++++++++++++ 3 files changed, 130 insertions(+), 10 deletions(-) diff --git a/edivorce/apps/core/static/js/main.js b/edivorce/apps/core/static/js/main.js index ea5dd9b9..dfc9ff12 100755 --- a/edivorce/apps/core/static/js/main.js +++ b/edivorce/apps/core/static/js/main.js @@ -59,6 +59,16 @@ $(function () { // be persisted to the server. $('[data-save_row="true"]').on('change', saveListControlRow); + // All elements tagged with the following delta related data attributes + // will have the delta between the two amounts calculated and the result written to + // the html elements at the delta target selector. Will store the absolute value of the difference + // of the terms. + // data-calc_delta=[true|false] - indicates input field should be included as term in the delta + // data-delta_term_selector=[selector] - all elements with the same delta class identifier will be + // addends of the delta. + // data-delta_target_selector=[selector] - all of the html elements where result of difference will be written + $('[data-calc_delta="true"]').on('change', deltaFieldOnChange); + $('[data-calc_delta="true"]').each(deltaFieldOnChange); var fraction = function(part1, part2) { part1 = parseFloat(part1); @@ -774,6 +784,20 @@ var sumFields = function(addend_selector, sum_selector) { } }; + +var deltaFieldOnChange = function() { + var deltaTermSelector = $(this).attr('data-delta_term_selector'); + var deltaTargetSelector = $(this).attr('data-delta_target_selector'); + + var delta = 0; + $(deltaTermSelector).each(function(){ + delta = Math.abs($(this).val() - delta); + }); + $(deltaTargetSelector).each(function() { + $(this).val(delta); + }); +}; + // Configuration for datepicker var date_picker = function (selector, showOnFocus) { var startDate, endDate; diff --git a/edivorce/apps/core/templates/question/06_children_your_children.html b/edivorce/apps/core/templates/question/06_children_your_children.html index 3f20705b..5323b476 100644 --- a/edivorce/apps/core/templates/question/06_children_your_children.html +++ b/edivorce/apps/core/templates/question/06_children_your_children.html @@ -285,10 +285,10 @@ What is the approximate amount of time the children spend with each parent? - {% input_field type="number" name="time_spent_with_you" value="0" class="fact-sheet-input" %} + {% input_field type="number" name="time_spent_with_you" class="fact-sheet-input" %} - {% input_field type="number" name="time_spent_with_spouse" value="0" class="fact-sheet-input" %} + {% input_field type="number" name="time_spent_with_spouse" class="fact-sheet-input" %} @@ -329,12 +329,12 @@
- {% money_input_field name="your_child_support_paid" value="0" class="fact-sheet-input" %} + {% money_input_field name="your_child_support_paid" class="fact-sheet-input claimants-child-support-amounts" data_calc_delta="true" data_delta_term_selector=".claimants-child-support-amounts" data_delta_target_selector="input[name=difference_between_claimants]" %}
- {% money_input_field name="your_spouse_child_support_paid" value="0" class="fact-sheet-input" %} + {% money_input_field name="your_spouse_child_support_paid" class="fact-sheet-input claimants-child-support-amounts" data_calc_delta="true" data_delta_term_selector=".claimants-child-support-amounts" data_delta_target_selector="input[name=difference_between_claimants]" %}
@@ -402,7 +402,7 @@ Difference between the Guidelines table amount of the claimant and the Guidelines table amount of the respondent - {% input_field type="number" name="difference_between_claimants" value="0" class="fact-sheet-input" readonly="" %} + {% input_field type="number" name="difference_between_claimants" value="" class="fact-sheet-input" readonly="" %} @@ -420,25 +420,25 @@ ) to be paid annually - {% input_field type="number" name="extra_ordinary_expenses_you" value="0" class="fact-sheet-input" %} + {% input_field type="number" name="extra_ordinary_expenses_you" class="fact-sheet-input" %} - {% input_field type="number" name="extra_ordinary_expenses_spouse" value="0" class="fact-sheet-input" %} + {% input_field type="number" name="extra_ordinary_expenses_spouse" class="fact-sheet-input" %} Any other relevant information regarding the conditions, means, needs and other circumstances of each spouse or of any child for whom support is sought? - {% input_field type="textarea" name="additional_relevant_spouse_children_info" value="" maxlength="500" rows="3" class="fact-sheet-input" %} + {% input_field type="textarea" name="additional_relevant_spouse_children_info" maxlength="500" rows="3" class="fact-sheet-input form-control response-textarea" %} Amount of child support to be paid per month by < Claimant 1 or Claimant 2> - - {{ difference_between_claimants }} + + {% input_field type="number" name="difference_between_claimants" value="" class="fact-sheet-input" readonly="" %} diff --git a/edivorce/fixtures/Question.json b/edivorce/fixtures/Question.json index fdd848be..44465768 100644 --- a/edivorce/fixtures/Question.json +++ b/edivorce/fixtures/Question.json @@ -1314,5 +1314,101 @@ }, "model": "core.question", "pk": "spouse_proportionate_share_amount" +}, +{ + "fields": { + "name": "Number of children", + "description": "For Step 6, Your children - Your children - Fact Sheet B Shared Custody", + "summary_order": 0, + "required": "Conditional", + "conditional_target": "claimant_children", + "reveal_response": "" + }, + "model": "core.question", + "pk": "number_of_children" +}, +{ + "fields": { + "name": "What is the approximate amount of time the children spend with each parent?", + "description": "For Step 6, Your children - Your children - Fact Sheet B Shared Custody", + "summary_order": 0, + "required": "Conditional", + "conditional_target": "claimant_children", + "reveal_response": "" + }, + "model": "core.question", + "pk": "time_spent_with_you" +}, +{ + "fields": { + "name": "What is the approximate amount of time the children spend with each parent?", + "description": "For Step 6, Your children - Your children - Fact Sheet B Shared Custody", + "summary_order": 0, + "required": "Conditional", + "conditional_target": "claimant_children", + "reveal_response": "" + }, + "model": "core.question", + "pk": "time_spent_with_spouse" +}, +{ + "fields": { + "name": "What is the monthly amount for child support (as per Federal Child Support Guidelines)?", + "description": "For Step 6, Your children - Your children - Fact Sheet B Shared Custody", + "summary_order": 0, + "required": "Conditional", + "conditional_target": "claimant_children", + "reveal_response": "" + }, + "model": "core.question", + "pk": "your_child_support_paid" +}, +{ + "fields": { + "name": "What is the monthly amount for child support (as per Federal Child Support Guidelines)?", + "description": "For Step 6, Your children - Your children - Fact Sheet B Shared Custody", + "summary_order": 0, + "required": "Conditional", + "conditional_target": "claimant_children", + "reveal_response": "" + }, + "model": "core.question", + "pk": "your_spouse_child_support_paid" +}, +{ + "fields": { + "name": "Special or extraordinary expenses (as per Section 7 of the Federal Child Support Guidelines) to be paid annually", + "description": "For Step 6, Your children - Your children - Fact Sheet B Shared Custody", + "summary_order": 0, + "required": "Conditional", + "conditional_target": "claimant_children", + "reveal_response": "" + }, + "model": "core.question", + "pk": "extra_ordinary_expenses_you" +}, +{ + "fields": { + "name": "Special or extraordinary expenses (as per Section 7 of the Federal Child Support Guidelines) to be paid annually", + "description": "For Step 6, Your children - Your children - Fact Sheet B Shared Custody", + "summary_order": 0, + "required": "Conditional", + "conditional_target": "claimant_children", + "reveal_response": "" + }, + "model": "core.question", + "pk": "extra_ordinary_expenses_spouse" +}, +{ + "fields": { + "name": "Any other relevant information regarding the conditions, means, needs and other circumstances of each spouse or of any child for whom support is sought?", + "description": "For Step 6, Your children - Your children - Fact Sheet B Shared Custody", + "summary_order": 0, + "required": "Conditional", + "conditional_target": "claimant_children", + "reveal_response": "" + }, + "model": "core.question", + "pk": "additional_relevant_spouse_children_info" } ]