Get data on a story from the server
Uses a GET request to get extra data about a story, if that story already exists it removes it so users can hide/show as much as they like.
This commit is contained in:
parent
77eebc0361
commit
2a9822daac
2 changed files with 38 additions and 1 deletions
|
@ -6,3 +6,19 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
||||||
|
function get_story_info(element) {
|
||||||
|
var id = element.id;
|
||||||
|
var data_element = $(element).parent().find(".data");
|
||||||
|
|
||||||
|
if (data_element.length > 0)
|
||||||
|
data_element.remove();
|
||||||
|
else
|
||||||
|
$.get('/stories/' + id, null,
|
||||||
|
function (data, textStatus, jqXHR) {
|
||||||
|
$(element).after("<div class=\"data\">" +
|
||||||
|
"Assignee: " + data.Assignee +
|
||||||
|
"<pre>" + data.content + "</pre>" +
|
||||||
|
"</div>");
|
||||||
|
}, 'json');
|
||||||
|
}
|
||||||
|
|
23
scrumelo.el
23
scrumelo.el
|
@ -85,7 +85,9 @@
|
||||||
(let ((state (org-entry-get (point) "TODO")))
|
(let ((state (org-entry-get (point) "TODO")))
|
||||||
`(tr (td (i (@ (class ,(scrumelo--task-state-class state))) "")
|
`(tr (td (i (@ (class ,(scrumelo--task-state-class state))) "")
|
||||||
" " ,state)
|
" " ,state)
|
||||||
(td ,(scrumelo--story)))))
|
(td (a (@ (id ,(org-id-get))
|
||||||
|
(onclick "return get_story_info(this)"))
|
||||||
|
,(scrumelo--story))))))
|
||||||
|
|
||||||
(defun scrumelo--maybe-story-row ()
|
(defun scrumelo--maybe-story-row ()
|
||||||
"If looking at a top level heading, return a table row for it."
|
"If looking at a top level heading, return a table row for it."
|
||||||
|
@ -156,6 +158,25 @@
|
||||||
(save-buffer))))
|
(save-buffer))))
|
||||||
(elnode-send-redirect httpcon "/"))))
|
(elnode-send-redirect httpcon "/"))))
|
||||||
|
|
||||||
|
(defun scrumelo--send-json (httpcon obj)
|
||||||
|
"Respond to HTTPCON with OBJ converted to a json structure."
|
||||||
|
(elnode-http-start httpcon 200 '("Contaent-Type" . "text/json"))
|
||||||
|
(elnode-http-return httpcon (json-encode obj)))
|
||||||
|
|
||||||
|
(defun scrumelo-story-json (httpcon)
|
||||||
|
"Repsond to HTTPCON with some json info about a story."
|
||||||
|
(let* ((story (match-string 1 (elnode-http-mapping httpcon)))
|
||||||
|
(buffer (find-file-noselect scrumelo-project-file))
|
||||||
|
(entry (cdr (org-id-find story))))
|
||||||
|
(message "HI: %s" story)
|
||||||
|
(with-current-buffer buffer
|
||||||
|
(goto-char entry)
|
||||||
|
(scrumelo--send-json
|
||||||
|
httpcon (list (cons 'Assignee (org-entry-get (point) "Assignee"))
|
||||||
|
(cons 'content (buffer-substring-no-properties
|
||||||
|
(org-end-of-meta-data-and-drawers)
|
||||||
|
(org-entry-end-position))))))))
|
||||||
|
|
||||||
(defun scrumelo-handler (httpcon)
|
(defun scrumelo-handler (httpcon)
|
||||||
"Send the right requests in HTTPCON to the right functions."
|
"Send the right requests in HTTPCON to the right functions."
|
||||||
(elnode-dispatcher
|
(elnode-dispatcher
|
||||||
|
|
Loading…
Reference in a new issue