feat: support setting story type on creation
Adds an interactive menu for selecting story type on story creation.
This commit is contained in:
parent
08340c223a
commit
bb97402cbe
1 changed files with 36 additions and 10 deletions
|
@ -68,6 +68,11 @@ If unset all projects will be synchronized")
|
||||||
("[X]" . "Merged")
|
("[X]" . "Merged")
|
||||||
("CLOSED" . "Merged")))
|
("CLOSED" . "Merged")))
|
||||||
|
|
||||||
|
(defvar org-clubhouse-story-types
|
||||||
|
'(("feature" . "Feature")
|
||||||
|
("bug" . "Bug")
|
||||||
|
("chore" . "Chore")))
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
;;; Utilities
|
;;; Utilities
|
||||||
;;;
|
;;;
|
||||||
|
@ -404,6 +409,19 @@ If unset all projects will be synchronized")
|
||||||
(message "%d" milestone-id)
|
(message "%d" milestone-id)
|
||||||
(funcall cb milestone-id)))))
|
(funcall cb milestone-id)))))
|
||||||
|
|
||||||
|
(defun org-clubhouse-prompt-for-story-type (cb)
|
||||||
|
(ivy-read
|
||||||
|
"Select a story type: "
|
||||||
|
(-map #'cdr org-clubhouse-story-types)
|
||||||
|
:history 'org-clubhouse-story-history
|
||||||
|
:action (lambda (selected)
|
||||||
|
(let ((story-type
|
||||||
|
(->> org-clubhouse-story-types
|
||||||
|
(-find (lambda (proj)
|
||||||
|
(string-equal (cdr proj) selected)))
|
||||||
|
car)))
|
||||||
|
(funcall cb story-type)))))
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
;;; Epic creation
|
;;; Epic creation
|
||||||
;;;
|
;;;
|
||||||
|
@ -467,7 +485,7 @@ If the epics already have a CLUBHOUSE-EPIC-ID, they are filtered and ignored."
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
(cl-defun org-clubhouse-create-story-internal
|
(cl-defun org-clubhouse-create-story-internal
|
||||||
(title &key project-id epic-id)
|
(title &key project-id epic-id story-type)
|
||||||
(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))))
|
||||||
|
@ -478,13 +496,15 @@ If the epics already have a CLUBHOUSE-EPIC-ID, they are filtered and ignored."
|
||||||
(json-encode
|
(json-encode
|
||||||
`((name . ,title)
|
`((name . ,title)
|
||||||
(project_id . ,project-id)
|
(project_id . ,project-id)
|
||||||
(epic_id . ,epic-id)))))
|
(epic_id . ,epic-id)
|
||||||
|
(story_type . ,story-type)))))
|
||||||
|
|
||||||
(defun org-clubhouse-populate-created-story (elt story)
|
(defun org-clubhouse-populate-created-story (elt story)
|
||||||
(let ((elt-start (plist-get elt :begin))
|
(let ((elt-start (plist-get elt :begin))
|
||||||
(story-id (alist-get 'id story))
|
(story-id (alist-get 'id story))
|
||||||
(epic-id (alist-get 'epic_id story))
|
(epic-id (alist-get 'epic_id story))
|
||||||
(project-id (alist-get 'project_id story)))
|
(project-id (alist-get 'project_id story))
|
||||||
|
(story-type (alist-get 'story_type story)))
|
||||||
|
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char elt-start)
|
(goto-char elt-start)
|
||||||
|
@ -504,6 +524,9 @@ If the epics already have a CLUBHOUSE-EPIC-ID, they are filtered and ignored."
|
||||||
(org-clubhouse-link-to-project project-id)
|
(org-clubhouse-link-to-project project-id)
|
||||||
(alist-get project-id (org-clubhouse-projects))))
|
(alist-get project-id (org-clubhouse-projects))))
|
||||||
|
|
||||||
|
(org-set-property "story-type"
|
||||||
|
(alist-get-equal story-type org-clubhouse-story-types))
|
||||||
|
|
||||||
(org-todo "TODO"))))
|
(org-todo "TODO"))))
|
||||||
|
|
||||||
(defun org-clubhouse-create-story (&optional beg end)
|
(defun org-clubhouse-create-story (&optional beg end)
|
||||||
|
@ -525,13 +548,16 @@ If the stories already have a CLUBHOUSE-ID, they are filtered and ignored."
|
||||||
(when project-id
|
(when project-id
|
||||||
(org-clubhouse-prompt-for-epic
|
(org-clubhouse-prompt-for-epic
|
||||||
(lambda (epic-id)
|
(lambda (epic-id)
|
||||||
(-map (lambda (elt)
|
(org-clubhouse-prompt-for-story-type
|
||||||
(let* ((title (plist-get elt :title))
|
(lambda (story-type)
|
||||||
(story (org-clubhouse-create-story-internal
|
(-map (lambda (elt)
|
||||||
title
|
(let* ((title (plist-get elt :title))
|
||||||
:project-id project-id
|
(story (org-clubhouse-create-story-internal
|
||||||
:epic-id epic-id)))
|
title
|
||||||
(org-clubhouse-populate-created-story elt story))) new-elts))))))))
|
:project-id project-id
|
||||||
|
:epic-id epic-id
|
||||||
|
:story-type story-type)))
|
||||||
|
(org-clubhouse-populate-created-story elt story))) new-elts))))))))))
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
;;; Story updates
|
;;; Story updates
|
||||||
|
|
Loading…
Reference in a new issue