diff --git a/db/up/profile_teacher.sql b/db/up/profile_teacher.sql
index 8b4b51360..5e1155dc0 100644
--- a/db/up/profile_teacher.sql
+++ b/db/up/profile_teacher.sql
@@ -1,30 +1,33 @@
CREATE TABLE teachers (
id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4(),
- user_id VARCHAR(64) REFERENCES users(id) ON DELETE CASCADE,
- introductory_video VARCHAR(1024) NULL,
- years_teaching SMALLINT NOT NULL DEFAULT 0,
- years_playing SMALLINT NOT NULL DEFAULT 0,
- teaches_age_lower SMALLINT NOT NULL DEFAULT 0,
- teaches_age_upper SMALLINT NOT NULL DEFAULT 0,
- teaches_beginner BOOLEAN NOT NULL DEFAULT FALSE,
- teaches_intermediate BOOLEAN NOT NULL DEFAULT FALSE,
- teaches_advanced BOOLEAN NOT NULL DEFAULT FALSE,
- website VARCHAR(1024) NULL,
- biography VARCHAR(4096) NULL,
- prices_per_lesson BOOLEAN NOT NULL DEFAULT FALSE,
- prices_per_month BOOLEAN NOT NULL DEFAULT FALSE,
- lesson_duration_30 BOOLEAN NOT NULL DEFAULT FALSE,
- lesson_duration_45 BOOLEAN NOT NULL DEFAULT FALSE,
- lesson_duration_60 BOOLEAN NOT NULL DEFAULT FALSE,
- lesson_duration_90 BOOLEAN NOT NULL DEFAULT FALSE,
- lesson_duration_120 BOOLEAN NOT NULL DEFAULT FALSE,
- price_per_lesson_cents INT NULL,
- price_per_month_cents INT NULL,
- price_duration_30_cents INT NULL,
- price_duration_45_cents INT NULL,
- price_duration_60_cents INT NULL,
- price_duration_90_cents INT NULL,
- price_duration_120_cents INT NULL,
+ user_id VARCHAR(64) REFERENCES users(id) ON DELETE CASCADE,
+ introductory_video VARCHAR(1024) NULL,
+ years_teaching SMALLINT NOT NULL DEFAULT 0,
+ years_playing SMALLINT NOT NULL DEFAULT 0,
+ teaches_age_lower SMALLINT NOT NULL DEFAULT 0,
+ teaches_age_upper SMALLINT NOT NULL DEFAULT 0,
+ teaches_beginner BOOLEAN NOT NULL DEFAULT FALSE,
+ teaches_intermediate BOOLEAN NOT NULL DEFAULT FALSE,
+ teaches_advanced BOOLEAN NOT NULL DEFAULT FALSE,
+ website VARCHAR(1024) NULL,
+ biography VARCHAR(4096) NULL,
+ prices_per_lesson BOOLEAN NOT NULL DEFAULT FALSE,
+ prices_per_month BOOLEAN NOT NULL DEFAULT FALSE,
+ lesson_duration_30 BOOLEAN NOT NULL DEFAULT FALSE,
+ lesson_duration_45 BOOLEAN NOT NULL DEFAULT FALSE,
+ lesson_duration_60 BOOLEAN NOT NULL DEFAULT FALSE,
+ lesson_duration_90 BOOLEAN NOT NULL DEFAULT FALSE,
+ lesson_duration_120 BOOLEAN NOT NULL DEFAULT FALSE,
+ price_per_lesson_30_cents INT NULL,
+ price_per_lesson_45_cents INT NULL,
+ price_per_lesson_60_cents INT NULL,
+ price_per_lesson_90_cents INT NULL,
+ price_per_lesson_120_cents INT NULL,
+ price_per_month_30_cents INT NULL,
+ price_per_month_45_cents INT NULL,
+ price_per_month_60_cents INT NULL,
+ price_per_month_90_cents INT NULL,
+ price_per_month_120_cents INT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
@@ -48,7 +51,7 @@ CREATE TABLE teacher_experiences(
name VARCHAR(200) NOT NULL,
organization VARCHAR(200) NOT NULL,
start_year SMALLINT NOT NULL DEFAULT 0,
- end_year SMALLINT NOT NULL DEFAULT 0
+ end_year SMALLINT NULL
);
-- Has many/through tables:
diff --git a/ruby/lib/jam_ruby/models/teacher.rb b/ruby/lib/jam_ruby/models/teacher.rb
index bb4a57bbc..102a32cef 100644
--- a/ruby/lib/jam_ruby/models/teacher.rb
+++ b/ruby/lib/jam_ruby/models/teacher.rb
@@ -67,13 +67,16 @@ module JamRuby
teacher.lesson_duration_60 = params[:lesson_duration_60] if params.key?(:lesson_duration_60)
teacher.lesson_duration_90 = params[:lesson_duration_90] if params.key?(:lesson_duration_90)
teacher.lesson_duration_120 = params[:lesson_duration_120] if params.key?(:lesson_duration_120)
- teacher.price_per_lesson_cents = params[:price_per_lesson_cents] if params.key?(:price_per_lesson_cents)
- teacher.price_per_month_cents = params[:price_per_month_cents] if params.key?(:price_per_month_cents)
- teacher.price_duration_30_cents = params[:price_duration_30_cents] if params.key?(:price_duration_30_cents)
- teacher.price_duration_45_cents = params[:price_duration_45_cents] if params.key?(:price_duration_45_cents)
- teacher.price_duration_60_cents = params[:price_duration_60_cents] if params.key?(:price_duration_60_cents)
- teacher.price_duration_90_cents = params[:price_duration_90_cents] if params.key?(:price_duration_90_cents)
- teacher.price_duration_120_cents = params[:price_duration_120_cents] if params.key?(:price_duration_120_cents)
+ teacher.price_per_lesson_30_cents = params[:price_per_lesson_30_cents] if params.key?(:price_per_lesson_30_cents)
+ teacher.price_per_lesson_45_cents = params[:price_per_lesson_45_cents] if params.key?(:price_per_lesson_45_cents)
+ teacher.price_per_lesson_60_cents = params[:price_per_lesson_60_cents] if params.key?(:price_per_lesson_60_cents)
+ teacher.price_per_lesson_90_cents = params[:price_per_lesson_90_cents] if params.key?(:price_per_lesson_90_cents)
+ teacher.price_per_lesson_120_cents = params[:price_per_lesson_120_cents] if params.key?(:price_per_lesson_120_cents)
+ teacher.price_per_month_30_cents = params[:price_per_month_30_cents] if params.key?(:price_per_month_30_cents)
+ teacher.price_per_month_45_cents = params[:price_per_month_45_cents] if params.key?(:price_per_month_45_cents)
+ teacher.price_per_month_60_cents = params[:price_per_month_60_cents] if params.key?(:price_per_month_60_cents)
+ teacher.price_per_month_90_cents = params[:price_per_month_90_cents] if params.key?(:price_per_month_90_cents)
+ teacher.price_per_month_120_cents = params[:price_per_month_120_cents] if params.key?(:price_per_month_120_cents)
# Many-to-many relations:
teacher.genres = params[:genres].collect{|genre_id|Genre.find(genre_id)} if params[:genres].present?
diff --git a/ruby/lib/jam_ruby/models/teacher_experience.rb b/ruby/lib/jam_ruby/models/teacher_experience.rb
index e544b9ea2..1b311886a 100644
--- a/ruby/lib/jam_ruby/models/teacher_experience.rb
+++ b/ruby/lib/jam_ruby/models/teacher_experience.rb
@@ -3,7 +3,8 @@ module JamRuby
include HtmlSanitize
html_sanitize strict: [:name, :organization]
belongs_to :teacher, :class_name => "JamRuby::Teacher"
-
+ attr_accessible :name, :experience_type, :organization, :start_year, :end_year
+
scope :teaching, where(experience_type: 'teaching')
scope :education, where(experience_type: 'education')
scope :awards, where(experience_type: 'award')
diff --git a/ruby/spec/jam_ruby/models/teacher_spec.rb b/ruby/spec/jam_ruby/models/teacher_spec.rb
index 9164829b2..17a333270 100644
--- a/ruby/spec/jam_ruby/models/teacher_spec.rb
+++ b/ruby/spec/jam_ruby/models/teacher_spec.rb
@@ -144,13 +144,16 @@ describe Teacher do
lesson_duration_60: true,
lesson_duration_90: true,
lesson_duration_120: true,
- price_per_lesson_cents: 3000,
- price_per_month_cents: 3000,
- price_duration_30_cents: 3000,
- price_duration_45_cents: 3000,
- price_duration_60_cents: 3000,
- price_duration_90_cents: 3000,
- price_duration_120_cents: 3000
+ price_per_lesson_30_cents: 3000,
+ price_per_lesson_45_cents: 3000,
+ price_per_lesson_60_cents: 3000,
+ price_per_lesson_90_cents: 3000,
+ price_per_lesson_120_cents: 3000,
+ price_per_month_30_cents: 5000,
+ price_per_month_45_cents: 5000,
+ price_per_month_60_cents: 5000,
+ price_per_month_90_cents: 5000,
+ price_per_month_120_cents: 5000
)
teacher.should_not be_nil
@@ -165,13 +168,16 @@ describe Teacher do
t.lesson_duration_60.should be_true
t.lesson_duration_90.should be_true
t.lesson_duration_120.should be_true
- t.price_per_lesson_cents.should == 3000
- t.price_per_month_cents.should == 3000
- t.price_duration_30_cents.should == 3000
- t.price_duration_45_cents.should == 3000
- t.price_duration_60_cents.should == 3000
- t.price_duration_90_cents.should == 3000
- t.price_duration_120_cents.should == 3000
+ t.price_per_lesson_30_cents.should == 3000
+ t.price_per_lesson_45_cents.should == 3000
+ t.price_per_lesson_60_cents.should == 3000
+ t.price_per_lesson_90_cents.should == 3000
+ t.price_per_lesson_120_cents.should == 3000
+ t.price_per_month_30_cents.should == 5000
+ t.price_per_month_45_cents.should == 5000
+ t.price_per_month_60_cents.should == 5000
+ t.price_per_month_90_cents.should == 5000
+ t.price_per_month_120_cents.should == 5000
end
end
@@ -249,13 +255,11 @@ describe Teacher do
lesson_duration_60: false,
lesson_duration_90: false,
lesson_duration_120: false,
- price_per_lesson_cents: 3000,
- price_per_month_cents: 3000,
- #price_duration_30_cents: 3000,
- price_duration_45_cents: 3000,
- #price_duration_60_cents: 3000,
- #price_duration_90_cents: 3000,
- price_duration_120_cents: 3000,
+ #price_per_lesson_30_cents: 3000,
+ price_per_lesson_45_cents: 3000,
+ #price_per_lesson_60_cents: 3000,
+ #price_per_lesson_90_cents: 3000,
+ price_per_lesson_120_cents: 3000,
validate_pricing:true
)
diff --git a/web/app/assets/javascripts/react-components/CheckBoxList.js.jsx.coffee b/web/app/assets/javascripts/react-components/CheckBoxList.js.jsx.coffee
index b03ead5f8..6b2d92b77 100644
--- a/web/app/assets/javascripts/react-components/CheckBoxList.js.jsx.coffee
+++ b/web/app/assets/javascripts/react-components/CheckBoxList.js.jsx.coffee
@@ -28,7 +28,7 @@ logger = context.JK.logger
for object in this.props.sourceObjects
nm = "check_#{object.id}"
checkedStr = if @isChecked(object.id) then "checked" else ""
- object_options.push `
`
+ object_options.push ``
`
diff --git a/web/app/assets/javascripts/react-components/TeacherExperienceEditableList.js.jsx.coffee b/web/app/assets/javascripts/react-components/TeacherExperienceEditableList.js.jsx.coffee
index 091b440af..d40a33c10 100644
--- a/web/app/assets/javascripts/react-components/TeacherExperienceEditableList.js.jsx.coffee
+++ b/web/app/assets/javascripts/react-components/TeacherExperienceEditableList.js.jsx.coffee
@@ -3,38 +3,50 @@ rest = window.JK.Rest()
logger = context.JK.logger
@TeacherExperienceEditableList = React.createClass({
- #instruments: []
componentDidUnmount: () ->
- #@instruments = []
+ @root.off("submit", ".teacher-experience-teaching-form")
componentDidMount: () ->
- $root = jQuery(this.getDOMNode())
- #rest.getInstruments().done (instruments) =>
- #@instruments = instruments
-
- $root.off("submit", ".teacher-experience-teaching-form").on("submit", ".teacher-experience-teaching-form", @addExperience)
+ @root = jQuery(this.getDOMNode())
+ @root.off("submit", ".teacher-experience-teaching-form").on("submit", ".teacher-experience-teaching-form", @addExperience)
formatListItem: (obj) ->
- "#{obj.name}"
+ t = "#{obj.name}/#{obj.organization} (#{obj.start_year}"
+ t += "-#{obj.end_year}" if this.props.showEndDate
+ t += ")"
- listItems: () ->
- logger.debug("listItems", this.props.listItems)
- this.props.listItems
+ getInitialProps: () ->
+ {listItems: []}
+
+ sortListItems: () ->
+ this.props.listItems ||= []
+ this.props.listItems = _.sortBy(this.props.listItems, 'start_year')
+
+ addError: (k,v) ->
+ teacherField = @root#.find(".teacher-field[name='#{k}'] > td").first()
+ teacherField.prepend("
#{v.join()}
")
+ $("input", teacherField).addClass("input-error")
addExperience: (e) ->
e.preventDefault()
logger.debug("addExperience", this.props.listItems, this.props)
$form = e.target
- formValues = $(":input", $form).formToObject()
- this.props.listItems.push {
- name: $("[name='title_input']", $form).val()
- organization: $("[name='organization_input']", $form).val()
- start_year: $("[name='start_year']", $form).val()
- end_year: $("[name='end_year']", $form).val()
- }
- logger.debug("addExperience", this.props.listItems)
- this.props.onItemChanged(this.props.experienceType, this.props.listItems)
- $form.reset()
+
+ start_year = $("[name='start_year']", $form).val()
+ end_year = $("[name='end_year']", $form).val()
+
+ if this.props.showEndDate && start_year > end_year
+ this.addError("date", ["End year must be greater than start year"])
+ else
+ this.props.listItems.push {
+ name: $("[name='title_input']", $form).val()
+ organization: $("[name='organization_input']", $form).val()
+ start_year: start_year
+ end_year: end_year
+ }
+ logger.debug("addExperience", this.props.listItems)
+ this.props.onItemChanged(this.props.experienceType, this.props.listItems)
+ $form.reset()
false
render: () ->
@@ -42,23 +54,33 @@ logger = context.JK.logger
if this.props.showEndDate
endDate.push `
`
+ dtLabel = "Start & End"
+ else
+ dtLabel = "Date"
+ titleLabel = this.props.titleLabel
+ orgLabel = this.props.orgLabel
+
+ titleLabel ||= "Title"
+ orgLabel ||= "School/Org"
+
+ listItems= _.sortBy(this.props.listItems, 'start_year')
`
`
})
\ No newline at end of file
diff --git a/web/app/assets/javascripts/react-components/TeacherSetupBasics.js.jsx.coffee b/web/app/assets/javascripts/react-components/TeacherSetupBasics.js.jsx.coffee
index d301de3fb..af0385ac9 100644
--- a/web/app/assets/javascripts/react-components/TeacherSetupBasics.js.jsx.coffee
+++ b/web/app/assets/javascripts/react-components/TeacherSetupBasics.js.jsx.coffee
@@ -56,10 +56,7 @@ rest = window.JK.Rest()
navTo = this.navDestination(e)
teacherActions.change.trigger(this.state, {navTo: navTo})
- render: () ->
- instrumentsTaughtCheckboxes = []
- #instrumentsTaughtCheckboxes.push(`
`)
-
+ render: () ->
# Render the following:
# Instruments
# Subjects
diff --git a/web/app/assets/javascripts/react-components/TeacherSetupExperience.js.jsx.coffee b/web/app/assets/javascripts/react-components/TeacherSetupExperience.js.jsx.coffee
index 72e39587c..e2750152e 100644
--- a/web/app/assets/javascripts/react-components/TeacherSetupExperience.js.jsx.coffee
+++ b/web/app/assets/javascripts/react-components/TeacherSetupExperience.js.jsx.coffee
@@ -11,7 +11,11 @@ rest = window.JK.Rest()
]
getInitialState: () ->
- {}
+ {
+ experiences_teaching: []
+ experiences_education: []
+ experiences_award: []
+ }
screenName: () ->
"experience"
@@ -22,9 +26,9 @@ rest = window.JK.Rest()
teacher = changes.teacher
this.setState({
#validate_basics: true,
- experience_teaching: teacher.experience_teaching
- experience_education: teacher.experience_education
- experience_award: teacher.experience_award
+ experiences_teaching: teacher.experiences_teaching
+ experiences_education: teacher.experiences_education
+ experiences_award: teacher.experiences_award
})
captureFormState: (changes) ->
@@ -54,29 +58,36 @@ rest = window.JK.Rest()
handleListChange: (listName, listObjects)->
logger.debug("EXPERIENCE handleListChange:", listName, listObjects)
this.setState({
- "experience_#{listName}": listObjects
+ "experiences_#{listName}": listObjects
})
#this.forceUpdate()
render: () ->
- logger.debug("RENDERING TeacherSetupExperience", this.props, this.state)
- instrumentsTaughtCheckboxes = []
- #instrumentsTaughtCheckboxes.push(`
`)
-
`
-
+
-
+
-
+
diff --git a/web/app/assets/javascripts/react-components/TeacherSetupIntroduction.js.jsx.coffee b/web/app/assets/javascripts/react-components/TeacherSetupIntroduction.js.jsx.coffee
index 6d50ec431..034aa7972 100644
--- a/web/app/assets/javascripts/react-components/TeacherSetupIntroduction.js.jsx.coffee
+++ b/web/app/assets/javascripts/react-components/TeacherSetupIntroduction.js.jsx.coffee
@@ -21,7 +21,6 @@ rest = window.JK.Rest()
logger.debug("onTeacherIntroStateChanged", changes, changes.errors?, changes.errors)
unless this.handleErrors(changes)
teacher = changes.teacher
- logger.debug("@teacher", teacher)
this.setState({
biography: teacher.biography,
introductory_video: teacher.introductory_video,
@@ -30,56 +29,45 @@ rest = window.JK.Rest()
validate_introduction: true
})
- captureFormState: (changes) ->
- $root = jQuery(this.getDOMNode())
- this.setState({
- biography: $root.find(".teacher-biography").val(),
- introductory_video: $root.find(".teacher-introductory-video").val(),
- years_teaching: $root.find(".years-teaching-experience").val(),
- years_playing: $root.find(".years-playing-experience").val()
- });
- logger.debug("capturedFormState", this.state, changes)
+ handleTextChange: (e) ->
+ this.setState({"#{e.target.name}": e.target.value})
navDestination: (instructions) ->
navTo=null
if instructions?
- logger.debug("handling instructions", instructions)
if instructions.direction=="cancel" || instructions.direction=="back"
navTo = @teacherSetupSource()
else if instructions.direction=="next"
- logger.debug("redireing to basics")
navTo = @teacherSetupDestination('basics')
navTo
handleNav: (e) ->
- logger.debug("handleNav #{this.screenName()}: ", this.state, this, e)
navTo = this.navDestination(e)
teacherActions.change.trigger(this.state, {navTo: navTo})
render: () ->
- logger.debug("RENDERING TeacherSetupIntroduction", this.props, this.state)
`
-
-
+
+
diff --git a/web/app/assets/javascripts/react-components/TeacherSetupNav.js.jsx.coffee b/web/app/assets/javascripts/react-components/TeacherSetupNav.js.jsx.coffee
index 5ec195cb7..83f5b39a5 100644
--- a/web/app/assets/javascripts/react-components/TeacherSetupNav.js.jsx.coffee
+++ b/web/app/assets/javascripts/react-components/TeacherSetupNav.js.jsx.coffee
@@ -16,7 +16,7 @@ SessionActions = @SessionActions
render: () ->
console.log("SetupNav: this.props", this.state, this.ref, this.props.handleNav)
- `
+ `
BACK
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 0714e0396..4f014b87b 100644
--- a/web/app/assets/javascripts/react-components/TeacherSetupPricing.js.jsx.coffee
+++ b/web/app/assets/javascripts/react-components/TeacherSetupPricing.js.jsx.coffee
@@ -10,40 +10,91 @@ rest = window.JK.Rest()
Reflux.listenTo(TeacherStore, "onTeacherStateChanged")
]
+ componentDidUnmount: () ->
+ @root.off("change", ".checkbox-enabler")
+
+ componentDidMount: () ->
+ @root = jQuery(this.getDOMNode())
+ @enableCheckBoxTargets()
+
getInitialState: () ->
{}
+ enableCheckBoxTargets: (e) ->
+ # Do unchecked boxes last 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")
+
+ if ($(this).is(":checked"))
+ $(".#{targetClass}").removeClass("invisible")
+ else
+ $(".#{targetClass}").addClass("invisible")
+ true
+
screenName: () ->
"pricing"
onTeacherStateChanged: (changes) ->
- $root = jQuery(this.getDOMNode())
- logger.debug("onTeacherPricingStateChanged", changes, changes.errors?, changes.errors)
+
unless this.handleErrors(changes)
teacher = changes.teacher
- logger.debug("@teacher", teacher)
this.setState({
- biography: teacher.biography,
- introductory_video: teacher.introductory_video,
- years_teaching: teacher.years_teaching,
- years_playing: teacher.years_playing,
- validate_pricing: true
+ price_per_lesson_30_cents: teacher.price_per_lesson_30_cents
+ price_per_lesson_45_cents: teacher.price_per_lesson_45_cents
+ price_per_lesson_60_cents: teacher.price_per_lesson_60_cents
+ price_per_lesson_90_cents: teacher.price_per_lesson_90_cents
+ price_per_lesson_120_cents: teacher.price_per_lesson_120_cents
+ price_per_month_30_cents: teacher.price_per_month_30_cents
+ price_per_month_45_cents: teacher.price_per_month_45_cents
+ price_per_month_60_cents: teacher.price_per_month_60_cents
+ price_per_month_90_cents: teacher.price_per_month_90_cents
+ price_per_month_120_cents: teacher.price_per_month_120_cents
+ prices_per_lesson: teacher.prices_per_lesson
+ prices_per_month: teacher.prices_per_month
+ lesson_duration_30: teacher.lesson_duration_30
+ lesson_duration_45: teacher.lesson_duration_45
+ lesson_duration_60: teacher.lesson_duration_60
+ lesson_duration_90: teacher.lesson_duration_90
+ lesson_duration_120: teacher.lesson_duration_120
+ })
+ @enableCheckBoxTargets()
+ false
+
+
+
+ captureFormState: (e) ->
+ this.setState({
+ prices_per_lesson: $("[name='prices_per_lesson_input']", @root).is(":checked")
+ prices_per_month: $("[name='prices_per_month_input']", @root).is(":checked")
+ lesson_duration_30: $("[name='lesson_duration_30_input']", @root).is(":checked")
+ lesson_duration_45: $("[name='lesson_duration_45_input']", @root).is(":checked")
+ lesson_duration_60: $("[name='lesson_duration_60_input']", @root).is(":checked")
+ lesson_duration_90: $("[name='lesson_duration_90_input']", @root).is(":checked")
+ lesson_duration_120: $("[name='lesson_duration_120_input']", @root).is(":checked")
+ })
+ @enableCheckBoxTargets()
+ #this.forceUpdate()
+
+ captureCurrency: (e) ->
+ for minutes in [30, 45, 60, 90, 120]
+ pricePerLessonCents = context.JK.ProfileUtils.normalizeMoneyForSubmit($("[name='price_per_lesson_#{minutes}_cents']", @root).val())
+ pricePerMonthCents = context.JK.ProfileUtils.normalizeMoneyForSubmit($("[name='price_per_month_#{minutes}_cents']", @root).val())
+
+ this.setState({
+ "price_per_lesson_#{minutes}_cents": pricePerLessonCents
+ "price_per_month_#{minutes}_cents": pricePerMonthCents
})
- captureFormState: (changes) ->
- $root = jQuery(this.getDOMNode())
- this.setState({
- biography: $root.find(".teacher-biography").val(),
- introductory_video: $root.find(".teacher-introductory-video").val(),
- years_teaching: $root.find(".years-teaching-experience").val(),
- years_playing: $root.find(".years-playing-experience").val()
- });
- logger.debug("capturedFormState", this.state, changes)
+ displayLessonAmount = context.JK.ProfileUtils.normalizeMoneyForDisplay(pricePerLessonCents)
+ displayMonthAmount = context.JK.ProfileUtils.normalizeMoneyForDisplay(pricePerMonthCents)
+ $("[name='price_per_lesson_#{minutes}_cents']", @root).val(displayLessonAmount)
+ $("[name='price_per_month_#{minutes}_cents']", @root).val(displayMonthAmount)
navDestination: (instructions) ->
navTo=null
if instructions?
- logger.debug("handling instructions", instructions)
if instructions.direction=="cancel"
navTo = @teacherSetupSource()
else if instructions.direction=="back"
@@ -55,24 +106,91 @@ rest = window.JK.Rest()
navTo
handleNav: (e) ->
- logger.debug("handleNav #{this.screenName()}: ", this.state, this, e)
navTo = this.navDestination(e)
teacherActions.change.trigger(this.state, {navTo: navTo})
- render: () ->
- logger.debug("RENDERING TeacherSetupPricing", this.props, this.state)
- instrumentsTaughtCheckboxes = []
- #instrumentsTaughtCheckboxes.push(`
`)
+ handleTextChange: (e) ->
+ this.setState({"#{e.target.name}": e.target.value})
- `
-
-
-
-
+ handleCheckChange: (e) ->
+ @enableCheckBoxTargets()
+ this.setState({"#{e.target.name}": e.target.value=="on"})
+
+ render: () ->
+ priceRows = []
+ 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"
+ priceRows.push `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
`
+
+ # Render:
+ `
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {priceRows}
+
+
+
`
diff --git a/web/app/assets/javascripts/react-components/YearSelect.js.jsx.coffee b/web/app/assets/javascripts/react-components/YearSelect.js.jsx.coffee
index 3b48034f1..3cd223d16 100644
--- a/web/app/assets/javascripts/react-components/YearSelect.js.jsx.coffee
+++ b/web/app/assets/javascripts/react-components/YearSelect.js.jsx.coffee
@@ -18,7 +18,7 @@ logger = context.JK.logger
for yr in [1901..now]
options.push `
`
- `