Don't assume there are tasks

This commit is contained in:
Tom Willemse 2013-07-05 00:02:10 +02:00
parent 12ee321c64
commit 74ec275c8f

View file

@ -64,7 +64,8 @@ var StoryTaskTable = React.createClass({
render: function() { render: function() {
var taskNodes = this.props.tasks.map(function (task) { var taskNodes = this.props.tasks.map(function (task) {
return <StoryTaskRow task={task} />; return <StoryTaskRow task={task} />;
}); }.bind(this));
return ( return (
<table class="table table-striped"> <table class="table table-striped">
{taskNodes} {taskNodes}
@ -111,11 +112,16 @@ var StoryData = React.createClass({
}); });
}), }),
render: function() { render: function() {
var taskTable = null;
if (this.props.data.tasks)
taskTable = <StoryTaskTable tasks={this.props.data.tasks} />;
if (this.props.data) { if (this.props.data) {
return (<div> return (<div>
Assignee: {this.props.data.assignee} Assignee: {this.props.data.assignee}
<pre>{this.props.data.content}</pre> <pre>{this.props.data.content}</pre>
<StoryTaskTable tasks={this.props.data.tasks} /> {taskTable}
<StoryTaskForm onTaskSubmit={this.handleTaskSubmit} /> <StoryTaskForm onTaskSubmit={this.handleTaskSubmit} />
</div>); </div>);
} }