Skip to content

Commit

Permalink
temporary fix for broken faa cucumber steps (#4854)
Browse files Browse the repository at this point in the history
* temporary fix for broken faa cucumber steps

* fix income forms

* add bs4 to date validation

* fix back to household buttons

* fix deduction form ids

* tax info cucumber fix

* cucumber step fixes

* add driver alert accept to step

* remove javascript void from anchors

---------

Co-authored-by: Brad Bodine <[email protected]>
  • Loading branch information
RyanEddyIC and bbodine1 committed Jan 5, 2025
1 parent b8d98d0 commit 09c4361
Show file tree
Hide file tree
Showing 26 changed files with 193 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ function notifyUserPrompt(element) {
$('#backModal').modal('show');
}

$(document).on('click', '.back-to-household-link', function(e) {
e.preventDefault()
notifyUserPrompt(this)
})

function backToHouseHolds() {
$('#backModal').modal('hide');
window.location = toLocation;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
function init_faa_immigration_doc_fields() {
$(document).ready(function(){
if ($("[data-vlp-doc-subject]").length) {
showOnly($("[data-vlp-doc-subject]").data('vlp-doc-subject'));
}
});
}


function init_faa_dependent_form() {
// components/financial_assistance/app/views/financial_assistance/applicants/_dependent_form.html.erb
var bs4 = document.documentElement.dataset.bs4

if (bs4) {
$(document).ready(function() {
$.inputMasks();

$('.field_with_errors > *').unwrap();

$('#applicant_same_with_primary').click(function(){
if($(this).is(':checked')){
$('#applicant-home-address-area').addClass("hidden");
} else {
$('#applicant-home-address-area').removeClass("hidden");
}
});

$("#dependent_first_name").change(function() {
var text = $("#dependent_first_name").val() == '' ? "This person" : $("#dependent_first_name").val()
$("#is_applying_coverage_value_dep").text("Does "+ text +" need coverage? *");
$("#is_applying_coverage_value_dep_1").text(text);
});
});

$(document).off('click', '#confirm-dependent');
$(document).on('click', '#confirm-dependent', function(e) {
if($("input#applicant_same_with_primary").is(":checked")){
$("#dependent-address input.required, dependent-address select.required, #dependent-address .address_required").removeAttr('required');
} else {
$("#dependent-address input.required, dependent-address select.required, #dependent-address .address_required").attr('required', true);
}

$(".btn-confirmation").removeAttr('disabled');

var form = $('#new_dependent')[0] || $('#edit_dependent')[0];

if (!$("input#applicant_same_with_primary").is(":checked")) {
$('#addressChangeConfirmation').modal('show');
} else {
PersonValidations.manageRequiredValidations($('#confirm-dependent'));
}

});
} else {
$(document).ready(function() {
$.inputMasks();

$('.field_with_errors > *').unwrap();
Freebies.floatlabels();
if($("input#applicant_same_with_primary").is(":checked")){
$("#dependent-address input, dependent-address select").removeAttr('required');
};
$("#dependent_first_name").change(function() {
var text = $("#dependent_first_name").val() == '' ? "this person" : $("#dependent_first_name").val()
$("#is_applying_coverage_value_dep").text("Does "+ text +" need coverage? *");
$("#is_applying_coverage_value_dep_1").text(text);
});
});

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");

ApplicantValidations.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 isSsnSelected(applicantSSN, applicantNoSSN) {
return (applicantSSN && applicantSSN.value.replace(/-/g, '').length == 9) || (applicantNoSSN && applicantNoSSN.checked);
}

$(document).on('click', '.applicant-confirm-member', function() {
confirmMember($(this))
})
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function getDateFieldDate(id) {
const dateValue = $(id).val();
const dateValue = $(id).val();
return dateValue ? new Date(dateValue) : null;
};

Expand All @@ -20,3 +20,11 @@ function validateDateWarnings(id) {
if (requiresStartDateWarning) warning_div.add(startDateWarning).removeClass('hidden');
if (requiresEndDateWarning) warning_div.add(endDateWarning).removeClass('hidden');
};

$(document).on('change', "[data-validate-date-id]", function() {
let id = $(this).data('validate-date-id')
let bs4 = $(this).data('use-bs4')
if (id.length) {
validateDateWarnings(id, bs4)
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -143,47 +143,6 @@
<% end %>
</div>
<%= render partial: 'shared/address_change_confirmation_modal' %>
<script>
$(document).ready(function() {
$.inputMasks();

$('.field_with_errors > *').unwrap();

$('#applicant_same_with_primary').click(function(){
if($(this).is(':checked')){
$('#applicant-home-address-area').addClass("hidden");
} else {
$('#applicant-home-address-area').removeClass("hidden");
}
});

$("#dependent_first_name").change(function() {
var text = $("#dependent_first_name").val() == '' ? "This person" : $("#dependent_first_name").val()
$("#is_applying_coverage_value_dep").text("Does "+ text +" need coverage? *");
$("#is_applying_coverage_value_dep_1").text(text);
});
});

$(document).off('click', '#confirm-dependent');
$(document).on('click', '#confirm-dependent', function(e) {
if($("input#applicant_same_with_primary").is(":checked")){
$("#dependent-address input.required, dependent-address select.required, #dependent-address .address_required").removeAttr('required');
} else {
$("#dependent-address input.required, dependent-address select.required, #dependent-address .address_required").attr('required', true);
}

$(".btn-confirmation").removeAttr('disabled');

var form = $('#new_dependent')[0] || $('#edit_dependent')[0];

if (!$("input#applicant_same_with_primary").is(":checked")) {
$('#addressChangeConfirmation').modal('show');
} else {
PersonValidations.manageRequiredValidations($('#confirm-dependent'));
}

});
</script>
</div>

<% else %>
Expand Down Expand Up @@ -416,53 +375,11 @@
<%= l10n("confirm_member") %>
<% end %>

<span tabindex="0" onkeydown="handleButtonKeyDown(event, 'confirm-member')" class="btn btn-primary btn-br pull-right mz applicant-confirm-member" onclick="confirmMember($(this));">
<span tabindex="0" data-keydown-id='confirm-member' class="btn btn-primary btn-br pull-right mz applicant-confirm-member">
<%= l10n("confirm_member") %>
</span>
</div>
<% end %>
</div>
<script>
$(document).ready(function() {
$.inputMasks();

$('.field_with_errors > *').unwrap();
Freebies.floatlabels();
if($("input#applicant_same_with_primary").is(":checked")){
$("#dependent-address input, dependent-address select").removeAttr('required');
};
$("#dependent_first_name").change(function() {
var text = $("#dependent_first_name").val() == '' ? "this person" : $("#dependent_first_name").val()
$("#is_applying_coverage_value_dep").text("Does "+ text +" need coverage? *");
$("#is_applying_coverage_value_dep_1").text(text);
});
});

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");

ApplicantValidations.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 isSsnSelected(applicantSSN, applicantNoSSN) {
return (applicantSSN && applicantSSN.value.replace(/-/g, '').length == 9) || (applicantNoSSN && applicantNoSSN.checked);
}

</script>
</li>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $('#btn-continue').addClass('disabled');
$("#new_employee_dependent_form").each(function(idx, ele) {
$(ele).remove();
});
$("#dependent_ul").append("<%= escape_javascript(render 'dependent_form') %>");
$("#dependent_ul").append("<%= escape_javascript(render 'dependent_form') %>").ready(init_faa_partials_js());
$('#' + $("#dependent_ul").children().last().attr('id')).get(0).scrollIntoView({behavior: 'smooth'});
<% end %>

Expand All @@ -39,3 +39,8 @@ applyFaaListeners();
changeApplyingCoverageText();
applicantDemographicValidations();


function init_faa_partials_js() {
init_faa_dependent_form()
init_faa_immigration_doc_fields()
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
<div class="col-xs-12">
<div class="back-link">
<i class="fa fa-caret-left fa-2x" aria-hidden="true"></i>
<a href="javascript:void(0);" onclick="notifyUserPrompt(this)" data-path="<%= financial_assistance.edit_application_path(@application) %>"> <b><%= l10n("faa.tax_info.back") %></b> </a> <span><%= l10n("faa.tax_info.back_paranthetical") %></span>
<a href="#" class="back-to-household-link" data-path="<%= financial_assistance.edit_application_path(@application) %>"> <b><%= l10n("faa.tax_info.back") %></b> </a> <span><%= l10n("faa.tax_info.back_paranthetical") %></span>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
<div class="col-xs-12">
<div class="back-link">
<i class="fa fa-caret-left fa-2x" aria-hidden="true"></i>
<a href="javascript:void(0);" onclick="notifyUserPrompt(this)" data-path="<%= financial_assistance.edit_application_path(@application) %>"> <b>BACK TO ALL HOUSEHOLD MEMBERS</b> </a> <span>(Go back and work on another person)</span>
<a href="#" class="back-to-household-link" data-path="<%= financial_assistance.edit_application_path(@application) %>"> <b>BACK TO ALL HOUSEHOLD MEMBERS</b> </a> <span>(Go back and work on another person)</span>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
<div class="col-xs-12">
<div class="back-link">
<i class="fa fa-caret-left fa-2x" aria-hidden="true"></i>
<a href="javascript:void(0);" onclick="notifyUserPrompt(this)" data-path="<%= financial_assistance.edit_application_path(@application) %>"> <b>BACK TO ALL HOUSEHOLD MEMBERS</b> </a> <span>(Go back and work on another person)</span>
<a href="#" class="back-to-household-link" data-path="<%= financial_assistance.edit_application_path(@application) %>"> <b>BACK TO ALL HOUSEHOLD MEMBERS</b> </a> <span>(Go back and work on another person)</span>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@
<div class="col-xs-12">
<div class="back-link">
<i class="fa fa-caret-left fa-2x" aria-hidden="true"></i>
<a href="javascript:void(0);" onclick="notifyUserPrompt(this)" data-path="<%= edit_application_path(@application) %>"> <b>BACK TO ALL HOUSEHOLD MEMBERS</b> </a> <span>(Go back and work on another person)</span>
<a href="#" class="back-to-household-link" data-path="<%= edit_application_path(@application) %>"> <b>BACK TO ALL HOUSEHOLD MEMBERS</b> </a> <span>(Go back and work on another person)</span>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<% else %>
<%= deduction_form_for @application, @applicant, deduction do |f| %>
<% deduction_id = deduction.id %>
<% onchange_date = FinancialAssistanceRegistry[:income_and_deduction_date_warning].enabled? ? (raw "validateDateWarnings('#{deduction_id}')") : "" %>
<% onchange_deduction_id = FinancialAssistanceRegistry[:income_and_deduction_date_warning].enabled? ? deduction_id : "" %>
<div class="focus_effect_module">
<div class="row row-form-wrapper no-buffer row-height row-edit-border">
<%= f.hidden_field :deduction_type, value: kind %>
Expand All @@ -52,15 +52,15 @@
</div>
</div>
<div class="col-md-3">
<%= f.text_field :start_on, placeholder: 'FROM *', required: true, id: "start_on_#{deduction_id}", class: "datepicker-js floatlabel", onchange: onchange_date %>
<%= f.text_field :start_on, placeholder: 'FROM *', required: true, id: "start_on_#{deduction_id}", class: "datepicker-js floatlabel", data: {validate_date_id: "#{onchange_deduction_id}", use_bs4: false} %>
</div>
<div class="col-md-3 overflow-hidden">
<%= f.text_field :end_on, placeholder: 'TO', id: "end_on_#{deduction_id}", class: "datepicker-js floatlabel", onchange: onchange_date %>
<%= f.text_field :end_on, placeholder: 'TO', id: "end_on_#{deduction_id}", class: "datepicker-js floatlabel", data: {validate_date_id: "#{onchange_deduction_id}", use_bs4: false} %>
</div>
</div>
<div class="row">
<div class="col-md-3 pull-right">
<a tabindex="0" onkeydown="handleButtonKeyDown(event, 'income-deduction-cancel-<%= deduction_id %>')" id="income-deduction-cancel-<%= deduction_id %>" class="btn btn-default deduction-cancel">Cancel</a>
<a tabindex="0" data-keydown-id="income-deduction-cancel-<%= deduction_id %>" id="income-deduction-cancel-<%= deduction_id %>" class="btn btn-default deduction-cancel">Cancel</a>
<%= f.submit 'Save', class: 'btn btn-save', :data => { :cuke => "income-adjustments-save-button" } %>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
<div class="col-xs-12">
<div class="back-link">
<i class="fa fa-caret-left fa-2x" aria-hidden="true"></i>
<a href="javascript:void(0);" onclick="notifyUserPrompt(this)" data-path="<%= edit_application_path(@application) %>"> <b>BACK TO ALL HOUSEHOLD MEMBERS</b> </a> <span>(Go back and work on another person)</span>
<a href="#" class="back-to-household-link" data-path="<%= edit_application_path(@application) %>"> <b>BACK TO ALL HOUSEHOLD MEMBERS</b> </a> <span>(Go back and work on another person)</span>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<% income_id = income.id %>
<% new_form = local_assigns[:new_form].present? ? local_assigns[:new_form] : false %>
<% dummy_income_id = "#{income_id}#{new_form ? 'dummy' : ''}" # needed to prevent Multiple Form Label accessibility error %>
<% onchange_income_id = FinancialAssistanceRegistry[:income_and_deduction_date_warning].enabled? ? income_id : "" %>
<%= f.hidden_field :kind, value: 'american_indian_and_alaskan_native' %>
<div class="d-flex col-sm p-0 mb-2">
<div class="mr-auto col-sm col-md-6 col-lg-3 p-0">
Expand All @@ -17,15 +18,15 @@
</div>
<div class="mr-auto col-sm col-md-6 col-lg-3 p-0 pr-4">
<%= f.label :start_on, l10n("start_date"), class: "required", for: "start_on_#{dummy_income_id}" %>
<%= f.date_field :start_on, required: true, id: "start_on_#{dummy_income_id}", min: 110.years.ago, max:"9999-12-31", class: "w-100" %>
<%= f.date_field :start_on, required: true, id: "start_on_#{dummy_income_id}", min: 110.years.ago, max:"9999-12-31", data: {validate_date_id: "#{onchange_income_id}", use_bs4: true}, class: "w-100" %>
</div>
<div class="col-sm col-md-6 col-lg-3 p-0 pr-4">
<%= f.label :end_on, l10n("end_date"), for: "end_on_#{dummy_income_id}" %>
<%= f.date_field :end_on, id: "end_on_#{dummy_income_id}", min: 110.years.ago, max:"9999-12-31", class: "w-100" %>
<%= f.date_field :end_on, id: "end_on_#{dummy_income_id}", min: 110.years.ago, max:"9999-12-31", data: {validate_date_id: "#{onchange_income_id}", use_bs4: true}, class: "w-100" %>
</div>
</div>
<div class="d-flex mb-2 align-items-center">
<a tabindex="0" data-keydown-id='ai-an-income-cancel-<%= income_id %>' id="ai-an-income-cancel-<%= income_id %>" class="btn outline ai-an-income-cancel mr-1"><%= l10n("cancel") %></a>
<a tabindex="0" data-keydown-id="ai-an-income-cancel-<%= income_id %>" id="ai-an-income-cancel-<%= income_id %>" class="btn outline ai-an-income-cancel mr-1"><%= l10n("cancel") %></a>
<%= f.submit l10n("faa.other_incomes.save"), class: "btn btn-save", :data => { :cuke => "income-adjustments-save-button" } %>
</div>
</div>
Expand All @@ -36,7 +37,7 @@
<% else %>
<%= income_form_for @application, @applicant, income do |f| %>
<% income_id = income.id %>
<% onchange_date = FinancialAssistanceRegistry[:income_and_deduction_date_warning].enabled? ? (raw "validateDateWarnings('#{income_id}')") : "" %>
<% onchange_income_id = FinancialAssistanceRegistry[:income_and_deduction_date_warning].enabled? ? income_id : "" %>
<div class="focus_effect_module">
<div class="row row-form-wrapper no-buffer row-height row-edit-border">
<%= f.hidden_field :kind, value: 'american_indian_and_alaskan_native' %>
Expand All @@ -53,15 +54,15 @@
</div>
</div>
<div class="col-md-3">
<%= f.text_field :start_on, placeholder: 'FROM *', required: true, id: "start_on_#{income.id}", class: "datepicker-js floatlabel", onchange: onchange_date %>
<%= f.text_field :start_on, placeholder: 'FROM *', required: true, id: "start_on_#{income.id}", class: "datepicker-js floatlabel", data: {validate_date_id: "#{onchange_income_id}", use_bs4: false} %>
</div>
<div class="col-md-3 overflow-hidden">
<%= f.text_field :end_on, placeholder: 'TO', id: "end_on_#{income.id}", class: "datepicker-js floatlabel", onchange: onchange_date %>
<%= f.text_field :end_on, placeholder: 'TO', id: "end_on_#{income.id}", class: "datepicker-js floatlabel", data: {validate_date_id: "#{onchange_income_id}", use_bs4: false} %>
</div>
</div>
<div class="row">
<div class="col-md-3 pull-right">
<a tabindex="0" onkeydown="handleButtonKeyDown(event, 'income-cancel-<%= income_id %>')" id="income-cancel-<%= income.id %>" class="btn btn-default ai-an-income-cancel">Cancel</a>
<a tabindex="0" data-keydown-id="ai-an-income-cancel-<%= income_id %>" id="income-cancel-<%= income.id %>" class="btn btn-default ai-an-income-cancel">Cancel</a>
<%= f.submit 'Save', class: "btn btn-save", onclick: "checkDate('#{income.id}')" %>
</div>
</div>
Expand Down
Loading

0 comments on commit 09c4361

Please sign in to comment.