diff --git a/scrumli.lisp b/scrumli.lisp index 778b1aa..8ab60f7 100644 --- a/scrumli.lisp +++ b/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) diff --git a/static/js/main.js b/static/js/main.js index 255e537..a2d8754 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -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 (