• About the JavaScript API
  • AP
  • Context
  • Cookie
  • Dialog
  • Events
  • Flag
  • History
  • Inline dialog
  • Jira
  • Navigator
  • Request
  • User

Jira

A JavaScript module which provides functions to interact with Jira.

Methods

refreshIssuePage ()

Refresh an issue page without reloading the browser.

This is helpful when your add-on updates information about an issue in the background.

Example

1
AP.jira.refreshIssuePage();

getWorkflowConfiguration (callback)

Retrieves a workflow configuration object.

Parameters

NameTypeDescription
callbackWorkflowConfiguration

the callback that handles the response.


isDashboardItemEditable (callback)

Returns whether the current user is permitted to edit the dashboard item

Parameters

NameTypeDescription
callbackfunction

the callback that handles the response


openCreateIssueDialog (callback, params)

Open the quick create issue dialog. The dialog fields may be pre-filled with supplied data. A callback will be invoked when the dialog is closed and will include an array of issues created.

Parameters

NameTypeDescription
callbackfunction

invoked when dialog is closed, takes a single parameter - array of issues created

paramsObject

contains data to pre-fill the dialog with

Properties
NameTypeDefaultDescription
pidnumber

Project to pre-fill the dialog with

issueTypenumber

Issue type to pre-fill the dialog with

fieldsObject

Optional data to pre-fill the dialog with, you can find out field key by checking it's html 'name' attribute.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
AP.jira.openCreateIssueDialog(function(issues){
  alert(issues[0]['fields']['summary']);
}, {
  pid: 10000,
  issueType: 1,
  fields : {
    summary: "Hello World",
    environment : "My environment",
    priority : 2,
    assignee: "tom",
    reporter: "bob",
    labels : ["Mylabel","MyOtherLabel"],
    description : "My first Issue",
    duedate : "11/Oct/16",
    fixVersions : 10001,
    versions : 10000,
    components : "My component",
    timetracking_originalestimate: "2w",
    timetracking_remainingestimate: "3d",
    worklog_activate: true,
    worklog_timeLogged: "2"
  }
});

setDashboardItemTitle (title)

Set the title of a dashboard item to the given text.

Parameters

NameTypeDescription
titleString

the title of the dashboard item. Any HTML is escaped.


openDatePicker (options)

Shows a date picker component. A callback will be invoked when the date (and time) is selected by the user.

Parameters

NameTypeDescription
optionsDatePicker~options

Configuration of the date picker.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
var dateField = document.querySelector("#date-field");
var dateTrigger = document.querySelector("#date-trigger");

dateTrigger.addEventListener("click", function(e) {
  e.preventDefault();
  AP.jira.openDatePicker({
    element: dateTrigger,
    date: "2011-12-13T15:20+01:00",
    showTime: true,
    onSelect: function (isoDate, date) {
      dateField.value = date;
      dateField.setAttribute("data-iso", isoDate);
      dateField.focus();
    }
  });
});

initJQLEditor ()

Prepares the JQL Editor dialog in preparation for fast rendering. This method should be called on iframe load if it contains a JQL editor trigger.

Example

1
AP.jira.initJQLEditor();

showJQLEditor (callback, options)

Launches a JQL Editor dialog. A callback will be invoked when the JQL is submitted by the user.

Parameters

NameTypeDescription
callbackfunction

invoked when dialog is submitted, includes an object containing the jql

optionsObject

contains data to pre-fill the dialog with

Properties
NameTypeDefaultDescription
jqlstring

Optionally provide initial JQL to pre-fill the dialog with

headerstring

Optionally overwrite the title of the dialog

descriptionTextstring

Optionally provide up to 512 chars to be displayed below header

submitTextstring

Optionally overwrite the submit button text

cancelTextstring

Optionally overwrite the cancel button text

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
var options = {
  jql: 'project = ACJS',
  header: 'My title',
  descriptionText: 'My custom description text for dialog',
  submitText: 'My submit label',
  cancelText: 'My cancel label'
};

var callback = function(obj) {
  alert(obj.jql);
};

AP.jira.showJQLEditor(options, callback);

  • System status
  • Privacy
  • Developer Terms
  • Trademark
  • Cookie Preferences
  • © 2019 Atlassian