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
callback

WorkflowConfiguration

the callback that handles the response.


isDashboardItemEditable (callback)

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

Parameters

NameTypeDescription
callback

function

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
callback

function

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

params

Object

contains data to pre-fill the dialog with

Properties
NameTypeDefaultDescription
pid

number

Project to pre-fill the dialog with

issueType

number

Issue type to pre-fill the dialog with

fields

Object

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 : [10005, 10006],
    timetracking_originalestimate: "2w",
    timetracking_remainingestimate: "3d",
    worklog_activate: true,
    worklog_timeLogged: "2"
  }
});

openIssueDialog (issueKey, callback)

Opens the issue dialog for an issue. A callback is invoked when the issue dialog is closed or an error occurs when opening the issue dialog.

Parameters

NameTypeDescription
issueKey

String

The key of the issue.

callback

function

Invoked when the dialog is closed. Takes a single parameter, either issueKey or, if the issue dialog isn't opened, an error key. it is impossible to open a issue dialog.

Example

1
2
3
4
5
6
AP.jira.openIssueDialog(
 'DEMO-1',
 function(){
   alert('Closed!');
 }
);

setDashboardItemTitle (title)

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

Parameters

NameTypeDescription
title

String

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
callback

function

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

options

Object

contains data to pre-fill the dialog with

Properties
NameTypeDefaultDescription
jql

string

Optionally provide initial JQL to pre-fill the dialog with

header

string

Optionally overwrite the title of the dialog

descriptionText

string

Optionally provide up to 512 chars to be displayed below header

submitText

string

Optionally overwrite the submit button text

cancelText

string

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);

isNativeApp (callback)

Returns whether the addon is being shown within a native app on iOS, Android or Mac.

Parameters

NameTypeDescription
callback

function

the callback that handles the response


Rate this page: