README
This repository contains a javascript module for autocompleting JQL queries in JIRA.
How do I get set up?
Download the jql-autocomplete.js file and include it in your page.
To enable autocompletion on a selected input field create an autocompletion controller:
#!javascript
var JQLAutocomplete = new JQLAutocomplete(data);
and pass the parsed JSON response of this JIRA REST resource using the following method:
#!javascript
JQLAutocomplete.passAutocompleteData(autocompleteData);
constructorData
The constructorData object is formed as follows:
#!javascript
var constructorData = {
input: element,
render: function(),
getSuggestions: function(),
maxSuggestions: number
};
input
The input property is a reference to the input field you wish to enable autocompletion on.
render
To initialize the module, you have to provide a render method.
#!javascript
function render(suggestions) {...}
This method will be called each time the user interacts with the input field.
It will receive exactly one parameter - an array containing autocomplete suggestions. The array is formed as follows:
#!javascript
var suggestions = [
{
text: 'string',
onClick: function()
},
...
];
The text property contains the display text for a suggestion.
The onClick property is a method that should be called when the suggestion is clicked.
It's up to you how to display the suggestions.
getSuggestions
When called, this method should return this JIRA REST resource. The response should be a parsed JSON.
#!javascript
function getSuggestions (fieldName, callback) {...}
It receives exactly two parameters - the name of the field to get the suggestions for and a callback function. The callback function should be called as soon as the REST response arrives and should be given the parsed reponse as the only parameter.
This property is optional - if omitted, the plugin will not autocomplete values for fields.
maxSuggestions
The maximal number of suggestions you wish the module to generate.
This property is optional - if omitted, the plugin will generate every reasonable suggestion.