JIRA - 在配置中列出项目并记住选择

时间:2013-10-18 01:40:26

标签: jira jira-plugin

我正在尝试创建一个仪表板小工具,它将在其配置对话框中显示JIRA项目列表,并允许用户从列表中进行选择。我需要能够记住这个项目列表(所以以某种方式将它们保存在服务器上)。我如何为列表做这件事?

我正在使用最新的jira版本

由于

1 个答案:

答案 0 :(得分:2)

gadget.xml 文件中使用此代码:

...
<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>