Skip to content

Commit

Permalink
fix: improve applicant destruction confirmation handling and logging (#…
Browse files Browse the repository at this point in the history
…4927)

* fix: improve applicant destruction confirmation handling and logging

* Update financial_assistance.js

Comment out console.log

Signed-off-by: Brad Bodine <[email protected]>

* Update inline_replacements.js

Signed-off-by: Brad Bodine <[email protected]>

---------

Signed-off-by: Brad Bodine <[email protected]>
  • Loading branch information
bbodine1 committed Jan 24, 2025
1 parent 186d19f commit 7f92d36
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 55 deletions.
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_<%=@applicant.id%>_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);
}

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

0 comments on commit 7f92d36

Please sign in to comment.