From 03452480e402d8c3c6410e2315374559bd4a8872 Mon Sep 17 00:00:00 2001 From: "Ernest W. Durbin III" Date: Thu, 12 Nov 2020 08:03:50 -0500 Subject: [PATCH 1/6] Check package only benefits as well (#1670) (#1671) A package only benefit's checkbox is rendered in the HTML with the disabled attribute. Because of that, the click event wasn't being triggered by the browser. This fix turn off and on this attribute so the click event can happen. Co-authored-by: Bernardo Fontes --- static/js/sponsors/applicationForm.js | 14 ++++++++++++-- templates/sponsors/sponsorship_benefits_form.html | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/static/js/sponsors/applicationForm.js b/static/js/sponsors/applicationForm.js index 558afb142..56189e374 100644 --- a/static/js/sponsors/applicationForm.js +++ b/static/js/sponsors/applicationForm.js @@ -17,12 +17,17 @@ $(document).ready(function(){ checkboxesContainer.find(':checkbox').each(function(){ $(this).prop('checked', false); + let packageOnlyBenefit = $(this).attr("package_only"); + if (packageOnlyBenefit) $(this).attr("disabled", true); }); let packageInfo = $("#package_benefits_" + package); packageInfo.children().each(function(){ let benefit = $(this).html() - checkboxesContainer.find(`[value=${benefit}]`).trigger("click"); + let benefitInput = checkboxesContainer.find(`[value=${benefit}]`); + let packageOnlyBenefit = benefitInput.attr("package_only"); + benefitInput.removeAttr("disabled"); + benefitInput.trigger("click"); }); let url = $("#cost_container").attr("calculate_cost_url"); @@ -38,7 +43,12 @@ $(document).ready(function(){ if (costLabel.html() != "Updating cost...") costLabel.html("Submit your application and we'll get in touch..."); let active = checkboxesContainer.find(`[value=${benefit}]`).prop("checked"); - if (!active) return; + if (!active) { + let packageOnlyBenefit = $(this).attr("package_only"); + if (packageOnlyBenefit) $(this).attr("disabled", true); + return; + } + $(`#conflicts_with_${benefit}`).children().each(function(){ let conflictId = $(this).html(); diff --git a/templates/sponsors/sponsorship_benefits_form.html b/templates/sponsors/sponsorship_benefits_form.html index f91e62351..27a85ad73 100644 --- a/templates/sponsors/sponsorship_benefits_form.html +++ b/templates/sponsors/sponsorship_benefits_form.html @@ -48,7 +48,7 @@

{{ field.label }}

{% for benefit in field.field.queryset %}