新建问题界面AffectVersions只显示未发布版本
field description里添加javascript
<script type="text/javascript">
// on create issue screen ,remove released versions.
var createScreen=document.getElementById('create-issue-submit');
var projectfield=AJS.$("#project-field");
var issuetypefield=AJS.$("#issuetype-field");
document.getElementById('description').value="外面";
if(createScreen !=null && createScreen.value == "创建"){
removeOption();
AJS.$("#environment").text("project-field changes 1");
issuetypefield.change(function(){
AJS.$("textarea#environment").text("project-field changes 2");
removeOption();
});
}
function removeOption(){
AJS.$("#versions optgroup").each(function() {
document.getElementById('description').value="循环1";
if (AJS.$(this).attr('label')=="已发布版本"){
document.getElementById('description').value="循环2";
AJS.$(this).find('option').each(function(){AJS.$(this).remove();});
}
});
}
</script>
更新版
https://answers.atlassian.com/questions/45825/how-to-remove-options-from-a-multi-version-picker-field
https://answers.atlassian.com/questions/218644/changing-issue-type-is-not-affecting-javascript-for-custom-field
https://answers.atlassian.com/questions/47843/strange-javascript-problem-in-create-screen
使用在两个field configuration中
project或者issue type改变的时候,也会执行下面的脚本。但是如果该脚本放在projectA的field configuration 中,第一次新建问题的时候,默认项目是projectB(非同个field configuration)的话。脚本还是会无效。
而且在进行上述操作后,没有刷新页面的情况下,编辑问题的时候,也会隐藏发布的版本
<script type="text/javascript">
// on create issue screen ,remove released versions.
jQuery(document).ready(function($) {
var createScreen=document.getElementById('create-issue-submit');
removeOption();
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
removeOption();
});
function removeOption(){
if(createScreen !=null && createScreen.value == "创建"){
$("#versions optgroup").each(function() {
if ($(this).attr('label')=="已发布版本"){
$(this).find('option').each(function(){$(this).remove();});
}
});
}
}
});
</script>
========================简单版的
<script type="text/javascript">
// on create issue screen ,remove released versions.
var createScreen=document.getElementById('create-issue-submit');
if(createScreen !=null && createScreen.value == "创建"){
removeOption();
}
function removeOption(){
AJS.$("#versions optgroup").each(function() {
if (AJS.$(this).attr('label')=="已发布版本"){
AJS.$(this).find('option').each(function(){AJS.$(this).remove();});
}
});
}
</script>