From ae854d858f498a7d97828b0dd5f9cc153bedd6da Mon Sep 17 00:00:00 2001 From: Steven Miers Date: Mon, 21 Sep 2015 13:00:06 -0500 Subject: [PATCH] VRFS-3359 : Fix several errors related to syntax, property usage, etc. --- .../TeacherSetupPricing.js.jsx.coffee | 49 ++++++++++++------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/web/app/assets/javascripts/react-components/TeacherSetupPricing.js.jsx.coffee b/web/app/assets/javascripts/react-components/TeacherSetupPricing.js.jsx.coffee index 4f014b87b..e41318325 100644 --- a/web/app/assets/javascripts/react-components/TeacherSetupPricing.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/TeacherSetupPricing.js.jsx.coffee @@ -21,13 +21,15 @@ rest = window.JK.Rest() {} enableCheckBoxTargets: (e) -> - # Do unchecked boxes last since any unchecked target has priority: + # Do checked boxes first and THEN do unchecked + # boxes since any unchecked target has priority: checkBoxes = $("input[type='checkbox'].checkbox-enabler:checked", @root) checkBoxes = $.merge(checkBoxes, $("input[type='checkbox'].checkbox-enabler:not(:checked)", @root)) - checkBoxes.each -> - targetClass = $(this).data("enable-target") + $.each checkBoxes, (idx, checkBox) => + targetClass = $(checkBox).data("enable-target") + isChecked=$(checkBox).is(":checked") - if ($(this).is(":checked")) + if isChecked $(".#{targetClass}").removeClass("invisible") else $(".#{targetClass}").addClass("invisible") @@ -113,23 +115,36 @@ rest = window.JK.Rest() this.setState({"#{e.target.name}": e.target.value}) handleCheckChange: (e) -> + this.setState({"#{e.target.name}": e.target.checked}) @enableCheckBoxTargets() - this.setState({"#{e.target.name}": e.target.value=="on"}) render: () -> priceRows = [] + logger.debug("Current State is", this.state) for minutes in [30, 45, 60, 90, 120] pricePerLessonCents = context.JK.ProfileUtils.normalizeMoneyForDisplay(this.state["price_per_lesson_"+minutes+"_cents"]) pricePerMonthCents = context.JK.ProfileUtils.normalizeMoneyForDisplay(this.state["price_per_month_"+minutes+"_cents"]) pricePerLessonName = "price_per_lesson_#{minutes}_cents" pricePerMonthName = "price_per_month_#{minutes}_cents" - inputName = "lesson_duration_"+minutes+"_input" + priceKey = "lesson_duration_#{minutes}" + inputName = "#{priceKey}_input" + containerName = "#{priceKey}_container" priceRows.push `
-
- - +
+ + +
@@ -139,10 +154,10 @@ rest = window.JK.Rest()
- +
- +
@@ -154,14 +169,14 @@ rest = window.JK.Rest()
-
- - +
+ +
-
- - +
+ +