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

NJ 193 - Add none of the above option to property tax #5295

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,48 @@
</div>
</div>
<% end %>
<div class="white-group">
<div class="tight-checkboxes">
<%= f.cfa_checkbox(:homeowner_none_of_the_above, t("general.none_of_these"), options: { checked_value: "yes", unchecked_value: "no" }) %>
</div>
</div>
</div>

<% if params[:return_to_review].present? %>
<%= hidden_field_tag "return_to_review", params[:return_to_review] %>
<% end %>

<%= f.continue %>
<% end %>
<script>
document.addEventListener("DOMContentLoaded", function() {
let noneCheckbox = document.getElementById("state_file_nj_homeowner_eligibility_form_homeowner_none_of_the_above");
let checkboxes = [
document.getElementById("state_file_nj_homeowner_eligibility_form_homeowner_home_subject_to_property_taxes"),
document.getElementById("state_file_nj_homeowner_eligibility_form_homeowner_more_than_one_main_home_in_nj"),
document.getElementById("state_file_nj_homeowner_eligibility_form_homeowner_shared_ownership_not_spouse"),
document.getElementById("state_file_nj_homeowner_eligibility_form_homeowner_main_home_multi_unit"),
document.getElementById("state_file_nj_homeowner_eligibility_form_homeowner_main_home_multi_unit_max_four_one_commercial")
]
let conditionalCheckbox = document.getElementById("state_file_nj_homeowner_eligibility_form_homeowner_same_home_spouse")
jachan marked this conversation as resolved.
Show resolved Hide resolved
if (conditionalCheckbox != null) {
checkboxes.push(conditionalCheckbox)
}
noneCheckbox.addEventListener("change", function() {
if(this.checked) {
checkboxes.forEach(function(checkbox) {
checkbox.checked = false;
})
document.getElementById("homeowner_multi_unit_followup").style.setProperty('display', 'none');
}
})

checkboxes.forEach(function(checkbox) {
checkbox.addEventListener("change", function() {
if(this.checked) {
noneCheckbox.checked = false;
}
})
})
})
</script>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
</div>
<% end %>
</div>
<div class="white-group">
<div class="tight-checkboxes">
<%= f.cfa_checkbox(:tenant_none_of_the_above, t("general.none_of_these"), options: { checked_value: "yes", unchecked_value: "no" }) %>
</div>
</div>
</fieldset>

<div class="reveal">
Expand All @@ -65,4 +70,36 @@

<%= f.continue %>
<% end %>
<% end %>
<script>
document.addEventListener("DOMContentLoaded", function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pebble] Seeing that we're using the same logic twice, I wonder if it's worth adding the function passed to the event listener to `app/javascript. You could refactor it to work for both cases by passing in the IDs of all not-none checkboxes, for each id adding the checkbox to the checkbox array if they're not null, passing in the noneCheckbox ID, and then optional checkbox ids that should be hidden when none is checked

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like this suggestion too. we or other states might need this pattern in more places so it would be handy to reuse

let noneCheckbox = document.getElementById("state_file_nj_tenant_eligibility_form_tenant_none_of_the_above");
let checkboxes = [
document.getElementById("state_file_nj_tenant_eligibility_form_tenant_home_subject_to_property_taxes"),
document.getElementById("state_file_nj_tenant_eligibility_form_tenant_building_multi_unit"),
document.getElementById("state_file_nj_tenant_eligibility_form_tenant_access_kitchen_bath"),
document.getElementById("state_file_nj_tenant_eligibility_form_tenant_more_than_one_main_home_in_nj"),
document.getElementById("state_file_nj_tenant_eligibility_form_tenant_shared_rent_not_spouse")
]
let conditionalCheckbox = document.getElementById("state_file_nj_tenant_eligibility_form_tenant_same_home_spouse")
if (conditionalCheckbox != null) {
checkboxes.push(conditionalCheckbox)
}
noneCheckbox.addEventListener("change", function() {
if(this.checked) {
checkboxes.forEach(function(checkbox) {
checkbox.checked = false;
})
document.getElementById("tenant_access_kitchen_bath_followup").style.setProperty('display', 'none');
}
})

checkboxes.forEach(function(checkbox) {
checkbox.addEventListener("change", function() {
if(this.checked) {
noneCheckbox.checked = false;
}
})
})
})
</script>
<% end %>
Loading
Loading