I am looking at the code for my gadget.xml file which will list out all the projects present in the db via a rest call and gets listed out in a multiselect listbox. user can select the projects of his choice and then save his change.
I have wriiten something down although its not complete. Is this right? What should i write in the view section of module? Can anyone post their implementation for this approach.
<?xml version="1.0" encoding="UTF-8" ?> <Module> <ModulePrefs title="__MSG_gadget.title__" directory_title="__MSG_gadget.title__" description="__MSG_gadget.description__"> <Require feature="views" /> <Require feature="settitle"/> <Require feature="oauthpopup" /> <Optional feature="gadget-directory"> <Param name="categories"> JIRA </Param> </Optional> <Optional feature="atlassian.util" /> <Optional feature="auth-refresh" /> #oauth <Locale messages="__ATLASSIAN_BASE_URL__/download/resources/jira-gadget-tutorial-plugin/i18n/ALL_ALL.xml"/> </ModulePrefs> <UserPref name="isConfigured" datatype="hidden" default_value="false"/> <Content type="html"> <![CDATA[ #requireResource("com.atlassian.gadgets.publisher:ajs-gadgets") <script type="text/javascript"> (function () { var gadget = AJS.Gadget({ baseUrl: "__ATLASSIAN_BASE_URL__", useOauth: "__ATLASSIAN_BASE_URL__/rest/api/2/myself", config: { descriptor: function(args) { var gadget = this; gadgets.window.setTitle("Choose the projects"); var projectpicker = AJS.gadget.fields.projectPicker(gadget,"projectId",args.projects); return { fields: [ projectpicker, { userpref: "selectedprojects", label: "Projects", description: Projects", type: "multiselect", selected: gadget.getPref("selectedprojects"), }, AJS.gadget.fields.nowConfigured() ] }; }, args: function() { return [ { key: "projects", ajaxOptions: "/rest/baseline-gadget/1.0/baselinecomparison/getBaselines.json" } ]; }() }, view: { enableReload: true, onResizeReload: true, template: function(args) { var gadget = this; ]]></Content> </Module>
Community moderators have prevented the ability to post new answers.
Why don't you try multi select list,
You can learn from
https://docs.atlassian.com/aui/latest/sandbox/#
Please try, I didn't try before but I guess,
<label for="project">Projects</label> <select class="multi-select" size="4" multiple="multiple" id="project" name="project">
#foreach($data in getAllProjects()) <option>$data</option> #end </select>
Cheers.
Hi Onkar if you dont mind can you please provide the complete implementation for the project listing. I have tried out some simple example on rest based exmaple as given in the book and jtricks by jobin but each time i get some exception.
i have described it here https://answers.atlassian.com/questions/282117/anyone-tried-the-simple-jira-gadget-implementation
So could you please post the entire implementation for this project listing. i would want to have a look into the atlassian.xml, pom.xml and the gadget.xml files. Would highly appreciate your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Onkar, the project snippet which you pasted here isnt working. i get some error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jayashri,
please try below code,
function getAllProjects() { var allProjects; AJS.$.ajax({ baseUrl: "__ATLASSIAN_BASE_URL__", url: AJS.params.baseURL+"/jira/rest/api/2/project", type: "get", dataType: 'json', async: false, success: function(data) { allProjects = data.value; } }); return allProjects; }
Regards
Onkar ahire
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thnaks Onkar. This i will write it in <![CDATA[ ] right? Or this would go into the .view section of CDATA[]?Also this would probably display list of projects. I need the user to select multiple projects from the list. How can i achieve that?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.