diff --git a/edivorce/apps/core/static/js/ajax.js b/edivorce/apps/core/static/js/ajax.js index cf3d1fd2..6739d16f 100644 --- a/edivorce/apps/core/static/js/ajax.js +++ b/edivorce/apps/core/static/js/ajax.js @@ -4,7 +4,7 @@ var ajaxOnChange = function () { // show/hide additional information if needed reveal(el); var question = el.prop('name'); - var value = getValue(el, question, ''); + var value = getValue(el, question); var isValid = true; // Check if date is in valid format DD/MM/YYYY diff --git a/edivorce/apps/core/static/js/controllers.js b/edivorce/apps/core/static/js/controllers.js index 1c62499f..4dd85ba6 100644 --- a/edivorce/apps/core/static/js/controllers.js +++ b/edivorce/apps/core/static/js/controllers.js @@ -68,14 +68,15 @@ var radioWithTextboxControl = function(el){ // when textbox is clicked, update associated radio button response with its value else if (el.is(".other-textbox")){ - var radioTextbox = el.siblings(".radio_with_textbox"); + var radioTextbox = el.parents().find(".radio_with_textbox"); ajaxCall(radioTextbox.prop('name'), radioTextbox.val()); } }; // Get value from various input fields // If input is checkbox, get all checked items' value and separate them by ; -var getValue = function(el, question, value){ +var getValue = function(el, question){ + var value = []; // if checkbox, get list of values. if (el.is("input[type=checkbox]")){ // special behaviour for question children_financial_support @@ -83,10 +84,18 @@ var getValue = function(el, question, value){ childSupportCheckboxControl(el); } $(".checkbox-group").find("input[type=checkbox]:checked").each(function(){ - value += $(this).val() + '; '; + value.push($(this).val()); }); // to remove last space and semi-colon - return value.slice(0, -2); + return JSON.stringify(value); + } + else if (question == "other_name_you" || question == "other_name_spouse"){ + var aliasType; + $('#other_names_fields').find("input[type=text]").each(function () { + aliasType = $(this).siblings(".alias-type").val(); + value.push([aliasType, $(this).val()]); + }); + return JSON.stringify(value); } else{ return el.val(); diff --git a/edivorce/apps/core/static/js/main.js b/edivorce/apps/core/static/js/main.js index 8348bf92..8df8c1d3 100755 --- a/edivorce/apps/core/static/js/main.js +++ b/edivorce/apps/core/static/js/main.js @@ -1,36 +1,49 @@ // Reveal sections as the form is loading -$('input:radio, input:checkbox').each(function() { - if($(this).is(':checked')) { +$('input:radio, input:checkbox').each(function () { + if ($(this).is(':checked')) { reveal($(this)); // apply css class to big round buttons if ($(this).parent().hasClass('btn-radio')) { $(this).parent().addClass('active'); } - } + } }); $(function () { $('[data-toggle="tooltip"]').tooltip({trigger: 'click'}); // when user click textbox beside radio button, check the associated radio button - $(".other-textbox").on("click focus", function(){ - $(this).siblings(".radio_with_textbox").prop('checked', true); + $(".other-textbox").on("click", function () { + $(this).parents().find(".radio_with_textbox").prop('checked', true); }); $("input[type=radio], input[type=checkbox], input[type=text], .response-textarea, .response-dropdown").on("change", ajaxOnChange); + // Add name button adds new input field for adding other name + $("#btn_add_other_names").on('click', function () { + $('#other_names_fields').append($('#other_names_group').children().clone(true)); + }); + + // Delete button will remove field and update user responses + $(".btn-delete").on('click', function () { + // store neighbour input text to trigger change event to update list after delete + var neighbour = $(this).parent('div').prev().find("input:text"); + $(this).parent('div').remove(); + neighbour.triggerHandler('change'); + }); + // Configuration for datepicker $(".date-picker-group").datepicker({ - format: "dd/mm/yyyy", - endDate: "today", - autoclose: true + format: "dd/mm/yyyy", + endDate: "today", + autoclose: true }); // On step_03.html, update text when user enters separation date - $("#separated_date").on("change", function(){ + $("#separated_date").on("change", function () { $("#separation_date_span").text(" on " + $(this).val()); // if separation date is less than one year, show alert message - if (checkSeparationDateLessThanYear($(this).val())){ + if (checkSeparationDateLessThanYear($(this).val())) { $('#separation_date_alert').show(); } else { @@ -41,8 +54,8 @@ $(function () { // Expand More Information boxes // TODO this is fragile and really just a place holder until the sidebar is revised -$( "#more_information" ).click(function() { - if($(this).hasClass("active")) { +$("#more_information").click(function () { + if ($(this).hasClass("active")) { $(this).removeClass("col-md-4 active"); $(".container-wrapper .col-md-8").addClass("col-md-offset-2"); } else { diff --git a/edivorce/apps/core/templates/partials/alias_field.html b/edivorce/apps/core/templates/partials/alias_field.html new file mode 100644 index 00000000..bc65bb60 --- /dev/null +++ b/edivorce/apps/core/templates/partials/alias_field.html @@ -0,0 +1,11 @@ +{% load input_field %} +
This is often referred to as Family name or Surname
Please select one
- +In order to apply for a divorce in British Columbia, you or your spouse must have been a regular resident in B.C (the legal term is ordinarily resident diff --git a/edivorce/apps/core/templates/question/03_respondent.html b/edivorce/apps/core/templates/question/03_respondent.html index 02ef9069..e35fc538 100644 --- a/edivorce/apps/core/templates/question/03_respondent.html +++ b/edivorce/apps/core/templates/question/03_respondent.html @@ -80,8 +80,21 @@