Skip to content

Commit

Permalink
Merge pull request #358 from djgoku/feature/add-setting-labels-when-c…
Browse files Browse the repository at this point in the history
…reating-an-issue

Feature/add setting labels when creating an issue
  • Loading branch information
ahungry authored Sep 28, 2024
2 parents bd57358 + 96183d1 commit 91f1140
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
17 changes: 16 additions & 1 deletion jiralib.el
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@ request.el, so if at all possible, it should be avoided."
('updateIssue (jiralib--rest-call-it
(format "/rest/api/2/issue/%s" (first params))
:type "PUT"
:data (json-encode `((fields . ,(second params)))))))))
:data (json-encode `((fields . ,(second params))))))
('getLabels (jiralib--rest-call-it (format "/rest/api/2/label?startAt=%s" (first params)))))))

(defun jiralib--soap-call-it (&rest args)
"Deprecated SOAP call endpoint. Will be removed soon.
Expand Down Expand Up @@ -1202,6 +1203,20 @@ Auxiliary Notes:
(apply 'jiralib-call "getIssuesFromBoard"
(cl-getf params :callback) board-id params))

(defvar jiralib-labels-cache nil)
(defun jiralib-get-labels ()
"Return assignable labels that can be added to an issue."
(unless jiralib-labels-cache
(setq jiralib-labels-start-at 0)
(while (progn
(let* ((labels (jiralib-call "getLabels" nil jiralib-labels-start-at))
(max-results (alist-get 'maxResults labels))
(is-last (alist-get 'isLast labels))
(values (alist-get 'values labels)))
(setq jiralib-labels-start-at (+ max-results jiralib-labels-start-at)
jiralib-labels-cache (append values jiralib-labels-cache))
(not (eq is-last t)))))))

(defun jiralib--agile-not-last-entry (num-entries total start-at limit)
"Return true if need to retrieve next page from agile api"
(and (> num-entries 0)
Expand Down
9 changes: 9 additions & 0 deletions org-jira.el
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,7 @@ that should be bound to an issue."
(jira-users (org-jira-get-assignable-users project))
(user (completing-read "Assignee: " (mapcar 'car jira-users)))
(priority (car (rassoc (org-jira-read-priority) (jiralib-get-priorities))))
(labels (org-jira-read-labels))
(ticket-struct
`((fields
(project (key . ,project))
Expand All @@ -1815,6 +1816,7 @@ that should be bound to an issue."
"")))
(description . ,description)
(priority (id . ,priority))
(labels . ,labels)
;; accountId should be nil if Unassigned, not the key slot.
(assignee (accountId . ,(or (cdr (assoc user jira-users)) nil)))))))
ticket-struct))
Expand Down Expand Up @@ -1921,6 +1923,13 @@ that should be bound to an issue."
(car (rassoc action actions))
(user-error "You specified an empty action, the valid actions are: %s" (mapcar 'cdr actions)))))

(defun org-jira-read-labels ()
"Pick multiple labels to add to your jira issue."
(if jiralib-labels-cache
(completing-read-multiple "Labels: " jiralib-labels-cache)
(jiralib-get-labels)
(completing-read-multiple "Labels: " jiralib-labels-cache)))

(defvar org-jira-fields-history nil)
(defun org-jira-read-field (fields)
"Read (custom) FIELDS for workflow progress."
Expand Down

0 comments on commit 91f1140

Please sign in to comment.