Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve applicant destruction confirmation handling and logging #4927

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/assets/javascripts/financial_assistance.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ $(document).on('ajax:success', '#edit-dependent-person', function (event) {
$('.btn-confirmation').removeAttr('disabled');
});

$(document).on('click', '#destroyApplicant #destroy-confirm', function (e) {
$(document).on('click', '#destroy-confirm', function (e) {
confirmDestoyApplicant(e, $(this).data('url'));
});

function confirmDestoyApplicant(event, url) {
$('.btn-confirmation').prop('disabled', true);
// console.log('Applicant Destroy Initiated');
$('#destroy-confirm').prop('disabled', true);
event.preventDefault();
event.stopImmediatePropagation();
//
Expand Down
3 changes: 2 additions & 1 deletion app/assets/javascripts/inline_replacements.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ $(document).on('click', 'button#delete_applicant_button', function (e) {
});

function confirmDestoyApplicant(event, url) {
$('.btn-confirmation').prop('disabled', true);
// console.log('Applicant Destroy1 Initiated');
$('#destroy-confirm').prop('disabled', true);
event.preventDefault();
event.stopImmediatePropagation();
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,20 @@
<%= render 'users/security_question_responses/edit_modal', action: 'replace', method: 'POST', edit_mode: true %>

<div class="modal" id="destroyApplicant" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<%= l10n('faa.edit.delete_applicant') %>
<strong><br /><%= l10n('faa.edit.remove_warning') %></strong>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary btn-confirmation" id="destroy-confirm" data-url="<%=application_applicant_path(@application, @applicant)%>">Confirm</button>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<%= l10n('faa.edit.delete_applicant') %>
<strong><br /><%= l10n('faa.edit.remove_warning') %></strong>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Cancel</button>
<button type="button" class="" id="destroy-confirm" data-url="<%=application_applicant_path(@application, @applicant)%>">Confirm</button>

</div>
</div>
</div>
</div>
</div>


<% else %>
Expand Down Expand Up @@ -366,54 +366,55 @@
<button type="button" class="btn btn-default close_member_form hide cancel_<%[email protected]%>_edit"> Cancel</button>
<span tabindex="0" tabindex="0" onkeydown="handleButtonKeyDown(event, 'confirm_member')" id="confirm_member" class='btn btn-primary btn-br save_member applicant-confirm-member' onclick='confirmMember($(this));'> Confirm member</span>
</div>
<% end %>
<br>
<%= render 'users/security_question_responses/edit_modal', action: 'replace', method: 'POST', edit_mode: true %>
<script>
Freebies.floatlabels();
$.inputMasks();

$('#applicant_same_with_primary').click(function(){
if($(this).is(':checked')){
$('#applicant-home-address-area').css("display", "none");
} else {
$('#applicant-home-address-area').css("display", "block");
}
});

$(document).on('click', '#delete_applicant_button', function(e) {
e.preventDefault();
$("#destroyApplicant").modal();
<% end %>
<br>
<%= render 'users/security_question_responses/edit_modal', action: 'replace', method: 'POST', edit_mode: true %>
<script>
Freebies.floatlabels();
$.inputMasks();

$('#applicant_same_with_primary').click(function(){
if($(this).is(':checked')){
$('#applicant-home-address-area').css("display", "none");
} else {
$('#applicant-home-address-area').css("display", "block");
}
});

$("#destroyApplicant .modal-cancel-button").click(function(e) {
$("#destroyApplicant").modal('hide');
$(document).on('click', '#delete_applicant_button', function(e) {
e.preventDefault();
$("#destroyApplicant").modal();

$("#destroyApplicant .modal-cancel-button").click(function(e) {
$("#destroyApplicant").modal('hide');
});
$(".btn-confirmation").removeAttr('disabled');
});
$(".btn-confirmation").removeAttr('disabled');
});

function confirmMember(element) {
const form = element.closest('form')[0];
const maleRadio = document.getElementById('radio_male');
const femaleRadio = document.getElementById('radio_female');
const confirmButtonText = "<%= l10n('confirm_member') %>";
const applicantSSN = document.getElementById('applicant_ssn')
const applicantNoSSN = document.getElementById('applicant_no_ssn')
element.text("Please Wait...").addClass("disabled");

PersonValidations.manageRequiredValidations(element);

if (!form.checkValidity() || !isGenderSelected(maleRadio, femaleRadio) || !isSsnSelected(applicantSSN, applicantNoSSN)) {
element.text(confirmButtonText).removeClass("disabled");

function confirmMember(element) {
const form = element.closest('form')[0];
const maleRadio = document.getElementById('radio_male');
const femaleRadio = document.getElementById('radio_female');
const confirmButtonText = "<%= l10n('confirm_member') %>";
const applicantSSN = document.getElementById('applicant_ssn')
const applicantNoSSN = document.getElementById('applicant_no_ssn')
element.text("Please Wait...").addClass("disabled");

PersonValidations.manageRequiredValidations(element);

if (!form.checkValidity() || !isGenderSelected(maleRadio, femaleRadio) || !isSsnSelected(applicantSSN, applicantNoSSN)) {
element.text(confirmButtonText).removeClass("disabled");
}
}
}

function isGenderSelected(maleRadio, femaleRadio) {
return (maleRadio && maleRadio.checked) || (femaleRadio && femaleRadio.checked);
}
function isGenderSelected(maleRadio, femaleRadio) {
return (maleRadio && maleRadio.checked) || (femaleRadio && femaleRadio.checked);
}

function isSsnSelected(applicantSSN, applicantNoSSN) {
return (applicantSSN && applicantSSN.value.replace(/-/g, '').length == 9) || (applicantNoSSN && applicantNoSSN.checked);
}
function isSsnSelected(applicantSSN, applicantNoSSN) {
return (applicantSSN && applicantSSN.value.replace(/-/g, '').length == 9) || (applicantNoSSN && applicantNoSSN.checked);
}
bbodine1 marked this conversation as resolved.
Show resolved Hide resolved

function confirmDestoyApplicant(event, url){
$(".btn-confirmation").prop('disabled', true);
Expand Down
Loading