From bdd07b68ca1f70b53bfcc8e54fc7ec489e4b52e8 Mon Sep 17 00:00:00 2001
From: Tom Willemse
Date: Sat, 13 Jul 2013 19:57:22 +0200
Subject: Show story data next to backlog
---
static/js/main.js | 70 ++++++++++++++++++++++++++++++-------------------------
1 file changed, 38 insertions(+), 32 deletions(-)
(limited to 'static')
diff --git a/static/js/main.js b/static/js/main.js
index 0a40489..28abd54 100644
--- a/static/js/main.js
+++ b/static/js/main.js
@@ -90,35 +90,34 @@ var StoryTaskForm = React.createClass({
var StoryData = React.createClass({
handleTaskSubmit: React.autoBind(function (task) {
- task.storyId = this.props.data.id;
+ task.storyId = this.state.data.id;
$.post("/stories/tasks/new", task);
}),
+ getInitialState: function() {
+ return {data: null};
+ },
+ setData: function(data) {
+ this.setState({data: data});
+ },
render: function() {
- var taskTable = null;
-
- if (this.props.data.tasks)
- taskTable = ;
-
- if (this.props.data) {
+ if (this.state.data) {
return (
- Assignee: {this.props.data.assignee}
-
{this.props.data.content}
- {taskTable}
-
+
{this.state.data.title}
+ Assignee: {this.state.data.assignee}
+
+ {this.state.data.content}
+
+
+
);
}
- return null;
+ return ;
}
});
var StoryRow = React.createClass({
render: function() {
- var sdata = null;
-
- if (this.state.content)
- sdata = ;
-
return (
@@ -137,8 +136,6 @@ var StoryRow = React.createClass({
{this.props.story.necessity} to
{this.props.story.title}
-
- {sdata}
|
);
@@ -148,15 +145,7 @@ var StoryRow = React.createClass({
content: null};
},
handleClick: React.autoBind(function(event) {
- if (!!this.state.content) {
- this.setState({content: null});
- return;
- }
-
- $.get('/stories/' + this.props.story.id)
- .done(function (data, textStatus, jqXHR) {
- this.setState({content: data});
- }.bind(this), 'json');
+ this.props.onTitleClicked(this.props.story.id);
}),
changeState: React.autoBind(function(event) {
$.post("/stories/state", {'id': this.props.story.id})
@@ -185,9 +174,13 @@ var StoryTable = React.createClass({
handleMoved: React.autoBind(function(direction) {
this.props.onStoryMoved(direction);
}),
+ handleSelected: React.autoBind(function(storyId) {
+ this.props.onStorySelected(storyId);
+ }),
render: function() {
var storyNodes = this.props.data.map(function (story) {
- return ;
+ return ;
}.bind(this));
return (
@@ -274,11 +267,24 @@ var StoryPage = React.createClass({
alert("error: " + errorThrown);
}.bind(this));
}),
+ handleStorySelected: React.autoBind(function (storyId) {
+ $.get('/stories/' + storyId)
+ .done(function (data, textStatus, jqXHR) {
+ this.refs.data.setData(data);
+ }.bind(this), 'json');
+ }),
render: function() {
return (
-
-
-
+
);
}
--
cgit v1.2.3-54-g00ecf