82 lines
3.1 KiB
CoffeeScript
82 lines
3.1 KiB
CoffeeScript
context = window
|
|
teacherActions = window.JK.Actions.Teacher
|
|
logger = context.JK.logger
|
|
rest = window.JK.Rest()
|
|
|
|
@TeacherSetupIntroduction = React.createClass({
|
|
mixins: [
|
|
@TeacherSetupMixin,
|
|
Reflux.listenTo(@AppStore,"onAppInit"),
|
|
Reflux.listenTo(TeacherStore, "onTeacherStateChanged")
|
|
]
|
|
|
|
screenName: () ->
|
|
"introduction"
|
|
|
|
getInitialState: () ->
|
|
{}
|
|
|
|
onTeacherStateChanged: (changes) ->
|
|
$root = jQuery(this.getDOMNode())
|
|
logger.debug("onTeacherIntroStateChanged", changes, changes.errors?, changes.errors)
|
|
unless this.handleErrors(changes)
|
|
teacher = changes.teacher
|
|
this.setState({
|
|
biography: teacher.biography,
|
|
introductory_video: teacher.introductory_video,
|
|
years_teaching: teacher.years_teaching,
|
|
years_playing: teacher.years_playing,
|
|
validate_introduction: true
|
|
})
|
|
|
|
handleTextChange: (e) ->
|
|
this.setState({"#{e.target.name}": e.target.value})
|
|
|
|
navDestination: (instructions) ->
|
|
navTo=null
|
|
if instructions?
|
|
if instructions.direction=="cancel" || instructions.direction=="back"
|
|
navTo = @teacherSetupSource()
|
|
else if instructions.direction=="next"
|
|
navTo = @teacherSetupDestination('basics')
|
|
navTo
|
|
|
|
handleNav: (e) ->
|
|
navTo = this.navDestination(e)
|
|
teacherActions.change.trigger(this.state, {navTo: navTo})
|
|
|
|
render: () ->
|
|
`<div className="TeacherSetupIntroduction TeacherSetupComponent" >
|
|
<div className="teacher-big-column left">
|
|
<div className="teacher-field" name="biography">
|
|
<label htmlFor="teacher-biography">Teacher Bio:</label>
|
|
<textarea className="teacher-biography" name="biography" ref="biography" rows="12" value={this.state.biography} onChange={this.handleTextChange} required/>
|
|
</div>
|
|
</div>
|
|
<div className="teacher-small-column left">
|
|
<div className="teacher-field" name="introductory_video">
|
|
<label htmlFor="teacher-introductory-video">Teacher Introductory Video:</label>
|
|
|
|
|
|
<input className="teacher-introductory-video" name="introductory_video" ref="introductory_video" type="url" maxLength="1024" value={this.state.introductory_video} onChange={this.handleTextChange} required/>
|
|
|
|
|
|
<em>(enter YouTube URL)</em>
|
|
</div>
|
|
|
|
|
|
|
|
<div className="teacher-field" name="years_teaching">
|
|
<label htmlFor="years-teaching-experience">Years Teaching Experience:</label>
|
|
<input className="years-teaching-experience" name="years_teaching_experience" ref ="years_teaching_experience" type="number" min="0" max="99" value={this.state.years_teaching} onChange={this.handleTextChange} value="0" placeholder="Select" />
|
|
</div>
|
|
|
|
<div className="teacher-field" name="years_playing">
|
|
<label htmlFor="teacher-playing-experience">Years Playing Experience:</label>
|
|
<input className="years-playing-experience" name="years_playing_experience" ref="years_playing_experience" type="number" min="0" max="99" value={this.state.years_playing} onChange={this.handleTextChange} value="0" placeholder="Select" />
|
|
</div>
|
|
</div>
|
|
<TeacherSetupNav handleNav={this.handleNav}/>
|
|
</div>`
|
|
|
|
}) |