From e529f38b59cdf6fa7155de754ec9857f2b5e2dc6 Mon Sep 17 00:00:00 2001
From: Tom Willemse
Date: Thu, 20 Jun 2013 21:04:44 +0200
Subject: Add changing of state
By clicking on a story's state you change that story's state to the next
possible state.
---
js/main.js | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
(limited to 'js')
diff --git a/js/main.js b/js/main.js
index a600ccf..4b84401 100644
--- a/js/main.js
+++ b/js/main.js
@@ -25,7 +25,7 @@ var StoryRow = React.createClass({
render: function() {
// A little ugly to get a space, but I don't know of any other
// way.
- var state = " " + this.props.story.state;
+ var state = " " + this.state.state;
var sdata = null;
if (this.state.content)
@@ -34,11 +34,13 @@ var StoryRow = React.createClass({
return (
|
-
- {state}
+
+
+ {state}
+
|
-
+
As a {this.props.story.role}, I
{this.props.story.necessity} to
{this.props.story.title}
@@ -50,7 +52,8 @@ var StoryRow = React.createClass({
);
},
getInitialState: function() {
- return {content: null};
+ return {state: this.props.story.state,
+ content: null};
},
handleClick: React.autoBind(function(event) {
if (!!this.state.content) {
@@ -63,6 +66,18 @@ var StoryRow = React.createClass({
function (data, textStatus, jqXHR) {
self.setState({content: data});
}, 'json');
+ }),
+ changeState: React.autoBind(function(event) {
+ $.ajax({
+ url: "/stories/state/",
+ type: "POST",
+ data: {'id': this.props.story.id},
+ dataType: 'json',
+ mimeType: 'textPlain',
+ success: function(data) {
+ this.setState({state: eval(data).state});
+ }.bind(this)
+ });
})
});
--
cgit v1.3-2-g0d8e
|