Browse Source

DIV-494: Updated preq step 3 to prevent user from navigate away if date is invalid on reconciliation period

pull/160/head
Charles Shin 8 years ago
parent
commit
5d42e8a988
4 changed files with 18 additions and 8 deletions
  1. +3
    -3
      edivorce/apps/core/static/js/ajax.js
  2. +2
    -2
      edivorce/apps/core/static/js/functions.js
  3. +11
    -1
      edivorce/apps/core/static/js/main.js
  4. +2
    -2
      edivorce/apps/core/templates/prequalification/step_03.html

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

@ -33,13 +33,13 @@ var ajaxOnChange = function () {
var getCSRFToken = function () { var getCSRFToken = function () {
var name = 'csrftoken'; var name = 'csrftoken';
var cookieValue = null; var cookieValue = null;
if (document.cookie && document.cookie != '') {
if (document.cookie && document.cookie !== '') {
var cookies = document.cookie.split(';'); var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) { for (var i = 0; i < cookies.length; i++) {
var cookie = $.trim(cookies[i]); var cookie = $.trim(cookies[i]);
// Does this cookie string begin with the name we want? // Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break; break;
} }
@ -59,7 +59,7 @@ var ajaxCall = function(question, value){
{ {
type: 'POST', type: 'POST',
beforeSend: function (xhr, settings) { beforeSend: function (xhr, settings) {
if ((settings.type == 'POST' || settings.type == 'PUT' || settings.type == 'DELETE') && !this.crossDomain) {
if ((settings.type === 'POST' || settings.type === 'PUT' || settings.type === 'DELETE') && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrf_token); xhr.setRequestHeader("X-CSRFToken", csrf_token);
} }
}, },


+ 2
- 2
edivorce/apps/core/static/js/functions.js View File

@ -162,14 +162,14 @@ var getValue = function(el, question){
$(this).closest('.form-inline').find('.date') $(this).closest('.form-inline').find('.date')
.addClass('has-error'); .addClass('has-error');
$(this).closest('.form-inline').find('.form-warning') $(this).closest('.form-inline').find('.form-warning')
.append('<span class="help-block">You have entered date periods that overlap, please check your dates and enter each period of time separately.</span>');
.append('<span class="help-block invalid-date">You have entered date periods that overlap, please check your dates and enter each period of time separately.</span>');
} }
} }
else { else {
$(this).closest('.form-inline').find('.date') $(this).closest('.form-inline').find('.date')
.addClass('has-error'); .addClass('has-error');
$(this).closest('.form-inline').find('.form-warning') $(this).closest('.form-inline').find('.form-warning')
.append('<span class="help-block">You have entered an end date (To:) that is earlier than the start date (From:), please check your dates and try again.</span>');
.append('<span class="help-block invalid-date">You have entered an end date (To:) that is earlier than the start date (From:), please check your dates and try again.</span>');
} }
} }
}); });


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

@ -118,7 +118,7 @@ $(function () {
var proceedNext = $(this).data('proceed'); var proceedNext = $(this).data('proceed');
if (!showAlert) { if (!showAlert) {
$(".checkbox-group input:checkbox").not(":checked").each(function () { $(".checkbox-group input:checkbox").not(":checked").each(function () {
if ($(this).val() == 'Division of property and debts' || $(this).val() == 'Spousal support') {
if ($(this).val() === 'Division of property and debts' || $(this).val() === 'Spousal support') {
showAlert = true; showAlert = true;
} }
}); });
@ -130,6 +130,16 @@ $(function () {
} }
}); });
// For Prequalification step 3
// If there is invalid date on reconciliation period,
// prevent user from navigate away from the page when user clicks next or back button, or use side navigation
$('#btn_reconcilaition_back, #btn_reconcilaition_next, .progress-column > a').on('click', function(e){
if ($('.invalid-date').is(':visible')) {
e.preventDefault();
$('.invalid-date').parent().siblings('.form-group').find('.reconciliation-from-date').focus();
}
});
// spinner // spinner
$('a.spinner').on('click', function (e) { $('a.spinner').on('click', function (e) {
e.preventDefault(); e.preventDefault();


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

@ -143,8 +143,8 @@
{% block formbuttons %} {% block formbuttons %}
<div class="form-buttons clearfix"> <div class="form-buttons clearfix">
<a class="btn btn-primary" href="{% url 'prequalification' '02' %}"><i class="fa fa-arrow-circle-o-left"></i>&nbsp;&nbsp;&nbsp;Back</a>
<a class="btn btn-success pull-right" href="{% url 'prequalification' '04' %}">Next&nbsp;&nbsp;&nbsp;<i class="fa fa-arrow-circle-o-right"></i></a>
<a class="btn btn-primary" id="btn_reconcilaition_next" href="{% url 'prequalification' '02' %}"><i class="fa fa-arrow-circle-o-left"></i>&nbsp;&nbsp;&nbsp;Back</a>
<a class="btn btn-success pull-right" id="btn_reconcilaition_back" href="{% url 'prequalification' '04' %}">Next&nbsp;&nbsp;&nbsp;<i class="fa fa-arrow-circle-o-right"></i></a>
</div> </div>
{% endblock %} {% endblock %}


Loading…
Cancel
Save