如何使用JIRA AUI功能在我自己的自定义领域-速度编辑
How to use JIRA AUI functions in my own custom field - velocity edit.vm
我正在尝试在JIRA中使用一些AUI -在编辑模式下使用JAVA编写我自己的自定义字段。我发现这个页面:https://docs.atlassian.com/aui/latest/sandbox/#和在未来我想使用设置一个例子Auiselect2。
https://docs.atlassian.com/aui/5.5.1/docs/auiselect2.html -这里写的,这只是实验性的,那么我应该做哪些步骤来使用它?在下面的示例中,您可以看到,我试图添加此功能,但它根本不起作用。我使用了docs -
中提到的一个例子edit.vm:
$webResourceManager.requireResource("cz.firma.rozy:zakaznik")
<form class="aui">
<select id="select2-example" multiple>
<option value="CONF">Confluence</option>
<option value="JIRA">JIRA</option>
<option value="BAM">Bamboo</option>
<option value="JAG">JIRA Agile</option>
<option value="CAP">JIRA Capture</option>
<option value="AUI">AUI</option>
</select>
</form>
和zakaznik.js
AJS.$(function() {
AJS.$("#select2-example").auiSelect2();
});
我的atlassian-plugin.xml是:
<web-resource key="zakaznik-resources" name="zakaznik Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<dependency>com.atlassian.auiplugin:jquery</dependency>
<dependency>com.atlassian.auiplugin:jquery-ui-other</dependency>
<dependency>com.atlassian.auiplugin:aui-select2</dependency>
<context>atl.general</context>
<context>atl.admin</context>
<resource type="download" name="zakaznik.css" location="/css/zakaznik.css"/>
<resource type="download" name="zakaznik.js" location="/js/zakaznik.js"/>
<resource type="download" name="images/" location="/images"/>
<context>zakaznik</context>
</web-resource>
...
<customfield-type name="Pridani zakaznika" i18n-name-key="customer-add.name" key="customer-add" class="cz.firma.rozy.jira.customfields.CustomerCustomField">
<description key="customer-add.description">Plugin, ktery prida zakaznika z abry</description>
<resource name="view" type="velocity" location="templates/viewCustomer.vm"/>
<resource name="edit" type="velocity" location="templates/edit.vm"/>
</customfield-type>
但是当我访问编辑模式时,没有jQuery完成-浏览器控制台没有写任何错误或警告。
只需将这一行添加到编辑中。Vm将包含select2 js.
$webResourceManager.requireResource("com.atlassian.auiplugin:aui-select2")
你不需要把它作为依赖项添加到web-resource中。
在js文件中通过-
调用select2AJS.$("#select2-example").select2();
您需要通过webResourceManager
加载aui资源。不需要更改atlassian-plugin.xml
。您的customfields .vm
文件可能如下所示:
#controlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters.noHeader)
$webResourceManager.requireResource("com.atlassian.auiplugin:aui-select2")
<script type="text/javascript">
AJS.toInit(function() {
AJS.$("#$customField.id").select2();
});
</script>
<select name="$customField.id" id="$customField.id" multiple>
#foreach ($option in $options)
<option value="$option">$option</option>
#end
</select>
#controlFooter ($action $fieldLayoutItem.fieldDescription $displayParameters.noHeader)
您只需要在edit.vm
中添加以下内容$webResourceManager.requireResourcesForContext("zakaznik")
我不同意提供的其他答案。当我们已经在资源文件中添加了js,为什么要在编辑中再做一次呢?虚拟机文件。参考我们已经创建的web资源和它的上下文
相关文章:
- 如何从自定义对话框编辑数据网格中的选定行
- 在plone 5中将自定义的灵活性内容类型插入到tinymce编辑器中
- 扩展 ACE 编辑器,如何导入自定义文件
- 如何在vim编辑器中为esint指定自定义--rulesdir
- Kendo UI网格自定义编辑按钮
- Kendo Scheduler自定义编辑弹出模板中的附加按钮
- 单击自定义编辑按钮时,X可编辑切换编辑
- Ext.js 网格中的自定义编辑器
- Jqgrid 单击自定义编辑按钮打开另一个页面
- 剑道网格自定义编辑器下拉列表;t反映选择
- 带有事件MVC3的自定义编辑器模板
- 使用下拉列表编辑器的剑道网格-线编辑(编辑自定义编辑器)
- 自定义编辑器在光滑网格
- KendoUI Grid:自定义编辑表单,日期选择器返回false格式
- 剑道网格使用内联编辑和自定义编辑器下拉控件
- 如何在JsGrid中自定义编辑事件
- 以编程方式关闭自定义编辑器
- 创建自定义编辑器窗口kendojs网格
- 内容工具 - 无法使用自定义编辑按钮重新激活
- 剑道UI:带有自定义编辑模板的网格,使用API设置值时不会绑定DatePicker