Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JIRA Gadget - Create a drop down list based on a REST call

Techie Guy February 28, 2012

I am writing a new JIRA gadget. I want to have a user preference field called Version which can be loaded dynamically from the backend via a REST call.

Please help with the approach and code.

THanks

3 answers

0 votes
tousifs
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 29, 2012

Hi Techie Guy,

<Optional feature="atlassian.util"/>
#oauth
#supportedLocales("gadget.common,gadget.user.activity")


<UserPref name="projectpicker" datatype="hidden"/>you can specify the customized user preferences. e.g Version

AJS.gadget.fields.projectsOrCategoriesPicker(gadget, "projectpicker"), -- it will get focused on load.

this way you can add project picker. or any if you still want to add simple select field manually you can refer the

https://developer.atlassian.com/display/GADGETS/Gadget+Developer+Documentation

0 votes
Techie Guy February 28, 2012

Thanks Tousif. But this will not be a user preference then. Also I am looking for more of a dropdown than a numbered list or unnumbered list.

Your thoughts ? Do you know of sample code which displays dropdown ?

0 votes
tousifs
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2012

Hi,

You can refer existing Gadget's according to there standard they have created what you want

e.g

view: {
template: function(args) {
var gadget = this;

var projectList = AJS.$("<ul/>");

AJS.$(args.projectData.projects).each(function() {
projectList.append(
AJS.$("<li/>").append(
AJS.$("<a/>").attr({
target: "_parent",
title: gadgets.util.escapeString(this.description),
href: "__ATLASSIAN_BASE_URL__" + "/browse/" + this.key
}).text(this.name)
)
);
});

gadget.getView().html(projectList);
},
args: [{
key: "projectData",
ajaxOptions: function() {
return {
url: "/rest/tutorial-gadget/1.0/projects.json"
};
}
}]
}

may be it will work for you .

please refer https://developer.atlassian.com/display/GADGETS/Gadget+Developer+Documentation it will helpful for you.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events