jam-cloud/web/app/assets/javascripts/react-components/AvatarEditLink.js.jsx.coffee

55 lines
1.3 KiB
CoffeeScript

context = window
rest = context.JK.Rest()
logger = context.JK.logger
AvatarStore = context.AvatarStore
@AvatarEditLink = React.createClass({
mixins: [
Reflux.listenTo(AvatarStore, "onAvatarUpdate"),
]
onAvatarUpdate: (avatar) ->
@setState({avatar: avatar})
getInitialState: () ->
{
avatar: null,
imageLoadedFpfile: null
}
componentWillMount: () ->
componentDidMount: () ->
@root = $(@getDOMNode())
startUpdate: () ->
AvatarActions.start(this.props.target, this.props.target_type)
render: () ->
if this.props.target?.photo_url?
testStudentUrl = "/school/#{this.props.target.id}/student?preview=true"
testTeacherUrl = "/school/#{this.props.target.id}/teacher?preview=true"
`<div className="avatar-edit-link">
<img src={this.props.target.photo_url}></img>
<br/>
<a onClick={this.startUpdate}>change/update logo</a><br/>
<div className="hint">See how it will look to&nbsp;
<a href={testStudentUrl} target="_blank">students</a> and&nbsp;
<a href={testTeacherUrl} target="_blank">teachers</a>
</div>
</div>`
else
`<div className="avatar-edit-link">
<div className="no-avatar-space">
No logo graphic uploaded
</div>
<a onClick={this.startUpdate}>change/update logo</a>
</div>`
})