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

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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



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

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

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.

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

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

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

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

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.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
Community showcase
Published in Confluence Cloud

Share your Confluence Cloud experience for a chance to win $500!

Take our 5-minute survey to win a $500 Visa gift card! Are you currently using Confluence Cloud? We want to hear from you! Fill out this quick survey about your Confluence Cloud experience so we ...

159 views 1 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you