feat: Add org-clubhouse-update-labels

Add a command to update the labels of an existing story from the labels
of an org headline
This commit is contained in:
Griffin Smith 2019-05-02 10:52:07 -04:00
parent f88deb2a33
commit cfcc346593

View file

@ -297,12 +297,13 @@ If set to nil, will never create stories with labels")
"Return the Clubhouse labels based on the tags of ELT and the user's config." "Return the Clubhouse labels based on the tags of ELT and the user's config."
(unless (eq nil org-clubhouse-create-stories-with-labels) (unless (eq nil org-clubhouse-create-stories-with-labels)
(let ((tags (org-get-tags (plist-get elt :contents-begin)))) (let ((tags (org-get-tags (plist-get elt :contents-begin))))
(cl-case org-clubhouse-create-stories-with-labels (-map (lambda (l) `((name . ,l)))
('t tags) (cl-case org-clubhouse-create-stories-with-labels
('existing (-filter (lambda (tag) (-some (lambda (l) ('t tags)
(string-equal tag (cdr l))) ('existing (-filter (lambda (tag) (-some (lambda (l)
(org-clubhouse-labels))) (string-equal tag (cdr l)))
tags)))))) (org-clubhouse-labels)))
tags)))))))
;;; ;;;
;;; API integration ;;; API integration
@ -709,9 +710,7 @@ If the stories already have a CLUBHOUSE-ID, they are filtered and ignored."
(save-mark-and-excursion (save-mark-and-excursion
(goto-char (plist-get elt :begin)) (goto-char (plist-get elt :begin))
(org-clubhouse-find-description-drawer))) (org-clubhouse-find-description-drawer)))
(labels (-map (lambda (l) `((name . ,l))) (labels (org-clubhouse--labels-for-elt elt))
(org-clubhouse--labels-for-elt
elt)))
(story (org-clubhouse-create-story-internal (story (org-clubhouse-create-story-internal
title title
:project-id project-id :project-id project-id
@ -924,6 +923,23 @@ contents of a drawer inside the element called DESCRIPTION, if any."
:description new-description) :description new-description)
(message "Successfully updated story description")))) (message "Successfully updated story description"))))
(defun org-clubhouse-update-labels ()
"Update the labels of the Clubhouse story linked to the current element.
Will use the value of `org-clubhouse-create-stories-with-labels' to determine
which labels to set."
(interactive)
(when-let* ((elt (org-element-find-headline))
(new-labels (org-clubhouse--labels-for-elt elt)))
(and
(org-clubhouse-update-story-at-point
:labels new-labels)
(message "Successfully updated story labels to :%s:"
(->> new-labels
(-map #'cdar)
(s-join ":"))))))
;;; ;;;
;;; Creating headlines from existing stories ;;; Creating headlines from existing stories
;;; ;;;