Respond to some more POSTs
This commit is contained in:
parent
aece802c32
commit
a322d9802c
2 changed files with 43 additions and 30 deletions
34
scrumli.lisp
34
scrumli.lisp
|
@ -115,32 +115,38 @@
|
|||
200)
|
||||
403))
|
||||
|
||||
(define-route stories-state ("stories/state" :method :post)
|
||||
(define-route stories-state ("stories/state" :method :post
|
||||
:content-type "text/json")
|
||||
(if (logged-in-p)
|
||||
(let* ((id (hunchentoot:post-parameter "id"))
|
||||
(current-state (story-get-state 'story id)))
|
||||
(story-set-state 'story id (ecase (intern current-state :scrumli)
|
||||
(todo "DOING")
|
||||
(doing "DONE")
|
||||
(done "TODO")))
|
||||
200)
|
||||
(current-state (story-get-state 'story id))
|
||||
(next (ecase (intern current-state :scrumli)
|
||||
(todo "DOING")
|
||||
(doing "DONE")
|
||||
(done "TODO"))))
|
||||
(story-set-state 'story id next)
|
||||
(encode-json-to-string `((status . "ok") (state . ,next))))
|
||||
403))
|
||||
|
||||
(define-route task-state ("tasks/state" :method :post)
|
||||
(if (logged-in-p)
|
||||
(let* ((id (hunchentoot:post-parameter "id"))
|
||||
(current-state (story-get-state 'task id)))
|
||||
(story-set-state 'task id (ecase (intern current-state :scrumli)
|
||||
(todo "DOING")
|
||||
(doing "DONE")
|
||||
(done "TODO"))))))
|
||||
(current-state (story-get-state 'task id))
|
||||
(next (ecase (intern current-state :scrumli)
|
||||
(todo "DOING")
|
||||
(doing "DONE")
|
||||
(done "TODO"))))
|
||||
(story-set-state 'task id next)
|
||||
(encode-json-to-string `((status . "ok") (state . ,next))))
|
||||
403))
|
||||
|
||||
(define-route stories-priority ("stories/:dir" :method :post)
|
||||
(define-route stories-priority ("stories/:dir" :method :post
|
||||
:content-type "text/json")
|
||||
(if (logged-in-p)
|
||||
(let* ((id (hunchentoot:post-parameter "id")))
|
||||
(story-change-priority
|
||||
'story id (intern (string-upcase dir) :keyword))
|
||||
200)
|
||||
(encode-json-to-string '((status . "ok"))))
|
||||
403))
|
||||
|
||||
(define-route task-priority ("tasks/:dir" :method :post)
|
||||
|
|
|
@ -15,9 +15,16 @@ var StoryTaskRow = React.createClass({
|
|||
type: "POST",
|
||||
data: {'id': this.props.task.id},
|
||||
dataType: 'json',
|
||||
mimeType: 'textPlain'
|
||||
mimeType: 'textPlain',
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
if (data.status == "ok")
|
||||
this.setState({state: data.state});
|
||||
}.bind(this)
|
||||
});
|
||||
}),
|
||||
getInitialState: function () {
|
||||
return {state: this.props.task.state};
|
||||
},
|
||||
moveUp: React.autoBind(function(event) {
|
||||
$.ajax({
|
||||
url: "tasks/up",
|
||||
|
@ -37,8 +44,6 @@ var StoryTaskRow = React.createClass({
|
|||
});
|
||||
}),
|
||||
render: function() {
|
||||
var state = " " + this.props.task.state;
|
||||
|
||||
return (
|
||||
<tr>
|
||||
<td class="span1">
|
||||
|
@ -47,8 +52,8 @@ var StoryTaskRow = React.createClass({
|
|||
</td>
|
||||
<td class="span2">
|
||||
<span onClick={this.changeState}>
|
||||
<StateIcon state={this.props.task.state} />
|
||||
{state}
|
||||
<StateIcon state={this.state.state} /> {" "}
|
||||
{this.state.state}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
|
@ -134,9 +139,6 @@ var StoryData = React.createClass({
|
|||
|
||||
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.state.state;
|
||||
var sdata = null;
|
||||
|
||||
if (this.state.content)
|
||||
|
@ -150,8 +152,8 @@ var StoryRow = React.createClass({
|
|||
</td>
|
||||
<td class="span2">
|
||||
<span onClick={this.changeState}>
|
||||
<StateIcon state={this.state.state} />
|
||||
{state}
|
||||
<StateIcon state={this.state.state} /> {" "}
|
||||
{this.state.state}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
|
@ -189,8 +191,9 @@ var StoryRow = React.createClass({
|
|||
data: {'id': this.props.story.id},
|
||||
dataType: 'json',
|
||||
mimeType: 'textPlain',
|
||||
success: function(data) {
|
||||
this.setState({state: eval(data).state});
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
if (data.status == "ok")
|
||||
this.setState({state: data.state});
|
||||
}.bind(this)
|
||||
});
|
||||
}),
|
||||
|
@ -201,8 +204,9 @@ var StoryRow = React.createClass({
|
|||
data: {'id': this.props.story.id},
|
||||
dataType: 'json',
|
||||
mimeType: 'textPlain',
|
||||
success: function (data) {
|
||||
this.props.onMoved(1);
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
if (data.status == "ok")
|
||||
this.props.onMoved(1);
|
||||
}.bind(this)
|
||||
});
|
||||
}),
|
||||
|
@ -222,7 +226,7 @@ var StoryRow = React.createClass({
|
|||
|
||||
var StoryTable = React.createClass({
|
||||
handleMoved: React.autoBind(function(direction) {
|
||||
this.loadStoriesFromServer();
|
||||
this.props.onStoryMoved(direction);
|
||||
}),
|
||||
render: function() {
|
||||
var storyNodes = this.props.data.map(function (story) {
|
||||
|
@ -302,6 +306,9 @@ var StoryPage = React.createClass({
|
|||
this.props.pollInterval
|
||||
);
|
||||
},
|
||||
handleStoryMoved: React.autoBind(function (direction) {
|
||||
this.loadStoriesFromServer();
|
||||
}),
|
||||
handleStorySubmit: React.autoBind(function (story) {
|
||||
$.ajax({
|
||||
url: "/stories/new",
|
||||
|
@ -321,7 +328,7 @@ var StoryPage = React.createClass({
|
|||
render: function() {
|
||||
return (
|
||||
<div>
|
||||
<StoryTable data={this.state.data} />
|
||||
<StoryTable data={this.state.data} onStoryMoved={this.handleStoryMoved} />
|
||||
<StoryForm onStorySubmit={this.handleStorySubmit} />
|
||||
</div>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue