Show assigned gravatar in story and task lists

This commit is contained in:
Tom Willemse 2013-07-24 20:42:13 +02:00
parent c672404675
commit 4b9563abd4
2 changed files with 33 additions and 3 deletions

View file

@ -57,16 +57,19 @@
(defmethod datastore-get-all-stories ((datastore pg-datastore)) (defmethod datastore-get-all-stories ((datastore pg-datastore))
(with-connection (connection-spec datastore) (with-connection (connection-spec datastore)
(query (:order-by (:select :* :from 'story) 'priority) :alists))) (query (:order-by (:select :* (:as (:md5 'assignee) 'md5)
:from 'story) 'priority) :alists)))
(defmethod datastore-get-story ((datastore pg-datastore) id) (defmethod datastore-get-story ((datastore pg-datastore) id)
(with-connection (connection-spec datastore) (with-connection (connection-spec datastore)
(append (query (:select :* :from 'story :where (:= 'id id)) :alist) (append (query (:select :* (:as (:md5 'assignee) 'md5) :from 'story
:where (:= 'id id)) :alist)
`((tasks . ,(datastore-get-tasks-for-story datastore id)))))) `((tasks . ,(datastore-get-tasks-for-story datastore id))))))
(defmethod datastore-get-tasks-for-story ((datastore pg-datastore) id) (defmethod datastore-get-tasks-for-story ((datastore pg-datastore) id)
(with-connection (connection-spec datastore) (with-connection (connection-spec datastore)
(query (:order-by (:select :* :from 'task :where (:= 'story-id id)) (query (:order-by (:select :* (:as (:md5 'assignee) 'md5) :from 'task
:where (:= 'story-id id))
'priority) 'priority)
:alists))) :alists)))

View file

@ -24,6 +24,25 @@ var StateIcon = React.createClass({
} }
}); });
var AssigneeIcon = React.createClass({
render: function() {
var icon;
if (this.props.assignee)
icon = <img src={"https://secure.gravatar.com/avatar/" +
this.props.md5 + '?s=24'}
title={this.props.assignee}
alt={this.props.assignee} />;
else
icon = (<span title="Unknown" class="icon-stack">
<i class="icon-sign-blank icon-stack-base"></i>
<i class="icon-question icon-light"></i>
</span>);
return icon;
}
});
var StoryTaskRow = React.createClass({ var StoryTaskRow = React.createClass({
changeState: React.autoBind(function(event) { changeState: React.autoBind(function(event) {
$.post("/tasks/state", {'id': this.props.task.id}) $.post("/tasks/state", {'id': this.props.task.id})
@ -58,6 +77,10 @@ var StoryTaskRow = React.createClass({
<i class="icon-arrow-down clickable" <i class="icon-arrow-down clickable"
onClick={this.moveDown}></i> onClick={this.moveDown}></i>
</td> </td>
<td class="span1">
<AssigneeIcon assignee={this.props.task.assignee}
md5={this.props.task.md5} />
</td>
<td class="span2"> <td class="span2">
<span onClick={this.changeState} class="clickable"> <span onClick={this.changeState} class="clickable">
<StateIcon state={this.state.state} /> {" "} <StateIcon state={this.state.state} /> {" "}
@ -182,6 +205,10 @@ var StoryRow = React.createClass({
<i class="icon-arrow-down clickable" <i class="icon-arrow-down clickable"
onClick={this.moveDown}></i> onClick={this.moveDown}></i>
</td> </td>
<td class="span1">
<AssigneeIcon assignee={this.props.story.assignee}
md5={this.props.story.md5} />
</td>
<td class="span2"> <td class="span2">
<span onClick={this.changeState} class="clickable"> <span onClick={this.changeState} class="clickable">
<StateIcon state={this.state.state} /> {" "} <StateIcon state={this.state.state} /> {" "}