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