-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task.cjsx
41 lines (34 loc) · 1.44 KB
/
Task.cjsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#Task component - represents a single todo item
@Task = React.createClass
propTypes:
#the component gets the task to display through a React group
task: React.PropTypes.object.isRequired
showPrivateButton: React.PropTypes.bool.isRequired
toggleChecked: ->
#Set the toggle property of the oposite of its current value
Meteor.call "setChecked", @props.task._id, ! @props.task.checked
deleteThisTask: ->
Meteor.call "removeTask", @props.task._id
togglePrivate: ->
Meteor.call "setPrivate", @props.task._id, ! @props.task.private
render: ->
taskClassName = (if @props.task.checked then "checked" else "") + " "\
+ (if @props.task.private then "private" else "")
<li className={taskClassName}>
<button className="delete" onClick={this.deleteThisTask}>
×
</button>
<input
type="checkbox"
readOnly={true}
checked={this.props.task.checked}
onClick={this.toggleChecked} />
{if @props.showPrivateButton
<button className="toggle-private" onClick={@togglePrivate} >
{if @props.task.private then "Private" else "Public"}
</button>
}
<span className="text">
<strong>{this.props.task.username}</strong> {this.props.task.text}
</span>
</li>