feat: Populate description when creating stories

If a DESCRIPTION drawer exists on headlines being used to create
stories, it is populated as the description of the created story
This commit is contained in:
Griffin Smith 2019-02-15 16:12:33 -05:00
parent 627799d4dc
commit 3fc1a3445b

View file

@ -239,9 +239,10 @@ not be prompted")
(append elt `(:children ,(reverse children))))) (append elt `(:children ,(reverse children)))))
(defun +org-element-contents (elt) (defun +org-element-contents (elt)
(buffer-substring-no-properties (if-let ((begin (plist-get (cadr elt) :contents-begin))
(plist-get (cadr elt) :contents-begin) (end (plist-get (cadr elt) :contents-end)))
(plist-get (cadr elt) :contents-end))) (buffer-substring-no-properties begin end)
""))
(defun org-clubhouse-find-description-drawer () (defun org-clubhouse-find-description-drawer ()
"Try to find a DESCRIPTION drawer in the current element." "Try to find a DESCRIPTION drawer in the current element."
@ -557,15 +558,17 @@ If the epics already have a CLUBHOUSE-EPIC-ID, they are filtered and ignored."
(alist-get-equal org-clubhouse-default-state (org-clubhouse-workflow-states))) (alist-get-equal org-clubhouse-default-state (org-clubhouse-workflow-states)))
(cl-defun org-clubhouse-create-story-internal (cl-defun org-clubhouse-create-story-internal
(title &key project-id epic-id story-type) (title &key project-id epic-id story-type description)
(assert (and (stringp title) (assert (and (stringp title)
(integerp project-id) (integerp project-id)
(or (null epic-id) (integerp epic-id)))) (or (null epic-id) (integerp epic-id))
(or (null description) (stringp description))))
(let ((workflow-state-id (org-clubhouse-default-state-id)) (let ((workflow-state-id (org-clubhouse-default-state-id))
(params `((name . ,title) (params `((name . ,title)
(project_id . ,project-id) (project_id . ,project-id)
(epic_id . ,epic-id) (epic_id . ,epic-id)
(story_type . ,story-type)))) (story_type . ,story-type)
(description . ,description))))
(when workflow-state-id (when workflow-state-id
(push `(workflow_state_id . ,workflow-state-id) params)) (push `(workflow_state_id . ,workflow-state-id) params))
@ -627,17 +630,22 @@ If the stories already have a CLUBHOUSE-ID, they are filtered and ignored."
(lambda (epic-id) (lambda (epic-id)
(let ((create-story (let ((create-story
(lambda (story-type) (lambda (story-type)
(-map (lambda (elt) (-map
(let* ((title (plist-get elt :title)) (lambda (elt)
(story (org-clubhouse-create-story-internal (let* ((title (plist-get elt :title))
title (story (org-clubhouse-create-story-internal
:project-id project-id title
:epic-id epic-id :project-id project-id
:story-type story-type))) :epic-id epic-id
(org-clubhouse-populate-created-story elt story) :story-type story-type))
(when (functionp then) (description
(funcall then story)))) (save-mark-and-excursion
new-elts)))) (goto-char (plist-get elt :begin))
(org-clubhouse-find-description-drawer))))
(org-clubhouse-populate-created-story elt story)
(when (functionp then)
(funcall then story))))
new-elts))))
(if org-clubhouse-default-story-type (if org-clubhouse-default-story-type
(funcall create-story org-clubhouse-default-story-type) (funcall create-story org-clubhouse-default-story-type)
(org-clubhouse-prompt-for-story-type create-story)))))))))) (org-clubhouse-prompt-for-story-type create-story))))))))))