From c67240467588bed6dd182416cff1618d8e169c1b Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 24 Jul 2013 19:56:52 +0200 Subject: Add assignment for stories --- defmodule.lisp | 5 ++++- pg-datastore.lisp | 6 ++++++ scrumli.lisp | 9 +++++++++ static/js/main.js | 12 +++++++++++- 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 (

{this.state.data.title}

- Assignee: {this.state.data.assignee} + Assignee: +
{this.state.data.content}
-- cgit v1.2.3-54-g00ecf