Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

fabby April 12, 2012

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 ?

4 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Azfar Masut
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 17, 2019
0 votes
fabby April 13, 2012

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.

0 votes
fabby April 13, 2012

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

0 votes
Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 12, 2012

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 :)



Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 12, 2012

Or you can directly run your javascript using setHelpText() and apply the condition to it .

fabby April 12, 2012

but the problem is how to hide the released versions by javascript

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 12, 2012

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.

fabby April 12, 2012

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

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 12, 2012

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)

fabby April 12, 2012

after setHelpText("your_javascript") some options is removed,and even if setHelpText("") ,the options will sitll not come back.

fabby April 12, 2012

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events