JIRA模块列表过滤

因为某些原因,项目中的某些模块不允许提问题单,但是又需要自动化指定(通过rest api等)。

实现方式:修改模版文件,atlassian/jira/atlassian-jira/WEB-INF/classes/templates/jira/issue/field/components-edit.vm

该文件用于create/edit 问题单时加载模块信息。

 1 #disable_html_escaping()
 2 $!{auiparams.put("controlHeaderClass", "aui-field-componentspicker $!fieldLayoutItem.rendererType")}
 3 #customControlHeader ($action $field.id $i18n.getText($field.nameKey) $fieldLayoutItem.required $displayParameters $auiparams)
 4 #if ($components && !$components.empty)
 5     #if ($!isFrotherControl)<div class="ajs-multi-select-placeholder textarea long-field"></div>#end
 6     #if (!$fieldLayoutItem.required)
 7         #set ( $componentHeaderSize = 1)
 8     #end
 9     <select class="select #if ($!isFrotherControl)hidden#end" id="$field.id" multiple="multiple" name="$field.id"
10             size="#minSelectSize($components $componentHeaderSize 5)"
11             data-remove-null-options="true" data-submit-input-val="true" data-input-text="#if (!$bulkEdit)$textutils.htmlEncode($!frotherInputText)#end" data-create-permission="$!{createPermission}">
12         #if (!$fieldLayoutItem.required)
13             <option#if ($currentComponents && $unknownComponentId && $currentComponents.contains($unknownComponentId)) selected="selected"#end value="-1">
14                 $i18n.getText('common.words.unknown')
15             </option>
16         #end
17         #foreach ($component in $components)
18             #if ($component.name.indexOf("(Hide)")==-1)
19                 <option#if ($currentComponents && $component && $currentComponents.contains($component.id)) selected="selected"#end title="$textutils.htmlEncode($component.name) #if($component.description) - $textutils.htmlEncode($component.description)#end" value="$!component.id">
20                     $textutils.htmlEncode($component.name)
21                 </option>
22             #end
23         #end
24     </select>
25     #if ($!isFrotherControl)<div class="description">${i18n.getText('generic.picker.static.desc')}</div>#end
26 #else
27     <span class="field-value">$i18n.getText('common.words.none')</span>
28 #end
29 #customControlFooter ($action $field.id $fieldLayoutItem.getFieldDescription() $displayParameters $auiparams)
30 $!{auiparams.clear()}

17-23行代码块即在初始化模块相关信息界面,包括勾选已选模块,加载可选模块等。其中,加粗显示的18和22行即根据需求添加的过滤条件:如果模块名中包含“(Hide)”字段,则不显示。

修改完成后,重启JIRA即可生效。

经如上修改后,通过REST API等方式可以指定已经隐藏的模块,但在界面上操作时模块不可见,从而实现需求。

c

omponents-edit.vm

猜你喜欢

转载自www.cnblogs.com/l200702031000/p/10032689.html