Add assignment for stories

This commit is contained in:
Tom Willemse 2013-07-24 19:56:52 +02:00
parent 97c5a1af86
commit c672404675
4 changed files with 30 additions and 2 deletions

View file

@ -44,7 +44,10 @@
"Set the state of a story.")
(define-method story-change-priority (type id dir)
"Change the priority of a story in direction DIR."))
"Change the priority of a story in direction DIR.")
(define-method set-assignee (type id assignee)
"Change the assigned person for a story or task."))
(restas:define-module #:scrumli
(:use #:cl #:restas #:json #:scrumli.datastore #:drakma)

View file

@ -118,3 +118,9 @@
(execute (:update type :set
'priority (max 1 (min next-priority max-priority))
:where (:= 'id id))))))
(defmethod datastore-set-assignee
((datastore pg-datastore) type id assignee)
(with-connection (connection-spec datastore)
(execute (:update type :set 'assignee assignee
:where (:= 'id id)))))

View file

@ -212,3 +212,12 @@
(if (logged-in-p)
(encode-json-to-string (get-story id))
403))
(define-route scrumli-story-set-assignee ("story/assignee"
:content-type "json"
:method :post)
(if (logged-in-p)
(with-post-parameters ("id" "assignee")
(set-assignee 'story id assignee)
(encode-json-to-string '((status . "ok"))))
403))

View file

@ -144,11 +144,21 @@ var StoryData = React.createClass({
handleTaskMoved: React.autoBind(function(direction) {
this.loadStoryFromServer();
}),
handleAssigned: React.autoBind(function(event) {
$.post("/story/assignee", {id: this.state.data.id,
assignee: event.target.value})
.fail(function() {
event.target.value = "";
}.bind(this));
}),
render: function() {
if (this.state.data) {
return (<div>
<h1>{this.state.data.title}</h1>
Assignee: {this.state.data.assignee}
Assignee:
<input type="text" ref="assignee"
value={this.state.data.assignee}
onChange={this.handleAssigned} />
<div class="well normalText">
{this.state.data.content}
</div>