Browse Source

Add required field errors to your children table

pull/160/head
ariannedee 5 years ago
parent
commit
be444f63f1
5 changed files with 112 additions and 16 deletions
  1. +17
    -6
      edivorce/apps/core/static/js/main.js
  2. +1
    -1
      edivorce/apps/core/templates/partials/required.html
  3. +11
    -7
      edivorce/apps/core/templates/question/06_children_your_children.html
  4. +78
    -0
      edivorce/apps/core/utils/question_step_mapping.py
  5. +5
    -2
      edivorce/apps/core/utils/user_response.py

+ 17
- 6
edivorce/apps/core/static/js/main.js View File

@ -478,12 +478,12 @@ $(function () {
} }
}; };
var returnToParent = function(options) {
var returnToParent = function(save) {
$('.children-questions').hide(); $('.children-questions').hide();
$('.children-list').show(); $('.children-list').show();
clearQuestionWellError();
clearQuestionWellError(save);
enableChildrenFooterNav({page:'review'}); enableChildrenFooterNav({page:'review'});
saveChildQuestions(options);
saveChildQuestions({persist: save});
populateChildrenFactSheets(); populateChildrenFactSheets();
}; };
@ -494,10 +494,15 @@ $(function () {
} }
}; };
var clearQuestionWellError = function() {
var clearQuestionWellError = function(removeTableError) {
$('.children-questions .question-well').each(function () { $('.children-questions .question-well').each(function () {
$(this).removeClass('error'); $(this).removeClass('error');
}); });
if (removeTableError) {
var $childrenTable = $('.children-list.question-well');
$childrenTable.removeClass('error');
$childrenTable.find('.warning').remove();
}
}; };
var checkNoEmptyField = function() { var checkNoEmptyField = function() {
@ -508,14 +513,19 @@ $(function () {
var questionWell = $(this); var questionWell = $(this);
questionWell.removeClass('error'); questionWell.removeClass('error');
questionWell.find('input').each(function (index, inputField) { questionWell.find('input').each(function (index, inputField) {
questionWell.find('.required').hide();
$(inputField).removeClass('error');
if (inputField.type === 'text') { if (inputField.type === 'text') {
if (inputField.value === '') { if (inputField.value === '') {
isNotEmpty = false; isNotEmpty = false;
$(inputField).addClass('error');
questionWell.addClass('error'); questionWell.addClass('error');
questionWell.find('.required').show();
} else if (inputField.id === 'childs_birth_date') { } else if (inputField.id === 'childs_birth_date') {
if (!moment(inputField.value, "MMM D, YYYY").isValid()) { if (!moment(inputField.value, "MMM D, YYYY").isValid()) {
isNotEmpty = false; isNotEmpty = false;
questionWell.addClass('error'); questionWell.addClass('error');
questionWell.find('.required').show();
} }
} else if (inputField.id === 'childs_name') { } else if (inputField.id === 'childs_name') {
// check for digits in the name // check for digits in the name
@ -528,6 +538,7 @@ $(function () {
if (questionWell.find('input:radio:checked').length === 0) { if (questionWell.find('input:radio:checked').length === 0) {
isNotEmpty = false; isNotEmpty = false;
questionWell.addClass('error'); questionWell.addClass('error');
questionWell.find('.required').show();
} }
return false; return false;
} }
@ -542,7 +553,7 @@ $(function () {
$('#btn_save_child').on('click', function(e) { $('#btn_save_child').on('click', function(e) {
e.preventDefault(); e.preventDefault();
if (checkNoEmptyField() === true) { if (checkNoEmptyField() === true) {
returnToParent({persist: true});
returnToParent(true);
} else { } else {
scrollToFirstError(); scrollToFirstError();
} }
@ -557,7 +568,7 @@ $(function () {
$('#btn_revert_child').on('click', function(e) { $('#btn_revert_child').on('click', function(e) {
e.preventDefault(); e.preventDefault();
returnToParent({persist: false});
returnToParent(false);
// Delete the empty row added to the children table when adding new child. // Delete the empty row added to the children table when adding new child.
// Empty row will always be the last row of the table. // Empty row will always be the last row of the table.


+ 1
- 1
edivorce/apps/core/templates/partials/required.html View File

@ -1 +1 @@
<span class="required">* Required</span>
<span class="required" {% if hidden %}hidden{% endif %}>* Required</span>

+ 11
- 7
edivorce/apps/core/templates/question/06_children_your_children.html View File

@ -52,7 +52,9 @@
and how they will spend time with each parent. and how they will spend time with each parent.
</p> </p>
{% endif %} {% endif %}
<div class="question-well children-list">
<div class="question-well children-list {% if claimant_children_error %}error{% endif %}">
<p class="warning">* You have indicated that you have children of the marriage. This includes children under and over the age of 19. Their details
must be added below.</p>
<table id="claimant_children" class="list-builder"> <table id="claimant_children" class="list-builder">
<thead> <thead>
<tr> <tr>
@ -82,7 +84,9 @@
<tbody> <tbody>
<tr> <tr>
<td id="btn_add_child" class="btn-add-child fact-sheet-control" colspan="5" readonly> <td id="btn_add_child" class="btn-add-child fact-sheet-control" colspan="5" readonly>
<a href="#add"><i class="fa fa-plus btn-add-child"></i> Add Child</a>
<a href="#add"><i class="fa fa-plus btn-add-child"></i> Add Child{% if claimant_children_error %}
{% include 'partials/required.html' with hidden=True %}{% endif %}
</a>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -92,7 +96,7 @@
<div class="children-questions" hidden> <div class="children-questions" hidden>
<div class="question-well"> <div class="question-well">
<h3>What is your child's name?</h3>
<h3>What is your child's name?{% include 'partials/required.html' with hidden=True %}</h3>
<p>Enter full name</p> <p>Enter full name</p>
<span class="form-group"> <span class="form-group">
{% input_field type="text" name="child_name" class="form-block input-wide response-textbox children-input-block name" id="childs_name" placeholder="First, Middle, Last Name" data_mirror="true" data_mirror_target="#child_name_0" data_skip_ajax="true" %} {% input_field type="text" name="child_name" class="form-block input-wide response-textbox children-input-block name" id="childs_name" placeholder="First, Middle, Last Name" data_mirror="true" data_mirror_target="#child_name_0" data_skip_ajax="true" %}
@ -101,7 +105,7 @@
<div class="question-well"> <div class="question-well">
<h3>What is your child's date of birth?</h3>
<h3>What is your child's date of birth?{% include 'partials/required.html' with hidden=True %}</h3>
<p> <p>
<span class="input-group date date-picker-group"> <span class="input-group date date-picker-group">
{% input_field type="text" name="child_birth_date" class="date-picker form-control children-input-block" id="childs_birth_date" placeholder="MMM D, YYYY" data_mirror="true" data_mirror_target="#child_birth_date_0" data_skip_ajax="true" %} {% input_field type="text" name="child_birth_date" class="date-picker form-control children-input-block" id="childs_birth_date" placeholder="MMM D, YYYY" data_mirror="true" data_mirror_target="#child_birth_date_0" data_skip_ajax="true" %}
@ -113,7 +117,7 @@
</div> </div>
<div class="question-well"> <div class="question-well">
<h3>Where/whom does this child currently live with?</h3>
<h3>Where/whom does this child currently live with?{% include 'partials/required.html' with hidden=True %}</h3>
<p>Please select one</p> <p>Please select one</p>
<div class="radio"> <div class="radio">
<label class="tight-spacing"> <label class="tight-spacing">
@ -168,7 +172,7 @@
</div> </div>
<div class="question-well"> <div class="question-well">
<h3>What is your relationship to this child?</h3>
<h3>What is your relationship to this child?{% include 'partials/required.html' with hidden=True %}</h3>
<div class="radio"> <div class="radio">
<label>{% input_field type="radio" class="radio-with-other children-input-block" name="child_relationship_to_you" value="Natural child" data_mirror="true" data_mirror_target="#child_relationship_you_0" data_skip_ajax="true" %}Natural <label>{% input_field type="radio" class="radio-with-other children-input-block" name="child_relationship_to_you" value="Natural child" data_mirror="true" data_mirror_target="#child_relationship_you_0" data_skip_ajax="true" %}Natural
child</label> child</label>
@ -235,7 +239,7 @@
</div> </div>
<div class="question-well"> <div class="question-well">
<h3>What is your spouse's relationship to this child?</h3>
<h3>What is your spouse's relationship to this child?{% include 'partials/required.html' with hidden=True %}</h3>
<div class="radio"> <div class="radio">
<label>{% input_field type="radio" class="radio-with-other children-input-block" name="child_relationship_to_spouse" value="Natural child" data_mirror="true" data_mirror_target="#child_relationship_spouse_0" data_skip_ajax="true" %}Natural <label>{% input_field type="radio" class="radio-with-other children-input-block" name="child_relationship_to_spouse" value="Natural child" data_mirror="true" data_mirror_target="#child_relationship_spouse_0" data_skip_ajax="true" %}Natural
child</label> child</label>


+ 78
- 0
edivorce/apps/core/utils/question_step_mapping.py View File

@ -173,6 +173,83 @@ question_step_mapping = {
'filing_locations': ['court_registry_for_filing'], 'filing_locations': ['court_registry_for_filing'],
} }
substep_mapping = {
'your_children': ['claimant_children'],
'': ['how_will_calculate_income',
'annual_gross_income',
'spouse_annual_gross_income',
'payor_monthly_child_support_amount',
'special_extraordinary_expenses',
'child_support_payor',
'claiming_undue_hardship',
'claimants_agree_to_child_support_amount',
'medical_coverage_available',
'whose_plan_is_coverage_under',
'child_support_payments_in_arrears',
'child_support_arrears_amount',
'child_support_in_order',
'order_monthly_child_support_amount',
'child_support_in_order_reason',
'child_support_payment_special_provisions',
'number_children_seeking_support',
'child_support_amount_under_high_income',
'percent_income_over_high_income_limit',
'amount_income_over_high_income_limit',
'total_guideline_amount',
'agree_to_child_support_amount',
'agreed_child_support_amount',
'reason_child_support_amount',
'have_separation_agreement',
'have_court_order',
'what_parenting_arrangements',
'want_parenting_arrangements',
'order_respecting_arrangement',
'order_for_child_support',
'child_support_act',
'spouse_number_children_seeking_support',
'spouse_child_support_amount_under_high_income',
'spouse_percent_income_over_high_income_limit',
'spouse_amount_income_over_high_income_limit',
'spouse_total_guideline_amount',
'spouse_agree_to_child_support_amount',
'spouse_agreed_child_support_amount',
'spouse_reason_child_support_amount',
'you_spouse_entered_agreement',
'claimant_debts',
'claimant_expenses',
'supporting_non_dependents',
'supporting_dependents',
'supporting_disabled',
'undue_hardship',
'income_others',
'total_income_others',
'number_of_children',
'time_spent_with_you',
'time_spent_with_spouse',
'annual_gross_income',
'spouse_annual_gross_income',
'your_child_support_paid_b',
'your_spouse_child_support_paid_b',
'your_child_support_paid_c',
'your_spouse_child_support_paid_c',
'extra_ordinary_expenses_you',
'extra_ordinary_expenses_spouse',
'additional_relevant_spouse_children_info',
'difference_between_claimants',
'child_care_expenses',
'children_healthcare_premiums',
'health_related_expenses',
'extraordinary_educational_expenses',
'post_secondary_expenses',
'extraordinary_extracurricular_expenses',
'total_section_seven_expenses',
'your_proportionate_share_percent',
'your_proportionate_share_amount',
'spouse_proportionate_share_percent',
'spouse_proportionate_share_amount',
'describe_order_special_extra_expenses']
}
page_step_mapping = { page_step_mapping = {
'orders': 'which_orders', 'orders': 'which_orders',
@ -180,6 +257,7 @@ page_step_mapping = {
'respondent': 'your_spouse', 'respondent': 'your_spouse',
'marriage': 'your_marriage', 'marriage': 'your_marriage',
'separation': 'your_separation', 'separation': 'your_separation',
'children': 'your_children',
'support': 'spousal_support', 'support': 'spousal_support',
'property': 'property_and_debt', 'property': 'property_and_debt',
'other_orders': 'other_orders', 'other_orders': 'other_orders',


+ 5
- 2
edivorce/apps/core/utils/user_response.py View File

@ -1,5 +1,5 @@
from edivorce.apps.core.models import UserResponse, Question from edivorce.apps.core.models import UserResponse, Question
from edivorce.apps.core.utils.question_step_mapping import question_step_mapping
from edivorce.apps.core.utils.question_step_mapping import question_step_mapping, substep_mapping
from edivorce.apps.core.utils.step_completeness import evaluate_numeric_condition from edivorce.apps.core.utils.step_completeness import evaluate_numeric_condition
from collections import OrderedDict from collections import OrderedDict
@ -14,7 +14,10 @@ def get_responses_from_db(bceid_user, show_errors=False, step=None, substep=None
elif answer.value.strip('[').strip(']'): elif answer.value.strip('[').strip(']'):
responses_dict[answer.question.key] = answer.value responses_dict[answer.question.key] = answer.value
if show_errors: if show_errors:
step_questions = question_step_mapping.get(step, [])
if substep:
step_questions = substep_mapping.get(substep, [])
else:
step_questions = question_step_mapping.get(step, [])
questions = Question.objects.filter(key__in=step_questions) questions = Question.objects.filter(key__in=step_questions)
for question in questions: for question in questions:
if responses_dict.get(question.key): if responses_dict.get(question.key):


Loading…
Cancel
Save