Browse Source

Merge pull request #43 from bcgov/DIV-944

DIV-944: Updated back button login to restore original data when edit…
pull/160/head
Charles Shin 6 years ago
committed by GitHub
parent
commit
98e4082388
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 3 deletions
  1. +22
    -3
      edivorce/apps/core/static/js/main.js

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

@ -23,6 +23,13 @@ $(window).load(function(){
$('#questions_modal, #terms_modal').modal('show'); $('#questions_modal, #terms_modal').modal('show');
}); });
// Temporarily store table row data.
var tempRowData = {
'isNewRow': false,
'el': null,
'activeRow': null,
};
$(function () { $(function () {
$('[data-toggle="tooltip"]').tooltip({ $('[data-toggle="tooltip"]').tooltip({
container: 'body', container: 'body',
@ -316,6 +323,7 @@ $(function () {
$('.children-list').hide(); $('.children-list').hide();
$('.fact-sheets').hide(); $('.fact-sheets').hide();
tempRowData.isNewRow = true;
initializeChildRowControls(newElement); initializeChildRowControls(newElement);
}, },
customDeleteAction: function(){} customDeleteAction: function(){}
@ -470,10 +478,18 @@ $(function () {
e.preventDefault(); e.preventDefault();
returnToParent({persist: false}); returnToParent({persist: false});
// Delete Empty row added to the children table.
// 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.
var $element = $('#claimant_children').find('tbody:first').find('tr:last');
deleteAddedTableRow($element);
if (tempRowData.isNewRow) {
var $element = $('#claimant_children').find('tbody:first').find('tr:last');
deleteAddedTableRow($element);
} else if (tempRowData.isNewRow === false && tempRowData.el !== null) {
// Restore original row data when edit is cancelled.
var $rows = $('#claimant_children').find('tbody:first').find(`tr[data-counter="${tempRowData.activeRow}"]`).find('.child-item-cell:not(.fact-sheet-button)');
$rows.each(function(i, $row) {
$row.replaceWith(tempRowData.el[i]);
});
}
}); });
$('#claimant_children').each(function(){ $('#claimant_children').each(function(){
@ -799,6 +815,9 @@ var populateChildInputFields = function(element) {
targetInput.filter("[value='" + $(this).text() + "']").prop('checked', true); targetInput.filter("[value='" + $(this).text() + "']").prop('checked', true);
} }
}); });
tempRowData.isNewRow = false;
tempRowData.el = element.find('.child-item-cell:not(.fact-sheet-button)').clone(true, true);
tempRowData.activeRow = activeChildRow;
}; };
var deleteChildData = function(settings, element) { var deleteChildData = function(settings, element) {


Loading…
Cancel
Save