aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2013-07-24 19:56:52 +0200
committerGravatar Tom Willemse2013-07-24 19:56:52 +0200
commitc67240467588bed6dd182416cff1618d8e169c1b (patch)
tree90f587e55b2cb797d757b024e89aeaf758bd5a7e
parent97c5a1af86cc3e44a2d15b50fd982b204c34d604 (diff)
downloadscrumli-c67240467588bed6dd182416cff1618d8e169c1b.tar.gz
scrumli-c67240467588bed6dd182416cff1618d8e169c1b.zip
Add assignment for stories
-rw-r--r--defmodule.lisp5
-rw-r--r--pg-datastore.lisp6
-rw-r--r--scrumli.lisp9
-rw-r--r--static/js/main.js12
4 files changed, 30 insertions, 2 deletions
diff --git a/defmodule.lisp b/defmodule.lisp
index 5a580ad..3ca601a 100644
--- a/defmodule.lisp
+++ b/defmodule.lisp
@@ -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)
diff --git a/pg-datastore.lisp b/pg-datastore.lisp
index 7c25c33..317eca5 100644
--- a/pg-datastore.lisp
+++ b/pg-datastore.lisp
@@ -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)))))
diff --git a/scrumli.lisp b/scrumli.lisp
index 7c94dcf..362f4a5 100644
--- a/scrumli.lisp
+++ b/scrumli.lisp
@@ -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))
diff --git a/static/js/main.js b/static/js/main.js
index ed895ed..444f06a 100644
--- a/static/js/main.js
+++ b/static/js/main.js
@@ -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>