feat: Update task list item statuses

Add a clause to org-clubhouse-update-status to update task headline
statuses in addition to story statuses
This commit is contained in:
Griffin Smith 2019-02-22 16:29:06 -05:00
parent dfc2335edb
commit f657a4c7fa

View file

@ -197,8 +197,8 @@ not be prompted")
(when (equal 'headline (car current-elt)) (when (equal 'headline (car current-elt))
(cadr current-elt)))) (cadr current-elt))))
(defun org-element-extract-clubhouse-id (elt) (defun org-element-extract-clubhouse-id (elt &optional property)
(when-let* ((clubhouse-id-link (plist-get elt :CLUBHOUSE-ID))) (when-let* ((clubhouse-id-link (plist-get elt (or property :CLUBHOUSE-ID))))
(cond (cond
((string-match ((string-match
(rx "[[" (one-or-more anything) "]" (rx "[[" (one-or-more anything) "]"
@ -740,6 +740,21 @@ allows manually passing a clubhouse ID and list of org-element plists to write"
(org-todo "TODO")))) (org-todo "TODO"))))
;;;
;;; Task Updates
;;;
(cl-defun org-clubhouse-update-task-internal
(story-id task-id &rest attrs)
(cl-assert (and (integerp story-id)
(integerp task-id)
(listp attrs)))
(org-clubhouse-request
"PUT"
(format "stories/%d" story-id)
:data
(json-encode attrs)))
;;; ;;;
;;; Story updates ;;; Story updates
;;; ;;;
@ -777,18 +792,39 @@ Update the status of the Clubhouse story linked to the current element with the
entry in `org-clubhouse-state-alist' corresponding to the todo-keyword of the entry in `org-clubhouse-state-alist' corresponding to the todo-keyword of the
element." element."
(interactive) (interactive)
(when-let* ((clubhouse-id (org-element-clubhouse-id)))
(let* ((elt (org-element-find-headline)) (let* ((elt (org-element-find-headline))
(todo-keyword (-> elt (plist-get :todo-keyword) (substring-no-properties)))) (todo-keyword (-> elt
(plist-get :todo-keyword)
(substring-no-properties)))
(clubhouse-id (org-element-extract-clubhouse-id elt))
(task-id (plist-get elt :CLUBHOUSE-TASK-ID)))
(cond
(clubhouse-id
(let* ((todo-keyword (-> elt
(plist-get :todo-keyword)
(substring-no-properties))))
(when-let* ((clubhouse-workflow-state (when-let* ((clubhouse-workflow-state
(alist-get-equal todo-keyword org-clubhouse-state-alist)) (alist-get-equal todo-keyword org-clubhouse-state-alist))
(workflow-state-id (workflow-state-id
(alist-get-equal clubhouse-workflow-state (org-clubhouse-workflow-states)))) (alist-get-equal clubhouse-workflow-state
(org-clubhouse-workflow-states))))
(org-clubhouse-update-story-internal (org-clubhouse-update-story-internal
clubhouse-id clubhouse-id
:workflow_state_id workflow-state-id) :workflow_state_id workflow-state-id)
(message "Successfully updated clubhouse status to \"%s\"" (message "Successfully updated clubhouse status to \"%s\""
clubhouse-workflow-state))))) clubhouse-workflow-state))))
(task-id
(let ((story-id (org-element-extract-clubhouse-id
elt
:CLUBHOUSE-STORY-ID))
(done? (member todo-keyword org-done-keywords)))
(org-clubhouse-update-task-internal
story-id
(string-to-number task-id)
:done done?)
(message "Successfully marked clubhouse task status as %s"
(if done? "complete" "incomplete")))))))
(defun org-clubhouse-update-description () (defun org-clubhouse-update-description ()
"Update the description of the Clubhouse story linked to the current element. "Update the description of the Clubhouse story linked to the current element.