about summary refs log tree commit diff
path: root/org-clubhouse.el
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2020-03-31T19·34-0400
committerGriffin Smith <root@gws.fyi>2020-03-31T19·34-0400
commit188af3a0d3b661a12e3b854253d112e9f9044714 (patch)
tree30be5edeb1cc2e5452609810c22eaffbdb8e627c /org-clubhouse.el
parent12313582b8ddcc8ff59ea4d610e99c6c1b423eee (diff)
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.
Diffstat (limited to 'org-clubhouse.el')
-rw-r--r--org-clubhouse.el31
1 files changed, 16 insertions, 15 deletions
diff --git a/org-clubhouse.el b/org-clubhouse.el
index d0f2b2c4c13b..1894f344ef42 100644
--- a/org-clubhouse.el
+++ b/org-clubhouse.el
@@ -553,9 +553,10 @@ If set to nil, will never create stories with labels")
                (funcall cb epic-id)))))
 
 (defun org-clubhouse-prompt-for-milestone (cb)
+  "Prompt the user for a milestone using ivy and call CB with its ID."
   (ivy-read
    "Select a milestone: "
-   (-map #'cdr (org-clubhouse-milestones))
+   (-map #'cdr (append '((nil . "No Milestone")) (org-clubhouse-milestones)))
    :require-match t
    :history 'org-clubhouse-milestone-history
    :action (lambda (selected)
@@ -593,7 +594,8 @@ If set to nil, will never create stories with labels")
 (cl-defun org-clubhouse-create-epic-internal
     (title &key milestone-id)
   (cl-assert (and (stringp title)
-               (integerp milestone-id)))
+                  (or (null milestone-id)
+                      (integerp milestone-id))))
   (org-clubhouse-request
    "POST"
    "epics"
@@ -606,7 +608,6 @@ If set to nil, will never create stories with labels")
   (let ((elt-start  (plist-get elt :begin))
         (epic-id    (alist-get 'id epic))
         (milestone-id (alist-get 'milestone_id epic)))
-
     (save-excursion
       (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)
                          (number-to-string epic-id)))
 
-      (org-set-property "clubhouse-milestone"
-                        (org-link-make-string
-                         (org-clubhouse-link-to-milestone milestone-id)
-                         (alist-get milestone-id (org-clubhouse-milestones)))))))
+      (when milestone-id
+        (org-set-property "clubhouse-milestone"
+                          (org-link-make-string
+                           (org-clubhouse-link-to-milestone milestone-id)
+                           (alist-get milestone-id (org-clubhouse-milestones))))))))
 
 (defun org-clubhouse-create-epic (&optional beg end)
   "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)))
     (org-clubhouse-prompt-for-milestone
      (lambda (milestone-id)
-       (when milestone-id
-         (dolist (elt elts)
-           (let* ((title (plist-get elt :title))
-                  (epic  (org-clubhouse-create-epic-internal
-                          title
-                          :milestone-id milestone-id)))
-             (org-clubhouse-populate-created-epic elt epic))
-               elts))))))
+       (dolist (elt elts)
+         (let* ((title (plist-get elt :title))
+                (epic  (org-clubhouse-create-epic-internal
+                        title
+                        :milestone-id milestone-id)))
+           (org-clubhouse-populate-created-epic elt epic))
+         elts)))))
 
 ;;;
 ;;; Story creation