Add changing order of stories
This commit is contained in:
parent
e529f38b59
commit
5885f98eab
2 changed files with 54 additions and 4 deletions
35
js/main.js
35
js/main.js
|
@ -33,6 +33,10 @@ var StoryRow = React.createClass({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
|
<td>
|
||||||
|
<i class="icon-arrow-up" onClick={this.moveUp}></i>
|
||||||
|
<i class="icon-arrow-down" onClick={this.moveDown}></i>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span onClick={this.changeState}>
|
<span onClick={this.changeState}>
|
||||||
<StateIcon state={this.state.state} />
|
<StateIcon state={this.state.state} />
|
||||||
|
@ -78,6 +82,30 @@ var StoryRow = React.createClass({
|
||||||
this.setState({state: eval(data).state});
|
this.setState({state: eval(data).state});
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
});
|
});
|
||||||
|
}),
|
||||||
|
moveUp: React.autoBind(function(event) {
|
||||||
|
$.ajax({
|
||||||
|
url: "/stories/up/",
|
||||||
|
type: "POST",
|
||||||
|
data: {'id': this.props.story.id},
|
||||||
|
dataType: 'json',
|
||||||
|
mimeType: 'textPlain',
|
||||||
|
success: function (data) {
|
||||||
|
this.props.onMoved(1);
|
||||||
|
}.bind(this)
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
moveDown: React.autoBind(function(event) {
|
||||||
|
$.ajax({
|
||||||
|
url: "/stories/down/",
|
||||||
|
type: "POST",
|
||||||
|
data: {'id': this.props.story.id},
|
||||||
|
dataType: 'json',
|
||||||
|
mimeType: 'textPlain',
|
||||||
|
success: function (data) {
|
||||||
|
this.props.onMoved(-1);
|
||||||
|
}.bind(this)
|
||||||
|
});
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -101,10 +129,13 @@ var StoryTable = React.createClass({
|
||||||
this.props.pollInterval
|
this.props.pollInterval
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
handleMoved: React.autoBind(function(direction) {
|
||||||
|
this.loadStoriesFromServer();
|
||||||
|
}),
|
||||||
render: function() {
|
render: function() {
|
||||||
var storyNodes = this.state.data.map(function (story) {
|
var storyNodes = this.state.data.map(function (story) {
|
||||||
return <StoryRow story={story} />;
|
return <StoryRow story={story} onMoved={this.handleMoved} />;
|
||||||
});
|
}.bind(this));
|
||||||
return (
|
return (
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
{storyNodes}
|
{storyNodes}
|
||||||
|
|
23
scrumelo.el
23
scrumelo.el
|
@ -120,13 +120,30 @@
|
||||||
(elnode-method httpcon
|
(elnode-method httpcon
|
||||||
(POST
|
(POST
|
||||||
(with-scrumelo-http-params (id) httpcon
|
(with-scrumelo-http-params (id) httpcon
|
||||||
(message "HI: %s" id)
|
|
||||||
(with-scrumelo-buffer
|
(with-scrumelo-buffer
|
||||||
(let ((entry (cdr (org-id-find id))))
|
(let ((entry (cdr (org-id-find id))))
|
||||||
(goto-char entry)
|
(goto-char entry)
|
||||||
(org-todo)
|
(org-todo)
|
||||||
|
(save-buffer)
|
||||||
(scrumelo--send-json
|
(scrumelo--send-json
|
||||||
httpcon (list (cons :state (org-entry-get (point) "TODO"))))))))))
|
httpcon
|
||||||
|
(list (cons :state (org-entry-get (point) "TODO"))))))))))
|
||||||
|
|
||||||
|
(defun scrumelo-move-story (dir)
|
||||||
|
"Create a function to move a story in direction DIR."
|
||||||
|
(let ((func (intern (concat "org-move-subtree-" dir))))
|
||||||
|
(lambda (httpcon)
|
||||||
|
(elnode-method httpcon
|
||||||
|
(POST
|
||||||
|
(with-scrumelo-http-params (id) httpcon
|
||||||
|
(with-scrumelo-buffer
|
||||||
|
(let ((entry (cdr (org-id-find id))))
|
||||||
|
(goto-char entry)
|
||||||
|
(funcall func)
|
||||||
|
(save-buffer)
|
||||||
|
(scrumelo--send-json
|
||||||
|
httpcon
|
||||||
|
(list (cons :status "OK")))))))))))
|
||||||
|
|
||||||
(defun scrumelo--send-json (httpcon obj)
|
(defun scrumelo--send-json (httpcon obj)
|
||||||
"Respond to HTTPCON with OBJ converted to a json structure."
|
"Respond to HTTPCON with OBJ converted to a json structure."
|
||||||
|
@ -175,6 +192,8 @@
|
||||||
("^/stories/$" . scrumelo-main-json)
|
("^/stories/$" . scrumelo-main-json)
|
||||||
("^/stories/new/$" . scrumelo-new-story)
|
("^/stories/new/$" . scrumelo-new-story)
|
||||||
("^/stories/state/$" . scrumelo-change-state)
|
("^/stories/state/$" . scrumelo-change-state)
|
||||||
|
("^/stories/up/$" . ,(scrumelo-move-story "up"))
|
||||||
|
("^/stories/down/$" . ,(scrumelo-move-story "down"))
|
||||||
("^/stories/\\([a-z0-9:-]+\\)/$" . scrumelo-story-json))))
|
("^/stories/\\([a-z0-9:-]+\\)/$" . scrumelo-story-json))))
|
||||||
|
|
||||||
(elnode-start 'scrumelo-handler :port 8028 :host "0.0.0.0")
|
(elnode-start 'scrumelo-handler :port 8028 :host "0.0.0.0")
|
||||||
|
|
Loading…
Reference in a new issue