Browse Source

Added reconciliation period field

pull/160/head
Charles Shin 8 years ago
parent
commit
50492f70f5
13 changed files with 146 additions and 39 deletions
  1. +1
    -1
      edivorce/apps/core/static/js/ajax.js
  2. +41
    -1
      edivorce/apps/core/static/js/controllers.js
  3. +50
    -12
      edivorce/apps/core/static/js/main.js
  4. +2
    -4
      edivorce/apps/core/templates/partials/alias_field.html
  5. +2
    -2
      edivorce/apps/core/templates/partials/name_with_alias.html
  6. +6
    -0
      edivorce/apps/core/templates/partials/reconciliation_period.html
  7. +2
    -2
      edivorce/apps/core/templates/pdf/form1.html
  8. +2
    -2
      edivorce/apps/core/templates/pdf/form35.html
  9. +2
    -2
      edivorce/apps/core/templates/pdf/form36.html
  10. +19
    -2
      edivorce/apps/core/templates/prequalification/step_03.html
  11. +1
    -1
      edivorce/apps/core/templates/question/02_claimant.html
  12. +2
    -2
      edivorce/apps/core/templatetags/input_field.py
  13. +16
    -8
      edivorce/fixtures/Question.json

+ 1
- 1
edivorce/apps/core/static/js/ajax.js View File

@ -9,7 +9,7 @@ var ajaxOnChange = function () {
// Check if date is in valid format DD/MM/YYYY
if (el.is(".date-picker")){
isValid = validateDatePicker(value);
isValid = validateDate(value);
}
if (el.is("#email_textbox")){


+ 41
- 1
edivorce/apps/core/static/js/controllers.js View File

@ -89,6 +89,7 @@ var getValue = function(el, question){
// to remove last space and semi-colon
return JSON.stringify(value);
}
// for adding other_name fields, create list of [aliasType, alias]
else if (question == "other_name_you" || question == "other_name_spouse"){
var aliasType;
$('#other_names_fields').find("input[type=text]").each(function () {
@ -97,6 +98,32 @@ var getValue = function(el, question){
});
return JSON.stringify(value);
}
// for adding reconciliation_period fields, create list of [from_date, to_date] and
// check if from_date is earlier than to_date
// TODO clean up console.log
else if (question == "reconciliation_period"){
var to_date, from_date;
$('#reconciliation_period_fields').find(".reconciliation-from-date").each(function () {
to_date = $(this).closest('div').find(".reconciliation-to-date").val();
from_date = $(this).val();
// check if both date is in valid format and all
if (to_date != '' && from_date != '' && validateDate(to_date) && validateDate(from_date))
{
if (stringToDate(from_date) < stringToDate(to_date)){
value.push([from_date, to_date]);
}
else {
console.log(from_date + " : " + to_date);
console.log("From date must be smaller than To date")
}
}
else {
console.log("Invalid: " + from_date + " : " + to_date);
console.log("invalid date format");
}
});
return JSON.stringify(value);
}
else{
return el.val();
}
@ -104,9 +131,13 @@ var getValue = function(el, question){
// check if value in date field is in DD/MM/YYYY format
// and check if it is valid date and it is today or earlier
var validateDatePicker = function(value){
var validateDate = function(value){
var isValid = false;
var regex = '[0-9]{2}[/][0-9]{2}[/][0-9]{4}';
if (value == ''){
return true;
}
if (value.match(regex)){
value = value.split('/');
var d = parseInt(value[0], 10);
@ -121,6 +152,15 @@ var validateDatePicker = function(value){
return isValid;
};
// take date string in DD/MM/YYYY format and return date object
var stringToDate = function(value){
value = value.split('/');
var d = parseInt(value[0], 10);
var m = parseInt(value[1], 10);
var y = parseInt(value[2], 10);
return new Date(y,m-1,d);
};
// check if email is in valid format
var validateEmail = function(value){
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;


+ 50
- 12
edivorce/apps/core/static/js/main.js View File

@ -24,29 +24,42 @@ $(function () {
$('#other_names_fields').append($('#other_names_group').children().clone(true));
});
// TODO delete button is not working if they are added
$("#btn_add_reconciliation_periods").on('click', function () {
$('#reconciliation_period_fields').append($('#reconciliation_period_group').children().clone());
$('#reconciliation_period_fields input:text').on('change', ajaxOnChange);
// $('.btn-delete-period').on('click', deleteAddedField);
date_picker();
});
// Delete button will remove field and update user responses
$(".btn-delete").on('click', function () {
$(".btn-delete-name").on('click', function () {
$(this).parent('div').remove();
// update by trigger change event on one of the text field
var textField = $('#other_names_fields').find('input:text');
textField.first().triggerHandler('change');
// when there is only one field left, clear it instead of delete it
if (textField.length < 1){
if ($('#other_names_fields').find('input:text').length < 1){
$("#btn_add_other_names").triggerHandler('click');
$('#other_names_fields').find('input:text').first().triggerHandler('change');
}
// update by trigger change event on one of the text field
$('#other_names_fields').find('input:text').first().triggerHandler('change');
});
// Configuration for datepicker
$(".date-picker-group").datepicker({
format: "dd/mm/yyyy",
endDate: "today",
autoclose: true
$(".btn-delete-period").on('click', function () {
$(this).parent('div').remove();
// when there is only one field left, clear it instead of delete it
if ($('#reconciliation_period_fields').find('input:text').length < 1){
$("#btn_add_reconciliation_periods").triggerHandler('click');
}
// update by trigger change event on one of the text field
$('#reconciliation_period_fields').find('input:text').first().triggerHandler('change');
});
// add date_picker
date_picker();
// On step_03.html, update text when user enters separation date
$("#separated_date").on("change", function () {
$("#separation_date_span").text(" on " + $(this).val());
@ -60,6 +73,31 @@ $(function () {
});
});
// TODO make ajax call way too many times
var deleteAddedField = function(){
console.log($(this));
$(this).parent('div').remove();
// when there is only one field left, clear it instead of delete it
if ($('#reconciliation_period_fields').find('input:text').length < 1){
$("#btn_add_reconciliation_periods").triggerHandler('click');
}
// update by trigger change event on one of the text field
$('#reconciliation_period_fields').find('input:text').first().triggerHandler('change');
console.log($('#reconciliation_period_fields').find('input:text').first());
};
// Configuration for datepicker
var date_picker = function () {
$(".date-picker-group").datepicker({
format: "dd/mm/yyyy",
startDate: "-100y",
endDate: "0d",
autoclose: true,
todayHighlight: true
});
};
// Expand More Information boxes
$(".more_information-link a").click(function () {
var moreInfo = $(".more_information-column");


+ 2
- 4
edivorce/apps/core/templates/partials/alias_field.html View File

@ -6,8 +6,6 @@
<option value="otherwise known as" {% if alias_type == 'otherwise known as' %} selected {% endif %}>Otherwise known as</option>
<option value="with assumed name of" {% if alias_type == 'with assumed name of' %} selected {% endif %}>With assumed name of</option>
</select>
{% input_field type="text" name=name value=value class="form-block input-wide response-textbox" %}
{% if delete_button == "true" %}
<button class="btn-delete">Delete</button>
{% endif %}
{% input_field type="text" name=name value=value multiple="true" class="form-block input-wide response-textbox" %}
<button class="btn-delete-name">Delete</button>
</div>

+ 2
- 2
edivorce/apps/core/templates/partials/name_with_alias.html View File

@ -2,10 +2,10 @@
<br />
<span class="form-entry_claimant">
{{ name }}
{% if other_names %}
{% if other_names and use_other_name == 'YES' %}
{% multiple_values_to_list source=other_names as values %}
{% for alias_type, value in values %}
{% if value != '' and value != ' ' %} {{alias_type}} {{value}} {% endif %}
{% if value != '' %} {{alias_type}} {{value}} {% endif %}
{% endfor %}
{% endif %}
</span>

+ 6
- 0
edivorce/apps/core/templates/partials/reconciliation_period.html View File

@ -0,0 +1,6 @@
{% load input_field %}
<div style="display: inline-flex">
<p><label>From: <span class="date-picker-group">{% input_field type="text" name="reconciliation_period" value=from multiple='true' class="date-pickers reconciliation-from-date" placeholder="DD/MM/YYYY" %}</span></label></p>
<p><label>To: <span class="date-picker-group">{% input_field type="text" name="reconciliation_period" value=to multiple='true' class="date-pickers reconciliation-to-date" placeholder="DD/MM/YYYY" %}</span></label></p>
<button class="btn-delete-period">Delete</button>
</div>

+ 2
- 2
edivorce/apps/core/templates/pdf/form1.html View File

@ -31,10 +31,10 @@
<em> In the Supreme Court of British Columbia </em>
</p>
<p>
Claimant 1:{% include "partials/name_with_alias.html" with name=responses.name_you other_names=responses.other_name_you %}
Claimant 1:{% include "partials/name_with_alias.html" with name=responses.name_you use_other_name=responses.any_other_name_you other_names=responses.other_name_you %}
</p>
<p>
Claimant 2:{% include "partials/name_with_alias.html" with name=responses.name_spouse other_names=responses.other_name_spouse %}
Claimant 2:{% include "partials/name_with_alias.html" with name=responses.name_spouse use_other_name=responses.any_other_name_spouse other_names=responses.other_name_spouse %}
</p>
<p>
&nbsp;


+ 2
- 2
edivorce/apps/core/templates/pdf/form35.html View File

@ -32,11 +32,11 @@
<em> In the Supreme Court of British Columbia </em>
</p>
<p>
Claimant 1: {% if responses.name_you %} {% include "partials/name_with_alias.html" with name=responses.name_you other_names=responses.other_name_you %}
Claimant 1: {% if responses.name_you %} {% include "partials/name_with_alias.html" with name=responses.name_you use_other_name=responses.any_other_name_you other_names=responses.other_name_you %}
{% else %} <span class="form-entry not-complete">&nbsp;</span> {% endif %}
</p>
<p>
Claimant 2: {% if responses.name_spouse %} {% include "partials/name_with_alias.html" with name=responses.name_spouse other_names=responses.other_name_spouse %}
Claimant 2: {% if responses.name_spouse %} {% include "partials/name_with_alias.html" with name=responses.name_spouse use_other_name=responses.any_other_name_spouse other_names=responses.other_name_spouse %}
{% else %} <span class="form-entry not-complete">&nbsp;</span> {% endif %}
</p>
<h2 class="text-center">


+ 2
- 2
edivorce/apps/core/templates/pdf/form36.html View File

@ -31,11 +31,11 @@
<em> In the Supreme Court of British Columbia </em>
</p>
<p>
Claimant 1: {% if responses.name_you %} {% include "partials/name_with_alias.html" with name=responses.name_you other_names=responses.other_name_you %}
Claimant 1: {% if responses.name_you %} {% include "partials/name_with_alias.html" with name=responses.name_you use_other_name=responses.any_other_name_you other_names=responses.other_name_you %}
{% else %} <span class="form-entry not-complete">&nbsp;</span> {% endif %}
</p>
<p>
Claimant 2: {% if responses.name_spouse %} {% include "partials/name_with_alias.html" with name=responses.name_spouse other_names=responses.other_name_spouse %}
Claimant 2: {% if responses.name_spouse %} {% include "partials/name_with_alias.html" with name=responses.name_spouse use_other_name=responses.any_other_name_spouse other_names=responses.other_name_spouse %}
{% else %} <span class="form-entry not-complete">&nbsp;</span> {% endif %}
</p>
<h2 align="center">


+ 19
- 2
edivorce/apps/core/templates/prequalification/step_03.html View File

@ -76,15 +76,32 @@
<div class="question-well">
<h3>Did you and {% if name_spouse %} {{ name_spouse }} {% else %} your spouse {% endif %} try and reconcile after you separated <span id="separation_date_span"></span>?</h3>
<div class="radio"><label>{% input_field type="radio" name="try_reconcile_after_separated" value="NO" %}
<div class="radio"><label>{% input_field type="radio" name="try_reconcile_after_separated" value="NO" data_target_id="reconciliation_period" data_reveal_target="false" %}
No, {% if name_spouse %} {{ name_spouse }} {% else %} my spouse {% endif %} and I have not reconciled (gotten back together)</label>
</div>
<div class="radio"><label>{% input_field type="radio" name="try_reconcile_after_separated" value="YES" %}
<div class="radio"><label>{% input_field type="radio" name="try_reconcile_after_separated" value="YES" data_target_id="reconciliation_period" data_reveal_target="true" %}
Yes, {% if name_spouse %} {{ name_spouse }} {% else %} my spouse {% endif %} and I lived together again during the following period(s) in an unsuccessful attempt to reconcile</label>
</div>
<!-- TODO: Dev note: If reconciliation period is greater than 90 days, display Alert message in column F -->
<!-- TODO: Add multiple date adding fields -->
<div id="reconciliation_period" hidden>
<div id="reconciliation_period_group" hidden>
{% include "partials/reconciliation_period.html" %}
</div>
<div id="reconciliation_period_fields">
{% if reconciliation_period and reconciliation_period != '[]' %}
{% multiple_values_to_list source=reconciliation_period as periods %}
{% for from, to in periods %}
{% include "partials/reconciliation_period.html" with from=from to=to %}
{% endfor %}
{% else %}
{% include "partials/reconciliation_period.html" %}
{% endif %}
</div>
<input type="button" id="btn_add_reconciliation_periods" value="Add Period"/>
</div>
<div>
<div class="information-message bg-danger" hidden>
<p>Based on the date(s) you have provided for reconciliation, we have detected that your reconciliation may be for a period of greater than 90 days. Within the one year separation period, you can only live together for 90 days or less. </p>


+ 1
- 1
edivorce/apps/core/templates/question/02_claimant.html View File

@ -70,7 +70,7 @@
<h3>Please enter the name</h3>
<!-- This is used for adding a new other name field when add button is clicked -->
<div id="other_names_group" hidden>
{% include "partials/alias_field.html" with name="other_name_you" value=' ' delete_button="true" %}
{% include "partials/alias_field.html" with name="other_name_you" %}
</div>
<div id="other_names_fields">
{% if other_name_you %}


+ 2
- 2
edivorce/apps/core/templatetags/input_field.py View File

@ -5,7 +5,7 @@ register = template.Library()
@register.simple_tag(takes_context=True)
def input_field(context, type, name='', value='', **kwargs):
def input_field(context, type, name='', value='', multiple='', **kwargs):
"""
Usage: when specifying data attributes in templates, use "data_" intead of "data-".
"""
@ -21,7 +21,7 @@ def input_field(context, type, name='', value='', **kwargs):
tag.append('</textarea>')
else:
# set initial value for textbox
if type == "text" and value == '':
if type == "text" and value == '' and multiple != 'true':
value = context.get(name, '')
tag = ['<input type="' + type + '" name="' + name + '" value="' + value + '"']


+ 16
- 8
edivorce/fixtures/Question.json View File

@ -31,6 +31,22 @@
"model": "core.question",
"pk": "separation_date"
},
{
"fields": {
"name": "Did you and your spouse try and reconcile after you separated?",
"description": "For pre-qualification step 3, Form 1 2. Divorce section B"
},
"model": "core.question",
"pk": "try_reconcile_after_separated"
},
{
"fields": {
"name": "Please enter reconciliation periods",
"description": "For pre-qualification step 3, Form 1 2. Divorce section B"
},
"model": "core.question",
"pk": "reconciliation_period"
},
{
"fields": {
"name": "Do you and your spouse have any children (includes step children, adopted children). The legal term is children of the marriage.",
@ -295,14 +311,6 @@
"model": "core.question",
"pk": "marital_status_before_spouse"
},
{
"fields": {
"name": "Did you and your spouse try and reconcile after you separated?",
"description": "For pre-qualification step 3, For step 5, Form 1 2. Divorce section B"
},
"model": "core.question",
"pk": "try_reconcile_after_separated"
},
{
"fields": {
"name": "There is no possibility my spouse and I will get back together (reconciliation).",


Loading…
Cancel
Save