0

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

我正在使用最新的 jira 版本

谢谢

4

1 回答 1

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>
于 2014-07-11T10:02:09.820 回答