JIRA - list projects in configuration and remember selection

泪湿孤枕 提交于 2019-12-11 18:57:29

问题


I am trying to create a dashboard gadget that will display a list of JIRA projects in its configuration dialog and allow the user to select from the list. I need to be able to remember this list of projects (so save them on the server somehow). How do I go about doing that for a list?

I am using the latest jira version out

Thanks


回答1:


Use this code in gadget.xml file:

...
<UserPref name="projectId" display_name="Project" datatype="select" default_value=""/>
...
<script type="text/javascript">
    (function () {
        var gadget = AJS.Gadget({
            baseUrl: "__ATLASSIAN_BASE_URL__",
            config: {
            descriptor: function (args) {
              var gadget = this;

              var projects = [{"label":"All","value":""}];
              projectsMap = args.projects.options;
              for(key in projectsMap) {
                projectName = projectsMap[key].label;
                projects.push({"label":projectName,"value":projectName});
              }

              return {
                  fields: [
                      {
                        userpref: "projectId",
                        label: "Project",
                        type: "select",
                        selected: this.getPref("projectId"),
                        options: projects
                      },
                      ...
                      AJS.gadget.fields.nowConfigured()
                  ]
              };
            },
            args : [{
              key: "projects",
              ajaxOptions: "/rest/gadget/1.0/filtersAndProjects?showFilters=false"
            }]
            },
            view: {
                enableReload: true,
                template: function(args) {
                    var gadget = this;
                    ...
                },
                args: [{
                    key: "timesheet",
                    ajaxOptions: function() {
                        return {
                            url: "/rest/timepo-resource/1.0/issues-report.json",  //put your url here
                            data: {
                              projectId: this.getPref("projectId"),
                              ...
                              baseUrl: "__ATLASSIAN_BASE_URL__"
                            }
                        };
                    }
                }]
            }
        });
    })();
</script>


来源:https://stackoverflow.com/questions/19440194/jira-list-projects-in-configuration-and-remember-selection

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!