how to make the field fixVersion hide released versions when resolution is "fixed" and show all versions if not choose "fixed" as resolution using javascript?
i have tried the following js,but
<script type="text/javascript">
// on resolve screen when choose 'fix' as resolution,only unreleased versions can be displayed.
var resolution=AJS.$("#resolution");
var resolvedScreen=document.getElementById('issue-workflow-transition-submit');
if( resolvedScreen !=null && resolvedScreen.value == "Resolve"){
AJS.$("#fixVersions").get(0).selectedIndex=-1;
if(resolution){
if(resolution.val()==1){
AJS.$("#fixVersions optgroup").each(function() {
if (AJS.$(this).attr('label')=='Released Versions'){
AJS.$(this).find('option').each(function() {
AJS.$(this).hide();
});
}
});
}
// when resolution changes
resolution.change(function(){
if(resolution.val()==1){
AJS.$("#fixVersions optgroup").each(function() {
if (AJS.$(this).attr('label')=='Released Versions'){
AJS.$(this).find('option').each(function() {
AJS.$(this).hide();
});
}
});
}else{
AJS.$("#fixVersions optgroup").each(function() {
if (AJS.$(this).attr('label')=='Released Versions'){
AJS.$(this).find('option').each(function() {
AJS.$(this).show();
});
}
});
}
});
}
}
</script>
the method hide() and show() does not make effect,if i use remove(),it does work,but i can not restore the Released Versions options because i have remove the options.
anyone has any ideas about how to resolve it ?
Community moderators have prevented the ability to post new answers.
anyone can tell me how to make the fixVersion show only one group(optgroup) of versions on one condition,and show other group(optgroup) of versions on another condition.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
anyone can tell me how to make the fixVersion field show one group(optgroup)/s of versions in one condition and show other group(optgroup)/s of versions in another condition
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have done something similar using behaviours plugin , i wrote a a server side groovy script on the field(version picker) which hides few versions.
In your case you need to hide only released version if resolution is fixed .
So first in your groovy script get all the released version for your project using getVersionsReleased
now you can hide the released versions by applying a javascript using the setHelpText("your_javascript") method of the behaviours plugin.
after you have added this serverside script you need to add a condition for this script i.e when resolution is fixed
Hope this helps :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Or you can directly run your javascript using setHelpText() and apply the condition to it .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What happens when you use remove() .
I did not get what you meant by this
but i can not restore the Released Versions options because i have remove the options.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if you have removed the field's options ,the DOM element is no longer exist,then how can you make the field's options show again,
if i use hide/show,for example
1, in my test.html
<script type="text/javascript">
$(document).ready(function(){
$(".btn1").click(function(){
$("p").wrap("<div></div>").hide();
});
$(".btn2").click(function(){
$("p").wrap("<div></div>").show();
});
});
</script>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button class="btn1">hide</button>
<button class="btn2">show</button>
the script can use the two button to make "p" hide or show
2, in my test2.html
<select name="propsearch[area]" id="propsearch_area">
<option value="0">- Any -</option>
<optgroup label="Bristol">
<option value="Hotwells">Hotwells</option>
<option value="Montpelier">Montpelier</option>
</optgroup>
<optgroup label="Cardiff">
<option value="Heath">Heath</option>
<option value="Roath">Roath</option>
</optgroup>
<optgroup label="Exeter">
<option value="Pennsylvania Road">Pennsylvania Road</option>
<option value="Lower North Street">Lower North Street</option>
</optgroup>
</select>
<script type="text/javascript">
$("#propsearch_area optgroup").each(function() {
if ($(this).attr('label')=='Bristol'){
$(this).find('option').each(function() {
$(this).hide();
});
}
});
</script>
the script also can hide 'Bristol' options.
3,
but for JIRA ,AJS.$(this).hide(); does not work
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you want to hide the options when the resolution chosed is fixed , so you need to listen the resolution field . when the option select in the resolution field is "fixed" run the javascript using setHelpText("your_javascript") when the option is something else disable the javascript using setHelpText("") . Have not tried something like this but i guess it will work (there is a similar example here)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i have tried one method:if someone choose one of the Released Versions,the js will force the fixversion to choose "none" whose selectedIndex=-1,the script is as follows,
AJS.$("#fixVersions").change(function(){
var group=AJS.$("#fixVersions").find("option:selected").parent().attr('label');
if (group=="Released Versions){
AJS.$("#fixVersions").val("-1");
}
});
but the js is only useful for SelectList Renderer,not for Autocomplete Renderer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.