Allow creating epics without milestones

The same as how we allow creating stories without epics, add a "No
Milestone" list item to the top of the list of milestones to select from
when creating an epic.
This commit is contained in:
Griffin Smith 2020-03-31 15:34:45 -04:00
parent 12313582b8
commit 188af3a0d3

View file

@ -553,9 +553,10 @@ If set to nil, will never create stories with labels")
(funcall cb epic-id))))) (funcall cb epic-id)))))
(defun org-clubhouse-prompt-for-milestone (cb) (defun org-clubhouse-prompt-for-milestone (cb)
"Prompt the user for a milestone using ivy and call CB with its ID."
(ivy-read (ivy-read
"Select a milestone: " "Select a milestone: "
(-map #'cdr (org-clubhouse-milestones)) (-map #'cdr (append '((nil . "No Milestone")) (org-clubhouse-milestones)))
:require-match t :require-match t
:history 'org-clubhouse-milestone-history :history 'org-clubhouse-milestone-history
:action (lambda (selected) :action (lambda (selected)
@ -593,7 +594,8 @@ If set to nil, will never create stories with labels")
(cl-defun org-clubhouse-create-epic-internal (cl-defun org-clubhouse-create-epic-internal
(title &key milestone-id) (title &key milestone-id)
(cl-assert (and (stringp title) (cl-assert (and (stringp title)
(integerp milestone-id))) (or (null milestone-id)
(integerp milestone-id))))
(org-clubhouse-request (org-clubhouse-request
"POST" "POST"
"epics" "epics"
@ -606,7 +608,6 @@ If set to nil, will never create stories with labels")
(let ((elt-start (plist-get elt :begin)) (let ((elt-start (plist-get elt :begin))
(epic-id (alist-get 'id epic)) (epic-id (alist-get 'id epic))
(milestone-id (alist-get 'milestone_id epic))) (milestone-id (alist-get 'milestone_id epic)))
(save-excursion (save-excursion
(goto-char elt-start) (goto-char elt-start)
@ -615,10 +616,11 @@ If set to nil, will never create stories with labels")
(org-clubhouse-link-to-epic epic-id) (org-clubhouse-link-to-epic epic-id)
(number-to-string epic-id))) (number-to-string epic-id)))
(org-set-property "clubhouse-milestone" (when milestone-id
(org-link-make-string (org-set-property "clubhouse-milestone"
(org-clubhouse-link-to-milestone milestone-id) (org-link-make-string
(alist-get milestone-id (org-clubhouse-milestones))))))) (org-clubhouse-link-to-milestone milestone-id)
(alist-get milestone-id (org-clubhouse-milestones))))))))
(defun org-clubhouse-create-epic (&optional beg end) (defun org-clubhouse-create-epic (&optional beg end)
"Creates a clubhouse epic using selected headlines. "Creates a clubhouse epic using selected headlines.
@ -635,14 +637,13 @@ If the epics already have a CLUBHOUSE-EPIC-ID, they are filtered and ignored."
(elts (-remove (lambda (elt) (plist-get elt :CLUBHOUSE-EPIC-ID)) elts))) (elts (-remove (lambda (elt) (plist-get elt :CLUBHOUSE-EPIC-ID)) elts)))
(org-clubhouse-prompt-for-milestone (org-clubhouse-prompt-for-milestone
(lambda (milestone-id) (lambda (milestone-id)
(when milestone-id (dolist (elt elts)
(dolist (elt elts) (let* ((title (plist-get elt :title))
(let* ((title (plist-get elt :title)) (epic (org-clubhouse-create-epic-internal
(epic (org-clubhouse-create-epic-internal title
title :milestone-id milestone-id)))
:milestone-id milestone-id))) (org-clubhouse-populate-created-epic elt epic))
(org-clubhouse-populate-created-epic elt epic)) elts)))))
elts))))))
;;; ;;;
;;; Story creation ;;; Story creation