VRFS-3359 : Proper setting of experience keys and saving.

This commit is contained in:
Steven Miers 2015-08-31 11:32:20 -05:00
parent e028a604cf
commit 0878c5fd3f
5 changed files with 13 additions and 13 deletions

View File

@ -3,7 +3,8 @@ module JamRuby
include HtmlSanitize include HtmlSanitize
html_sanitize strict: [:name, :organization] html_sanitize strict: [:name, :organization]
belongs_to :teacher, :class_name => "JamRuby::Teacher" belongs_to :teacher, :class_name => "JamRuby::Teacher"
attr_accessible :name, :experience_type, :organization, :start_year, :end_year
scope :teaching, where(experience_type: 'teaching') scope :teaching, where(experience_type: 'teaching')
scope :education, where(experience_type: 'education') scope :education, where(experience_type: 'education')
scope :awards, where(experience_type: 'award') scope :awards, where(experience_type: 'award')

View File

@ -25,7 +25,6 @@ logger = context.JK.logger
e.preventDefault() e.preventDefault()
logger.debug("addExperience", this.props.listItems, this.props) logger.debug("addExperience", this.props.listItems, this.props)
$form = e.target $form = e.target
formValues = $(":input", $form).formToObject()
this.props.listItems.push { this.props.listItems.push {
name: $("[name='title_input']", $form).val() name: $("[name='title_input']", $form).val()
organization: $("[name='organization_input']", $form).val() organization: $("[name='organization_input']", $form).val()

View File

@ -22,9 +22,9 @@ rest = window.JK.Rest()
teacher = changes.teacher teacher = changes.teacher
this.setState({ this.setState({
#validate_basics: true, #validate_basics: true,
experience_teaching: teacher.experience_teaching experiences_teaching: teacher.experiences_teaching
experience_education: teacher.experience_education experiences_education: teacher.experiences_education
experience_award: teacher.experience_award experiences_award: teacher.experiences_award
}) })
captureFormState: (changes) -> captureFormState: (changes) ->
@ -54,7 +54,7 @@ rest = window.JK.Rest()
handleListChange: (listName, listObjects)-> handleListChange: (listName, listObjects)->
logger.debug("EXPERIENCE handleListChange:", listName, listObjects) logger.debug("EXPERIENCE handleListChange:", listName, listObjects)
this.setState({ this.setState({
"experience_#{listName}": listObjects "experiences_#{listName}": listObjects
}) })
#this.forceUpdate() #this.forceUpdate()
@ -66,17 +66,17 @@ rest = window.JK.Rest()
`<div className="TeacherSetupExperience TeacherSetupComponent"> `<div className="TeacherSetupExperience TeacherSetupComponent">
<div className="teacher-third-column"> <div className="teacher-third-column">
<label className="sub-caption">TEACHING EXPERIENCE:</label> <label className="sub-caption">TEACHING EXPERIENCE:</label>
<TeacherExperienceEditableList showEndDate="true" experienceType="teaching" onItemChanged={this.handleListChange} listItems={this.state.experience_teaching}/> <TeacherExperienceEditableList showEndDate="true" experienceType="teaching" onItemChanged={this.handleListChange} listItems={this.state.experiences_teaching}/>
</div> </div>
<div className="teacher-third-column"> <div className="teacher-third-column">
<label className="sub-caption">EDUCATION:</label> <label className="sub-caption">EDUCATION:</label>
<TeacherExperienceEditableList showEndDate="true" experienceType="education" onItemChanged={this.handleListChange} listItems={this.state.experience_education}/> <TeacherExperienceEditableList showEndDate="true" experienceType="education" onItemChanged={this.handleListChange} listItems={this.state.experiences_education}/>
</div> </div>
<div className="teacher-third-column"> <div className="teacher-third-column">
<label className="sub-caption">AWARDS:</label> <label className="sub-caption">AWARDS:</label>
<TeacherExperienceEditableList experienceType="award" onItemChanged={this.handleListChange} listItems={this.state.experience_award}/> <TeacherExperienceEditableList experienceType="award" onItemChanged={this.handleListChange} listItems={this.state.experiences_award}/>
</div> </div>
<TeacherSetupNav handleNav={this.handleNav}> </TeacherSetupNav> <TeacherSetupNav handleNav={this.handleNav}> </TeacherSetupNav>

View File

@ -18,7 +18,7 @@ logger = context.JK.logger
for yr in [1901..now] for yr in [1901..now]
options.push `<option value={yr}>{yr}</option>` options.push `<option value={yr}>{yr}</option>`
`<select className="YearSelect react-component" required placeholder="Select"> `<select className="YearSelect react-component" name={this.props.name} required placeholder="Select">
{options} {options}
</select>` </select>`
}) })

View File

@ -48,7 +48,7 @@ node :languages do
@teacher.languages.collect{|o|o.id} @teacher.languages.collect{|o|o.id}
end end
node :experience_teaching do node :experiences_teaching do
@teacher.experiences_teaching.collect do |o| @teacher.experiences_teaching.collect do |o|
{ {
name: o.name, name: o.name,
@ -60,7 +60,7 @@ node :experience_teaching do
end # collect end # collect
end end
node :experience_education do node :experiences_education do
@teacher.experiences_education.collect do |o| @teacher.experiences_education.collect do |o|
{ {
name: o.name, name: o.name,
@ -72,7 +72,7 @@ node :experience_education do
end # collect end # collect
end end
node :experience_award do node :experiences_award do
@teacher.experiences_award.collect do |o| @teacher.experiences_award.collect do |o|
{ {
name: o.name, name: o.name,