Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Can anyone please provide the source code for a gadget displaying the projects in a select list ?

Jayashree Shetty
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.
May 20, 2014

i am really in need of some help because i am stuck in implementing this. could anyone please provide the source code for a gadget which can display the projects in a select list using rest ? somehow the rest is getting trickier and i am not able to display this info in my gadget

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Jayashree Shetty
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.
May 20, 2014
I could solve this using the xml snippet as given below. This uses the projectId. We can use the projectorFilterId too. When i do that part of coding shall post that too .

<?xml version="1.0" encoding="UTF-8" ?>
<Module>
    <ModulePrefs title="__MSG_gadget.title__"
                 title_url="__MSG_gadget.title.url__"
                 description="__MSG_gadget.description__"
		         height="150"
                 >
        <Optional feature="gadget-directory">
            <Param name="categories">
                Other
            </Param>
        </Optional>
        <Optional feature="atlassian.util" />
        <Optional feature="auth-refresh" />
        <Require feature="views" />
        <Require feature="settitle" />
        <Require feature="oauthpopup" />
        <Require feature="setprefs" />
        <Require feature="dynamic-height" />
        
        #oauth
        #supportedLocales("gadget.common")
		<Locale messages="__ATLASSIAN_BASE_URL__/download/resources/com.siemens.plugin.mygadget/i18n/messages.xml"/>
    </ModulePrefs>
    
    <UserPref name="isConfigured" datatype="hidden" default_value="false"/>
	<UserPref name="refresh" datatype="hidden" default_value="false"/>
    <UserPref name="projectOrFilterId" datatype="hidden" />
	<!-- <UserPref name="displayName" datatype="hidden" default_value="true"/> -->
    <Content type="html" view="profile">
        <![CDATA[
     #requireResource("com.atlassian.jira.gadgets:jira-global")
     #requireResource("com.atlassian.jira.gadgets:autocomplete")
     #includeResources()
 
<script type="text/javascript">
     (function ()
     {
 
         var gadget = AJS.Gadget({
             baseUrl: "__ATLASSIAN_BASE_URL__",
             useOauth: "/rest/gadget/1.0/currentUser",
             config: {
                 descriptor: function(args)
                 {
                     var gadget = this;
                     gadgets.window.setTitle("My Gadget");
                     var projectPicker = AJS.gadget.fields.projectPicker(gadget, "projectId", args.projectOptions);
 
                     return {
 
                         theme : function()
                         {
                             if (gadgets.window.getViewportDimensions().width < 450)
                             {
                                 return "gdt top-label";
                             }
                             else
                             {
                                 return "gdt";
                             }
                         }(),
                         fields: [
                             projectPicker,
                             AJS.gadget.fields.nowConfigured()
                         ]
                     };
                 },
                 args: function()
                 {
                     return [
                         {
                             key: "projectOptions",
                             ajaxOptions:  "/rest/gadget/1.0/filtersAndProjects?showFilters=false"
 
                         } 
                     ];
                 }()
             },
             view: {
                 onResizeAdjustHeight: true,
                 enableReload: true,
                 template: function(args)
				  {
                       var gadget = this;                          
                       gadget.getView().html("project:"+gadget.getPref("projectId")+"!");
                  }
             }
         });
 
     })(); 
        </script>
        ]]>
    </Content>
 </Module>

Also to mention i got a lot of help from the following links

https://answers.atlassian.com/questions/232272/gadget-projectorfilterpicker-does-not-reload-config

https://developer.atlassian.com/display/JIRADEV/Writing+a+Plugin+Gadget+that+Shows+Days+Left+in+a+Version

TAGS
AUG Leaders

Atlassian Community Events