添加JS webresource以在速度

时间:2017-03-02 07:58:03

标签: javascript java jira jira-plugin

我是Jira插件开发的新手,我正在尝试为JIRA(6.3.4)开发项目标签面板插件。

我在" resources / js / updateIssueTypes.js" 的JS文件,它在速度模板中不起作用。

JS文件未下载到页面

哪里出错?

以下是JS文件的内容:

$(function() {
    alert("haha");
    $("#selectedProject").change(function () {
        var key = $(this).val();
        $("#selectedIssueType").empty();
        $.getJSON("/rest/api/2/project/" + key, function(data) {
            var items = data.issueTypes;
            $.each(data, function( key, val ) {
                var option = $('<option/>');
                option.attr({'value': val.id }).text(val.nameTranslation);
                $('#selectedIssueType').append(option);
            });
        });
    })
});

速度文件的内容如下:

<head>
#requireResource("ru.company.plugins.postfunctions.Newtask:updateIssueTypes")
</head>
<body>
some code...
</body>

atlassian-plugin.xml添加了这样的webresource:

<?xml version="1.0" encoding="UTF-8"?>

<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2">
  <plugin-info>
    <description>${project.description}</description>
    <version>${project.version}</version>
    <vendor name="${project.organization.name}" url="${project.organization.url}"/>
    <param name="plugin-icon">images/pluginIcon.png</param>
    <param name="plugin-logo">images/pluginLogo.png</param>
  </plugin-info>

  <!-- add our i18n resource -->
  <resource type="i18n" name="i18n" location="i18n"/>

  <!-- add our web resources -->
  <web-resource key="new-task-resources" name="new-task Web Resources">
    <resource type="download" name="images/" location="resources/images"/>
    <context>new-task</context>
  </web-resource>


  <web-resource key="updateIssueTypes" name="updateIssueTypes" >
    <resource type="download" name="updateIssueTypes" location="js/updateIssueTypes.js"/>
    <context>new-task</context>
    <context>atl.general</context>
    <context>jira.general</context>
  </web-resource>


  <workflow-function key="new-task" name="New Task" i18n-name-key="new-task" class="ru.company.jira.workflow.NewTaskFactory">
    <description key="new-task.description">The New Task Plugin</description>
    <function-class>ru.company.jira.workflow.NewTask</function-class>
    <resource type="velocity" name="view" location="templates/postfunctions/new-task.vm"/>
    <resource type="velocity" name="input-parameters" location="templates/postfunctions/new-task-input.vm"/>
    <resource type="velocity" name="edit-parameters" location="templates/postfunctions/new-task-input.vm"/>
  </workflow-function>
</atlassian-plugin>
像这样的pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>ru.company.plugins.postfunctions</groupId>
    <artifactId>Newtask</artifactId>
    <version>1.0.1</version>
.......some code........

1 个答案:

答案 0 :(得分:1)

已解决!

旧版本:

<head>
#requireResource("ru.company.plugins.postfunctions.Newtask:updateIssueTypes")
</head>

新版本:

<head>
</head>
$webResourceManager.requireResource("ru.eldorado.plugins.postfunctions.Newtask:new-task-resources")